-
Notifications
You must be signed in to change notification settings - Fork 40
/
aws_add_node.yml
70 lines (65 loc) · 2.43 KB
/
aws_add_node.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
- name: Create OpenShift Instances for Scale Up
hosts: localhost
gather_facts: no
vars_files:
- aws_vars.yml
tasks:
- name: Provision AWS Instances for Scale Up
ec2:
key_name: "{{ aws_key_name }}"
group: "{{ aws_sec_group }}"
instance_type: "{{ item.type }}"
image: "{{ item.image }}"
wait: yes
instance_tags:
"{'Name': '{{ item.name }}-{{ student_id }}.{{ domain_name }}', 'lab_name': '{{ lab_name }}', 'lab_user': '{{ lab_user }}', 'lab_role': '{{ item.meta.node_type }}', 'student_id': '{{ student_id }}', 'node_group': '{{ item.meta.node_group }}', 'kubernetes.io/cluster/{{ student_id }}': '{{ student_id }}'}"
vpc_subnet_id: "{{ aws_subnet_id }}"
zone: "{{ aws_az_1 }}"
assign_public_ip: yes
region: "{{ aws_region }}"
state: present
user_data: "{{ lookup('template', 'aws_user_data.j2') }}"
with_items: "{{ aws_instances }}"
when: item.meta.node_type == 'node' or item.meta.node_type == 'new_node'
register: instances_created
- add_host:
hostname: "{{ item.instances.0.tags.Name }}"
ansible_host: "{{ item.instances.0.public_ip }}"
public_dns_name: "{{ item.instances.0.public_dns_name }}"
public_ip: "{{ item.instances.0.public_ip }}"
groups: OSEv3
student_id: "{{ item.instances.0.tags.student_id }}"
when: item['instances'] is defined
with_items: "{{ instances_created.results }}"
- debug:
var: groups
verbosity: 2
- name: Wait for ssh
wait_for:
port: 22
host: "{{ item.instances.0.public_ip }}"
timeout: 1000
when: item['instances'] is defined
with_items: "{{ instances_created.results }}"
- name: Register Host DNS
route53:
command: create
zone: "{{ domain_name }}"
type: A
overwrite: True
ttl: 60
record: "{{ item['instances'][0]['tags']['Name'] }}"
value: "{{ item['instances'][0]['public_ip'] }}"
wait: yes
when: item['instances'] is defined
with_items: "{{ instances_created.results }}"
- name: Wait for resolvable route53 hostname
local_action: command host {{ item['instances'][0]['tags']['Name'] }}
register: host_result
until: host_result.rc == 0
retries: 60
delay: 5
when: item['instances'] is defined
with_items: "{{ instances_created.results }}"
...