forked from hortonworks/ansible-hortonworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_gce_nodes.yml
72 lines (67 loc) · 2.43 KB
/
build_gce_nodes.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
71
72
---
- set_fact: outer_loop="{{ item }}"
- name: Create {{ outer_loop.host_group }} root disk(s)
gce_pd:
zone: "{{ cloud_config.zone }}"
name: "{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
image: "{{ outer_loop.image }}"
disk_type: "{{ outer_loop.root_disk.type }}"
size_gb: "{{ outer_loop.root_disk.size }}"
mode: READ_WRITE
state: present
loop_control:
loop_var: local_loop
with_sequence: count="{{ outer_loop.count }}" format=-%02x
async: 1000
poll: 0
register: current_disks_async
- name: Wait for {{ outer_loop.host_group }} root disk(s) to be created
async_status:
jid: "{{ local_loop.ansible_job_id }}"
loop_control:
loop_var: local_loop
with_items: "{{ current_disks_async.results }}"
register: current_disks
until: current_disks.finished
retries: 120
- name: Create {{ outer_loop.host_group }} node(s)
gce:
zone: "{{ cloud_config.zone }}"
name: "{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}{{ cloud_config.name_suffix|default('') }}"
image: "{{ outer_loop.image }}"
machine_type: "{{ outer_loop.type }}"
network: "{{ cloud_config.vpc_name }}"
subnetwork: "{{ cloud_config.subnet_name }}"
external_ip: "{{ (outer_loop.public_ip|default(false)|bool == true) | ternary('ephemeral','none') }}"
disks:
- "{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
tags:
- "cluster-{{ cluster_name }}"
- "role-{{ outer_loop.host_group }}"
- "group-{{ cluster_name }}-{{ outer_loop.host_group }}"
state: present
loop_control:
loop_var: local_loop
with_sequence: count="{{ outer_loop.count }}" format=-%02x
async: 1000
poll: 0
register: current_nodes_async
- name: Wait for {{ outer_loop.host_group }} node(s) to be built
async_status:
jid: "{{ local_loop.ansible_job_id }}"
loop_control:
loop_var: local_loop
with_items: "{{ current_nodes_async.results }}"
register: current_nodes
until: current_nodes.finished
retries: 120
- name: Wait for SSH to start
wait_for:
host: "{{ (outer_loop.public_ip|default(false) == true) | ternary(local_loop.instance_data.0.public_ip,local_loop.instance_data.0.private_ip) }}"
port: 22
state: started
delay: 5
timeout: 300
loop_control:
loop_var: local_loop
with_items: '{{ current_nodes.results }}'