-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2_new.yml
39 lines (35 loc) · 1.19 KB
/
ec2_new.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
---
- name: ec2 create new
hosts: localhost
gather_facts: false
connection: local
vars:
tags:
env: "{{ tags_env | default('prod') }}"
type: "{{ tags_type | default('web') }}"
tasks:
- name: launch instance
local_action:
module: ec2
count: "{{ count }}"
keypair: "{{ keypair | default('undefined') }}"
instance_type: "{{ type | default('t2.micro') }}"
vpc_subnet_id: "{{ vpc_subnet_id | default('undefined') }}"
image: "{{ ami | default('undefined') }}"
region: "{{ region | default('us-west-2') }}"
group: "{{ security_group | default('ssh-only') }}"
wait: yes
instance_tags: "{{ tags | default('undefined') }}"
#user_data: "{{ lookup('template', 'ec2_bootstrap.j2') }}"
user_data: "{{ lookup('template', 'user-data.j2') }}"
assign_public_ip: "{{ assign_eip | default(true) }}"
register: ec2
- name: Wait for SSH to come up
wait_for_connection:
delay: 60
timeout: 320
with_items: "{{ ec2.instances }}"
- name: Instance info
debug:
msg: "{{ item.id }} {{ item.public_ip }}"
with_items: "{{ ec2.instances }}"