-
Notifications
You must be signed in to change notification settings - Fork 2
/
inventory_setup.yml
68 lines (63 loc) · 1.66 KB
/
inventory_setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Create VPC and Subnet
ec2_vpc:
state: present
region: us-east-1
cidr_block: 20.0.0.0/16
subnets:
- cidr: 20.0.0.0/16
resource_tags: {"Name":"Test Subnet"}
route_tables:
- subnets:
- 20.0.0.0/16
routes:
- dest: 0.0.0.0/0
gw: igw
wait: yes
internet_gateway: yes
resource_tags:
Name: "Test VPC"
register: vpc
- name: get igw
ec2_vpc_igw:
vpc_id: "{{ vpc.vpc_id }}"
region: us-east-1
state: present
register: igw
- name: Tagging the new internet gateway created
ec2_tag:
resource: "{{ igw.gateway_id }}"
state: present
region: us-east-1
tags:
Name: test-gateway
- name: Create a group for our ec2 instances
ec2_group:
name: ansible_ssh_open
description: an example EC2 group
vpc_id: "{{ vpc.vpc_id }}"
region: us-east-1
rules:
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- name: Provision a set of instances
ec2:
key_name: ansible_key
group: ansible_ssh_open
instance_type: t2.micro
image: "ami-0b33d91d"
region: us-east-1
vpc_subnet_id: "{{ vpc.subnets[0].id }}"
assign_public_ip: true
exact_count: 3
count_tag: "ansible_instances"
instance_tags:
ansible_instances: "True"
instance_number: "ec2 aws instance"
wait: true