/
aws.yml
43 lines (41 loc) · 1.21 KB
/
aws.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
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Launch EC2 instance
ec2:
group: "{{ aws.security_group }}"
instance_type: "{{ aws.instance_type }}"
instance_profile_name: "{{ aws.instance_profile_name }}"
instance_tags:
Name: pcgr "{{ pcgr.release }}"
name: pcgr
#spot_price: "{{ aws.spot_price }}"
image: "{{ aws.image_id }}"
keypair: "{{ aws.keypair }}"
region: "{{ aws.region }}"
zone: "{{ aws.zone }}"
wait: yes
volumes:
- device_name: "{{ aws.volume_device }}"
volume_type: gp2
volume_size: "{{ aws.volume_size }}"
delete_on_termination: true
count_tag:
name: pcgr
exact_count: 1
register: ec2
- name: Add new instance to host group
add_host:
hostname: "{{ item.public_dns_name }}"
groupname: launched
with_items: "{{ ec2.instances }}"
- name: Wait for SSH to come up
wait_for:
host: "{{ item.public_dns_name }}"
port: 22
delay: 60
timeout: 320
state: started
with_items: "{{ ec2.instances }}"