-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-infra.yaml
64 lines (61 loc) · 1.63 KB
/
create-infra.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
---
- name: "Load variables"
hosts: localhost
connection: local
gather_facts: no
tags: [ always ]
tasks:
- include_vars: vars/vault.yaml
- name: "Setup AWS SSH Keys"
hosts: localhost
connection: local
gather_facts: no
become: no
tags: [ aws ]
tasks:
- name: "Setup SSH keys"
ec2_key:
name: "{{ item.key }}"
key_material: "{{ item.value.key }}"
region: "{{ ec2_region }}"
with_dict: "{{ ssh_keys }}"
- name: "Setup falcon.fnord.net AWS instance"
hosts: localhost
connection: local
gather_facts: no
become: no
tags: [ aws ]
tasks:
- name: "Create instance"
ec2:
# Xenial ebs-ssd image
image: ami-f652979b
instance_type: t2.micro
key_name: jezebel
instance_tags: { Name: falcon }
count_tag:
Name: falcon
exact_count: 1
region: "{{ ec2_region }}"
wait: yes
register: ec2_falcon_all
- name: "Save falcon instance data"
set_fact:
ec2_falcon_id: "{{ ec2_falcon_all['tagged_instances'][0]['id'] }}"
- debug: var=ec2_falcon_id
- debug: var=falcon_eip
- name: "Associate Elastic IP with falcon"
ec2_eip:
region: "{{ ec2_region }}"
public_ip: "{{ falcon_eip }}"
device_id: "{{ ec2_falcon_id }}"
- name: "Create DNS entry for falcon.fnord.net"
dnsmadeeasy:
domain: fnord.net
record_name: falcon
record_type: A
record_value: "{{ falcon_eip }}"
record_ttl: "{{ dns_ttl |default(3600) }}"
state: present
account_key: "{{ dme_api_key }}"
account_secret: "{{ dme_secret_key }}"