-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-ec2.yml
49 lines (43 loc) · 1.2 KB
/
provision-ec2.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
---
# Provision an AWS EC2 instance
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- group_vars/all
tasks:
- name: Provision an AWS EC2 instance
ec2:
key_name: "{{ ec2_key_name }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
region: "{{ ec2_region }}"
group: "{{ ec2_group }}"
instance_type: "{{ ec2_instance_type }}"
image: "{{ ec2_image }}"
vpc_subnet_id: "{{ ec2_vpc_subnet }}"
assign_public_ip: yes
source_dest_check: no
wait: true
exact_count: 1
count_tag:
Name: pritunl-vpn
ID: 07032019-01
instance_tags:
Name: pritunl-vpn
ID: 07032019-01
register: ec2
# add the new instance into a host group so we
# can call it later when installing the VPN
# software
- name: Add instance public IP to host group
add_host:
hostname: '{{ item.public_ip }}'
groupname: pritunl
loop: "{{ ec2.instances }}"
- name: Wait for SSH to come up
delegate_to: "{{ item.public_dns_name }}"
wait_for_connection:
delay: 60
timeout: 320
loop: "{{ ec2.instances }}"