forked from hortonworks/ansible-hortonworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_azure_nodes.yml
123 lines (115 loc) · 4.85 KB
/
build_azure_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
- set_fact: outer_loop="{{ item }}"
- block:
- name: Create Public IPs
azure_rm_publicipaddress:
resource_group: "{{ cloud_config.resource_group }}"
allocation_method: Static
name: "IP-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
loop_control:
loop_var: local_loop
with_sequence: count="{{ outer_loop.count }}" format=-%02x
async: 1000
poll: 0
register: current_ips_async
- name: Wait for Public IPs to be built
async_status:
jid: "{{ local_loop.ansible_job_id }}"
loop_control:
loop_var: local_loop
with_items: "{{ current_ips_async.results }}"
register: current_public_ips
until: current_public_ips.finished
retries: 120
- name: Create NIC(s) (with public IP)
azure_rm_networkinterface:
resource_group: "{{ cloud_config.resource_group }}"
name: "NIC-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
virtual_network_name: "{{ cloud_config.network.name }}"
subnet_name: "{{ cloud_config.subnet.name }}"
security_group_name: "{{ outer_loop.security_group }}"
ip_configurations:
- name: "ipconfig-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
public_ip_address_name: "IP-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
public_ip_allocation_method: Static
primary: True
loop_control:
loop_var: local_loop
with_sequence: count="{{ outer_loop.count }}" format=-%02x
async: 1000
poll: 0
register: current_public_nics_async
- name: Wait for NIC(s) to be built
async_status:
jid: "{{ local_loop.ansible_job_id }}"
loop_control:
loop_var: local_loop
with_items: "{{ current_public_nics_async.results }}"
register: current_public_nics
until: current_public_nics.finished
retries: 120
when: outer_loop.public_ip|default(false)|bool
- block:
- name: Create NIC(s) (with private IP only)
azure_rm_networkinterface:
resource_group: "{{ cloud_config.resource_group }}"
name: "NIC-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
virtual_network_name: "{{ cloud_config.network.name }}"
subnet_name: "{{ cloud_config.subnet.name }}"
security_group_name: "{{ outer_loop.security_group }}"
ip_configurations:
- name: "ipconfig-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
primary: True
loop_control:
loop_var: local_loop
with_sequence: count="{{ outer_loop.count }}" format=-%02x
async: 1000
poll: 0
register: current_private_nics_async
- name: Wait for NIC(s) to be built
async_status:
jid: "{{ local_loop.ansible_job_id }}"
loop_control:
loop_var: local_loop
with_items: "{{ current_private_nics_async.results }}"
register: current_private_nics
until: current_private_nics.finished
retries: 120
when: not outer_loop.public_ip|default(false)|bool
- name: Create {{ outer_loop.host_group }} node(s)
azure_rm_virtualmachine:
resource_group: "{{ cloud_config.resource_group }}"
storage_account_name: "{{ cloud_config.storage_account.name }}"
name: "{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}{{ cloud_config.name_suffix|default('') }}"
image:
offer: "{{ outer_loop.image.offer }}"
publisher: "{{ outer_loop.image.publisher }}"
sku: "{{ outer_loop.image.sku }}"
version: "{{ outer_loop.image.version }}"
vm_size: "{{ outer_loop.flavor }}"
network_interface_names: "NIC-{{ cluster_name }}-{{ outer_loop.host_group }}{{ (outer_loop.count > 1) | ternary(local_loop,'') }}"
ssh_password_enabled: false
admin_username: "{{ cloud_config.admin_username }}"
ssh_public_keys:
- path: "/home/{{ cloud_config.admin_username }}/.ssh/authorized_keys"
key_data: "{{ lookup('file', cloud_config.ssh.publickey) }}"
state: present
tags:
Cluster: "{{ cluster_name }}"
Role: "{{ outer_loop.host_group }}"
Group: "{{ cluster_name }}-{{ outer_loop.host_group }}"
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