-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2launch.yml
43 lines (39 loc) · 1 KB
/
ec2launch.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
- name: ec2 launcher
hosts: localhost
gather_facts: no
vars_files:
- group_vars/packt
tasks:
- name: launching first ec2
ec2:
instance_type: "{{ aws_instance_type }}"
key_name: "{{ aws_key_name }}"
image: "{{ aws_image }}"
region: "{{ aws_region }}"
group_id: sg-2fa1114f
count: 1
vpc_subnet_id: "{{ aws_subnet_id }}"
wait: yes
assign_public_ip: yes
register: ec2
- name: Add new instance to host group
add_host:
hostname: "{{ item.public_ip }}"
groupname: ec2_server
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 }}"
- hosts: ec2_server
gather_facts: no
become: yes
tasks:
- name: copy a file
copy:
src: files/ab.txt
dest: /home/ab.txt