-
Notifications
You must be signed in to change notification settings - Fork 16
/
scaleout.yml
363 lines (307 loc) · 13.6 KB
/
scaleout.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
---
- hosts: localhost
tasks:
#Make sure public key of ansible controller node is copied on to undercloud host
- name: add undercloud
add_host:
name: "undercloud"
ansible_host: "{{ undercloud_hostname }}"
ansible_user: "stack"
ansible_connection: "ssh"
ansible_ssh_pass: "{{ undercloud_password }}"
- hosts: undercloud
vars:
new_instack: /home/stack/newnodes.json
tasks:
- name: get the new nodes file
copy:
src: "{{ new_nodes_instack }}"
dest: "{{ new_instack }}"
force: yes
- name: get tn10rt machines list
shell: curl http://wiki.scalelab.redhat.com/1029u/ > ~/tn10rt.html
- name: load tn10rt machines list
slurp:
src: /home/stack/tn10rt.html
register: tn10rt
- block:
- name: load instack data
slurp:
src: /home/stack/newnodes.json
register: stack_data
- name: load new instackenv
set_fact:
stack_data: "{{ stack_data['content'] | b64decode | from_json }}"
- name: get machine types
set_fact:
machine_types: "{{ machine_types|default([]) + [ (type != '1029u') | ternary(type, (item.pm_addr.replace('mgmt-', '') in tn10rt['content'] | b64decode) | ternary('1029utn10rt', '1029utrtp')) ] }}"
vars:
type: "{{ (lab_name == 'scale') | ternary(item.pm_addr.split('.')[0].split('-')[4], item.pm_addr.split('.')[0].split('-')[3]) }}"
loop: "{{ stack_data.nodes|flatten(levels=1) }}"
- name: set vendors of overcloud nodes
set_fact:
vendors: "{{ vendors|default([])+ [(item in lab_vars['machine_types']['supermicro']) | ternary('supermicro', 'dell')] }}"
with_items:
- "{{ machine_types }}"
- name: list stack_data
shell: |
echo "{{ (stack_data.nodes[item | int].pm_addr | replace('mgmt-','') | replace('-drac', '')) }}"
with_sequence: 0-{{ (stack_data.nodes|length - 1) }}
register: host_list
vars:
lab_vars: "{{ (lab_name == 'scale') | ternary(scale, alias) }}"
when: lab_name in ['scale', 'alias']
- block:
- name: clear existing dell-hosts file
shell: echo "" > {{ playbook_dir }}/badfish/dell-hosts
- name: prepare dell hosts for badfish
shell: echo "mgmt-{{ item[1].stdout }}" >> {{ playbook_dir }}/badfish/dell-hosts
when: vendors is defined and item[0] == "dell"
with_together:
- "{{ vendors }}"
- "{{ host_list.results }}"
- name: set boot order to director
include_tasks: tasks/set_boot_order_director.yml
vars:
chassis_password: "{{ stack_data.nodes[0].pm_password }}"
when: lab_name in ['scale', 'alias'] and set_boot_order == true
delegate_to: localhost
- name: set machine count
set_fact:
total_machine_count: {}
- name: set machine count for each machine type
set_fact:
total_machine_count: "{{ total_machine_count | combine({item: (item in total_machine_count)|ternary(total_machine_count[item], 0)|int + 1 }, recursive=True) }}"
with_items:
"{{ machine_types }}"
- name: register new nodes
shell: |
source /home/stack/stackrc
openstack overcloud node import {{ new_instack }}
- name: wait for nodes to move From enroll, Verifying and to manageable state
wait_for:
timeout: 15
delegate_to: localhost
- name: get the new nodes detail
shell: |
source /home/stack/stackrc
openstack baremetal node list -f yaml
register: new_nodes_detail
- name: set new nodes fact
set_fact:
new_nodes_list: "{{ new_nodes_detail.stdout | from_yaml }}"
- name: filter manageable/available nodes
set_fact:
new_nodes: "{{ (new_nodes | default([])) + [ item['UUID'] ] }}"
with_items: "{{ new_nodes_list | default([]) }}"
when:
item.get('Provisioning State') == 'manageable' or item.get('Provisioning State') == 'available'
- name: introspect new nodes
shell: |
source /home/stack/stackrc
openstack overcloud node introspect --all-manageable
ignore_errors: true
- name: delete instrospect failed nodes
include_tasks: tasks/delete_introspection_failed_nodes.yml
# when automated cleaning is enabled, this check is needed
- name: wait for nodes to reach available state
shell: |
source /home/stack/stackrc
openstack baremetal node show {{ item }} -f value -c provision_state
register: node_state
until: node_state.stdout == "available"
retries: 15
delay: 120
loop: "{{ manageable_nodes.stdout_lines | default([]) }}"
# keep track of count for each machine type after
# deleting introspect failed nodes.
- block:
- name: reduce machine count for introspect failed machine type
set_fact:
total_machine_count: "{{ total_machine_count | combine(update_item, recursive=true) }}"
vars:
update_item: "{ '{{ item.key }}': {{ total_machine_count[item.key]|int - failed_nodes_machine_count[item.key]|int }} }"
with_dict: "{{ failed_nodes_machine_count }}"
- name: remove introspect failed machine types that have count of zero
set_fact:
total_machine_count: "{{ total_machine_count | combine({ item: (total_machine_count[item]|int > 0) | ternary(total_machine_count[item], omit) }) }}"
with_items: "{{ total_machine_count.keys() }}"
- name: delete introspect failed node UUID's
set_fact:
new_nodes: "{{ new_nodes | difference(failed_nodes_uuids) }}"
when: failed_nodes_machine_type is defined
- name: set command for getting overcloud host list
set_fact:
overcloud_host_list: "metalsmith -c Hostname -f value list"
when: osp_release|int >= 17
- name: set command for getting overcloud host list
set_fact:
overcloud_host_list: "openstack server list -c Name -f value"
when: osp_release|int < 17
# figure out existing machine types and newly added machine types
- block:
- name: get existing machine types
shell: |
source /home/stack/stackrc
{{ overcloud_host_list }} | grep compute | cut -d'-' -f 1 | sed 's/compute/''/gI' | sort | uniq
register: existing_machine_types
- name: get new machine types that are newly being added
set_fact:
new_machine_types: "{{ total_machine_count.keys()|list | difference(existing_machine_types.stdout_lines|list) }}"
when: composable_roles == true
- name: Configure the image properties
shell: |
source /home/stack/stackrc
openstack overcloud node configure {{ item }}
with_items: "{{ new_nodes | default([]) }}"
ignore_errors: true
changed_when: false
# set root hints
- block:
# workaround for using existing root hint tasks
- block:
- name: remove existing total nodes file
shell: |
rm -f /home/stack/total_nodes.txt
- name: get all nodes
shell: |
echo {{ item }} >> /home/stack/total_nodes.txt
with_items: "{{ new_nodes | default([]) }}"
- name: register the output of total new nodes
shell: |
cat /home/stack/total_nodes.txt
register: total_nodes
- name: set root hints
include_tasks: tasks/set_root_hints.yml
when: lab_name in ['scale', 'alias']
- name: create flavors
shell: |
source ~/stackrc
openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal{{ item }}
openstack flavor set --property "capabilities:boot_option"="local" --property "capabilities:profile"="baremetal{{ item }}" baremetal{{ item }}
openstack flavor set baremetal{{ item }} --property "resources:VCPU"="0"
openstack flavor set baremetal{{ item }} --property "resources:MEMORY_MB"="0"
openstack flavor set baremetal{{ item }} --property "resources:DISK_GB"="0"
openstack flavor set baremetal{{ item }} --property "resources:CUSTOM_BAREMETAL"="1"
with_items: "{{ new_machine_types | default([]) }} "
when: osp_release|int < 17 and composable_roles == true
- name: setting node capabilities (boot_mode bios)
vars:
boot_mode: bios
include_tasks: tasks/set_boot_mode.yml
when: osp_release|int >= 17 or composable_roles
- name: set fact for defining list of hosts for which the deployment should be limited
set_fact:
deploy_limit_str: ""
- block:
- name: copy roles definition for new machine types
command: |
cp -r ~/roles/Compute.yaml ~/roles/Compute{{ item }}.yaml
with_items: "{{ new_machine_types | default([]) }}"
- name: Edit role name
lineinfile:
path: "/home/stack/roles/Compute{{ item }}.yaml"
regexp: '- name:'
line: "- name: Compute{{ item }}"
with_items: "{{ new_machine_types | default([]) }}"
- name: Edit hostname format
lineinfile:
path: "/home/stack/roles/Compute{{ item }}.yaml"
regexp: ' HostnameFormatDefault:'
line: " HostnameFormatDefault: 'compute{{ item }}-%index%'"
with_items: "{{ new_machine_types | default([]) }}"
- name: write entries for new roles
include_tasks: tasks/new_roles_for_scaleout.yml
vars:
check_type: "{{ item }}"
loop: "{{ new_machine_types | default([]) }}"
- name: prepare nic configs
include_tasks: tasks/composable_prepare_nic_configs_for_scaleout.yml
- name: write entries for new roles in baremetal_deployment.yaml
include_tasks: tasks/baremetal_deployment_prepare_for_scaleout.yaml
vars:
node_type: "{{ item }}"
loop: "{{ total_machine_count.keys()|list }}"
when: osp_release|int >= 17
- name: update nodes_data.yaml
include_tasks: tasks/update_nodes_data_for_scaleout.yaml
vars:
node_type: "{{ item }}"
loop: "{{ total_machine_count.keys()|list }}"
- name: update network-environment.yaml
include_tasks: tasks/update_network_environment_for_scaleout.yaml
vars:
node_type: "{{ item }}"
loop: "{{ new_machine_types | default([]) }}"
when: osp_release|int < 17
- name: prepare deploy_limit_str
include_tasks: tasks/prepare_deploy_limit_str_for_scaleout.yaml
vars:
node_type: "{{ item }}"
loop: "{{ total_machine_count.keys()|list }}"
when: composable_roles == true
- block:
- name: get existing compute count
shell: |
source /home/stack/stackrc
{{ overcloud_host_list }} | grep compute | wc -l
register: compute_count
- name: prepare deploy_limit_str
set_fact:
deploy_limit_str: "{{ deploy_limit_str + append_item }}"
vars:
append_item: "{{ (deploy_limit_str|length == 0) | ternary(item, (',' + item)) }}"
with_sequence: "start={{ compute_count.stdout|int }} end={{ compute_count.stdout|int + new_nodes|length - 1 }} format=compute-%1u"
- name: set fact for compute count
set_fact:
compute_count: "{{ compute_count.stdout|int + new_nodes|length }}"
- name: update count in baremetal_deployment.yaml with added computes
replace:
path: /home/stack/virt/network/baremetal_deployment.yaml
after: "- name: Compute"
before: " hostname_format: compute-%index%"
regexp: '.*count.*'
replace: " count: {{ compute_count }}"
when: osp_release|int >= 17
- name: update nodes_data.yaml
lineinfile:
regexp: ".*ComputeCount.*"
line: " ComputeCount: {{ compute_count }}"
path: /home/stack/virt/nodes_data.yaml
when: osp_release|int >= 17
- name: update compute count in nodes_data.yaml
lineinfile:
regexp: ".*ComputeCount.*"
line: " ComputeCount: {{ compute_count }}"
path: /home/stack/virt/nodes_data.yaml
when: osp_release|int < 17
when: composable_roles == false
- name: provision nodes
shell: |
source /home/stack/stackrc
set -o pipefail
openstack overcloud node provision \
--network-config --stack overcloud \
-o /home/stack/templates/overcloud-baremetal-deployed.yaml /home/stack/virt/network/baremetal_deployment.yaml -y | \
tee -a /home/stack/overcloud_provision_nodes.log
when: osp_release|int >= 17
- block:
- name: format deploy_limit_str
set_fact:
deploy_limit_str: " --limit \"Undercloud,Controller,{{ deploy_limit_str }}\" \\"
- name: copy overcloud_deploy.sh
shell: |
cp /home/stack/overcloud_deploy.sh /home/stack/overcloud_deploy_with_limit.sh
- name: update overcloud deploy script
lineinfile:
regexp: ".*--limit.*"
line: "{{ deploy_limit_str }}"
insertafter: ".*openstack overcloud deploy.*"
path: /home/stack/overcloud_deploy_with_limit.sh
- name: overcloud deploy
shell: |
source /home/stack/stackrc
set -o pipefail
./overcloud_deploy_with_limit.sh &> /home/stack/overcloud_install.log
args:
chdir: /home/stack/