-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathaws_sandbox_deploy.yml
52 lines (47 loc) · 1.37 KB
/
aws_sandbox_deploy.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
---
- name: Create a sandbox instance
hosts: localhost
gather_facts: False
vars:
keypair: us-jhooker-aws-admin
instance_type: t2.micro
security_group: ansible-security-group
image: ami-0520e698dd500b1d1
region: us-east-2
tasks:
- name: Launch instance
ec2:
key_name: "{{ keypair }}"
group: "{{ security_group }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
wait: true
region: "{{ region }}"
vpc_subnet_id: subnet-e45a7a8c
assign_public_ip: yes
instance_tags:
Name: "Jonathan's Awesome Instance"
location: ohio-ansible-cluster
source: sid
register: ec2
- name: Ensure new instance is in host group
add_host:
hostname: "{{ item.public_ip }}"
groupname: launched
loop: "{{ ec2.instances }}"
- name: Pause ansible run and wait for AWS instance to come up and ssh to be available
delegate_to: "{{ item.public_dns_name }}"
wait_for_connection:
delay: 60
timeout: 320
loop: "{{ ec2.instances }}"
- name: Dump core instance config
debug:
msg: "IP of new instance(s): {{ item.public_ip }}"
loop: "{{ ec2.instances }}"
- name: Ensure sample application is available
hosts: launched
become: True
gather_facts: True
roles:
- my_awesome_role