Skip to content

Commit 0e84d5e

Browse files
committed
Adding Scale Out functionality
- Add nodes to worker inventory section and update vars in scaleout.yml to add nodes to the existing cluster. - https://docs.openshift.com/container-platform/4.17/nodes/nodes/nodes-nodes-adding-node-iso.html
1 parent 72bc337 commit 0e84d5e

File tree

16 files changed

+260
-10
lines changed

16 files changed

+260
-10
lines changed

ansible/mno-scale-out.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: Adds nodes to a cluster
3+
hosts: bastion
4+
vars_files:
5+
- vars/all.yml
6+
- vars/scale_out.yml
7+
roles:
8+
- mno-scale-out
9+
- role: boot-iso
10+
vars:
11+
inventory_group: 'worker'
12+
offset: "{{ current_worker_count }}"
13+
index: "{{ current_worker_count+scale_out_count }}"
14+
virtual_media_iso: "mno-scale-out.x86_64.iso"
15+
- mno-scale-out-csr

ansible/roles/boot-iso/defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
# This will be your bastion machine (if you run setup-bastion playbook)
55
http_store_host: "{{ groups['bastion'][0] }}"
66
http_store_port: 8081
7+
8+
# This is always 0 for a deploy
9+
# For a scale out it indicates how many worker nodes are already deployed
10+
# and should not be included in the scale out from the inventory.
11+
offset: 0

ansible/roles/boot-iso/tasks/dell.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
# Dell tasks for booting an iso
33

4+
- name: Set Virtual Media ISO
5+
set_fact:
6+
_virtual_media_iso: "{{ virtual_media_iso | default(hostvars[item]['boot_iso']) }}"
7+
48
- name: Dell - Power down machine prior to booting iso
59
shell: |
610
ipmitool -I lanplus -H {{ hostvars[item]['bmc_address'] }} -U {{ hostvars[item]['bmc_user'] }} -P {{ hostvars[item]['bmc_password'] }} chassis power off
@@ -80,7 +84,7 @@
8084
username: "{{ hostvars[item]['bmc_user'] }}"
8185
password: "{{ hostvars[item]['bmc_password'] }}"
8286
virtual_media:
83-
image_url: "http://{{ http_store_host }}:{{ http_store_port }}/{{ hostvars[item]['boot_iso'] }}"
87+
image_url: "http://{{ http_store_host }}:{{ http_store_port }}/{{ _virtual_media_iso }}"
8488
media_types:
8589
- CD
8690
- DVD

ansible/roles/boot-iso/tasks/hp.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
# HP tasks for booting an iso
33

4+
- name: Set Virtual Media ISO
5+
set_fact:
6+
_virtual_media_iso: "{{ virtual_media_iso | default(hostvars[item]['boot_iso']) }}"
7+
48
- name: HP - Power off
59
hpilo_boot:
610
host: "{{ hostvars[item]['bmc_address'] }}"
@@ -20,5 +24,5 @@
2024
host: "{{ hostvars[item]['bmc_address'] }}"
2125
login: "{{ hostvars[item]['bmc_user'] }}"
2226
password: "{{ hostvars[item]['bmc_password'] }}"
23-
image: "http://{{ http_store_host }}:{{ http_store_port }}/{{ hostvars[item]['boot_iso'] }}"
27+
image: "http://{{ http_store_host }}:{{ http_store_port }}/{{ _virtual_media_iso }}"
2428
media: cdrom

ansible/roles/boot-iso/tasks/lenovo.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
# Lenovo tasks for booting an iso
33

4+
- name: Set Virtual Media ISO
5+
set_fact:
6+
_virtual_media_iso: "{{ virtual_media_iso | default(hostvars[item]['boot_iso']) }}"
7+
48
- name: Lenovo - Power off
59
community.general.redfish_command:
610
category: Systems
@@ -26,7 +30,7 @@
2630
username: "{{ hostvars[item]['bmc_user'] }}"
2731
password: "{{ hostvars[item]['bmc_password'] }}"
2832
virtual_media:
29-
image_url: "http://{{ http_store_host }}:{{ http_store_port }}/iso/{{ hostvars[item]['boot_iso'] }}"
33+
image_url: "http://{{ http_store_host }}:{{ http_store_port }}/iso/{{ _virtual_media_iso }}"
3034
media_types:
3135
- CD
3236
- DVD

ansible/roles/boot-iso/tasks/libvirt.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Couldn't use ansible redfish_command it requires username and password to be used.
44
# URLs modeled from http://docs.openstack.org/sushy-tools/latest/user/dynamic-emulator.html
55

6+
- name: Set Virtual Media ISO
7+
set_fact:
8+
_virtual_media_iso: "{{ virtual_media_iso | default(hostvars[item]['boot_iso']) }}"
9+
610
- name: Libvirt - Power down machine prior to booting iso
711
uri:
812
url: "http://{{ hostvars[item]['ansible_host'] }}:9000/redfish/v1/Systems/{{ hostvars[item]['domain_uuid'] }}/Actions/ComputerSystem.Reset"
@@ -65,7 +69,7 @@
6569
headers:
6670
content-type: application/json
6771
Accept: application/json
68-
body: {"Image":"http://{{ http_store_host }}:{{ http_store_port }}/{{ hostvars[item]['boot_iso'] }}", "Inserted": true}
72+
body: {"Image":"http://{{ http_store_host }}:{{ http_store_port }}/{{ _virtual_media_iso }}", "Inserted": true}
6973
body_format: json
7074
validate_certs: no
7175
status_code: 204

