scottslowe-learning-tools/ansible/ansible-aws/create.yml
Scott Lowe 43ab5524a2
Reorganize repository contents
Move contents into new folder structure based on primary technology

Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
2017-02-23 16:12:37 -07:00

41 lines
1,002 B
YAML

---
- hosts: "localhost"
connection: "local"
gather_facts: false
vars:
ami: "<insert AMI ID here>"
region: "<insert AWS region here>"
type: "t2.micro"
sshkey: "<insert SSH keypair name here>"
vpcid: "<insert VPC ID here>"
tasks:
- name: "Create a new security group"
ec2_group:
name: "ansible-sec-group"
description: "New SG for Ansible-created instances"
region: "{{ region }}"
vpc_id: "{{ vpcid }}"
rules:
- proto: "tcp"
from_port: 22
to_port: 22
cidr_ip: "0.0.0.0/0"
rules_egress:
- proto: "all"
cidr_ip: "0.0.0.0/0"
register: secgrp
- name: "Provision an EC2 instance"
ec2:
key_name: "{{ sshkey }}"
group_id: "{{ secgrp.group_id }}"
instance_type: "{{ type }}"
ec2_region: "{{ region }}"
image: "{{ ami }}"
wait: true
count: 1
instance_tags:
tool: "ansible"
env: "test"
register: ec2instance