ansible/roles/boot-iso/tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
- name: Boot iso on dell hardware
55
include_tasks: dell.yml
66
with_items:
7-
- "{{ groups[inventory_group][:index|int] }}"
7+
- "{{ groups[inventory_group][offset|int:index|int] }}"
88
when: hostvars[item]['vendor'] == 'Dell'
99

1010
- name: Boot iso on hp hardware
1111
include_tasks: hp.yml
1212
with_items:
13-
- "{{ groups[inventory_group][:index|int] }}"
13+
- "{{ groups[inventory_group][offset|int:index|int] }}"
1414
when: hostvars[item]['vendor'] == 'Hp'
1515

1616
- name: Boot iso on supermicro hardware
1717
include_tasks: supermicro.yml
1818
with_items:
19-
- "{{ groups[inventory_group][:index|int] }}"
19+
- "{{ groups[inventory_group][offset|int:index|int] }}"
2020
when: hostvars[item]['vendor'] == 'Supermicro'
2121

2222
- name: Boot iso on lenovo hardware
2323
include_tasks: lenovo.yml
2424
with_items:
25-
- "{{ groups[inventory_group][:index|int] }}"
25+
- "{{ groups[inventory_group][offset|int:index|int] }}"
2626
when: hostvars[item]['vendor'] == 'Lenovo'
2727

2828
- name: Boot iso on libvirt vm
2929
include_tasks: libvirt.yml
3030
with_items:
31-
- "{{ groups[inventory_group][:index|int] }}"
31+
- "{{ groups[inventory_group][offset|int:index|int] }}"
3232
when: hostvars[item]['vendor'] == 'Libvirt'

ansible/roles/boot-iso/tasks/supermicro.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
# Supermicro tasks for booting an iso
33

4+
- name: Set Virtual Media ISO
5+
set_fact:
6+
_virtual_media_iso: "{{ virtual_media_iso | default(hostvars[item]['boot_iso']) }}"
7+
48
- name: SuperMicro - Power off
59
community.general.redfish_command:
610
category: Systems
@@ -16,7 +20,7 @@
1620
# Retry because sometimes mounting will fail if it occurs too quickly after unmounting
1721
- name: SuperMicro - Mount ISO
1822
shell: |
19-
SMCIPMITool {{ hostvars[item]['bmc_address'] }} {{ hostvars[item]['bmc_user'] }} {{ hostvars[item]['bmc_password'] }} wsiso mount "http://{{ http_store_host }}:{{ http_store_port }}" /iso/{{ hostvars[item]['boot_iso'] }}
23+
SMCIPMITool {{ hostvars[item]['bmc_address'] }} {{ hostvars[item]['bmc_user'] }} {{ hostvars[item]['bmc_password'] }} wsiso mount "http://{{ http_store_host }}:{{ http_store_port }}" /iso/{{ _virtual_media_iso }}
2024
register: mount_iso
2125
until: not mount_iso.failed
2226
retries: 10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
scale_out_count: 0
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
- name: Set Facts to recurse with
3+
set_fact:
4+
r_qry: "{{ qry }}"
5+
r_worker_counter: "{{ worker_counter }}"
6+
7+
- name: approve CSRs and check if nodes have joined the cluster
8+
block:
9+
- name: Increment the retry count
10+
set_fact:
11+
retry: "{{ 0 if retry is undefined else retry | int + 1 }}"
12+
13+
- name: Pause during loop
14+
pause:
15+
seconds: "30"
16+
when: retry|int > 0
17+
18+
- name: Get CSRs
19+
shell: |
20+
KUBECONFIG={{ bastion_cluster_config_dir }}/kubeconfig oc get csr -o json
21+
register: oc_get_csr
22+
23+
- name: Approve pending CSRs
24+
shell: |
25+
KUBECONFIG={{ bastion_cluster_config_dir }}/kubeconfig oc adm certificate approve {{ item.metadata.name }}
26+
loop: "{{ oc_get_csr.stdout | from_json | json_query(qry) }}"
27+
loop_control:
28+
label: "{{ item.metadata.name }}"
29+
30+
- name: Get worker node count
31+
shell: |
32+
KUBECONFIG={{ bastion_cluster_config_dir }}/kubeconfig oc get nodes | {{ worker_counter }}
33+
register: oc_get_nodes_workers
34+
35+
- name: Current Worker Node Count
36+
debug:
37+
var: oc_get_nodes_workers.stdout
38+
39+
- name: Waiting for Worker Node Count
40+
debug:
41+
msg: "{{ current_worker_count+scale_out_count }}"
42+
43+
- name: Raise fail to trigger retry if all nodes didn't meet requirments
44+
fail:
45+
msg: All nodes have not met check requirements
46+
when: oc_get_nodes_workers.stdout|int < current_worker_count+scale_out_count
47+
rescue:
48+
- name: Fail on maximum retry count
49+
fail:
50+
msg: Maximum retries reached
51+
when: retry | int == 540
52+
53+
- name: Retry the check
54+
include_tasks: check_nodes_joined.yml
55+
vars:
56+
qry: "{{ r_qry }}"
57+
worker_counter: "{{ r_worker_counter }}"

0 commit comments

Comments
 (0)