diff --git a/ansible-ipi-install/playbook-jetski-scaleup.yml b/ansible-ipi-install/playbook-jetski-scaleup.yml index d18559ed9d..b27cd798b6 100644 --- a/ansible-ipi-install/playbook-jetski-scaleup.yml +++ b/ansible-ipi-install/playbook-jetski-scaleup.yml @@ -27,6 +27,7 @@ - supermicro_nodes - ocp_deploying_node_content - nondeploying_worker_nodes_content + - worker_network_config_template - quit_play - hosts: provisioner diff --git a/ansible-ipi-install/roles/scale-bootstrap/tasks/main.yml b/ansible-ipi-install/roles/scale-bootstrap/tasks/main.yml index 01e36baafa..f725876b01 100644 --- a/ansible-ipi-install/roles/scale-bootstrap/tasks/main.yml +++ b/ansible-ipi-install/roles/scale-bootstrap/tasks/main.yml @@ -213,3 +213,18 @@ - name: set ocp_nondeplopyed_node_content set_fact: nondeploying_worker_nodes_content: "{{ ocp_nondeployed_node_content | combine({'nodes': ocp_nondeployed_node_content.nodes|difference(scale_worker_node.nodes)}, recursive=True) }}" + +- name: "Check ansible collection path - redhatci.ocp" + community.general.ansible_galaxy_install: + type: collection + name: redhatci.ocp + register: out + +- set_fact: + collection_dir: "{{ item.key }}" + with_dict: "{{ out.installed_collections }}" + when: "item.value != {}" + +- name: Set manifest directory path + set_fact: + worker_network_config_template: "{{ collection_dir }}/redhatci/ocp/roles/installer/files/worker_nmstate_file.yaml" diff --git a/ansible-ipi-install/roles/scale-worker/tasks/20_create_bmh.yml b/ansible-ipi-install/roles/scale-worker/tasks/20_create_bmh.yml index 9c57579dc9..d251770984 100644 --- a/ansible-ipi-install/roles/scale-worker/tasks/20_create_bmh.yml +++ b/ansible-ipi-install/roles/scale-worker/tasks/20_create_bmh.yml @@ -1,3 +1,11 @@ +- name: Create network config secret for workers + kubernetes.core.k8s: + state: present + definition: "{{ lookup('template', bare-metal-network-config-secret, template_vars=dict(host_name=item.host_name,prov_nic=item.prov_nic,bm_nic=item.bm_nic)) | from_yaml }}" + loop: "{{ scale_worker_node.nodes }}" + loop_control: + extended: yes + - name: Create BareMetalHost definition file for new worker template: dest: "{{ scaling_dir }}/{{ item.host_name }}-bmh.yaml" diff --git a/ansible-ipi-install/roles/scale-worker/templates/bare-metal-host.yaml.j2 b/ansible-ipi-install/roles/scale-worker/templates/bare-metal-host.yaml.j2 index 776f92051b..b24b339180 100644 --- a/ansible-ipi-install/roles/scale-worker/templates/bare-metal-host.yaml.j2 +++ b/ansible-ipi-install/roles/scale-worker/templates/bare-metal-host.yaml.j2 @@ -13,7 +13,10 @@ spec: bootMACAddress: "{{ item.prov_mac }}" {% if bootmode is defined and bootmode == 'legacy' %} bootMode: legacy -{% endif %} +{% endif %} +{% if worker_network_config_template is defined %} + PreprovisioningNetworkDataName: "{{ item.host_name }}-network-config-secret" +{% endif %} userData: name: worker-user-data namespace: openshift-machine-api diff --git a/ansible-ipi-install/roles/scale-worker/templates/bare-metal-network-config-secret.yaml.j2 b/ansible-ipi-install/roles/scale-worker/templates/bare-metal-network-config-secret.yaml.j2 new file mode 100644 index 0000000000..5679617364 --- /dev/null +++ b/ansible-ipi-install/roles/scale-worker/templates/bare-metal-network-config-secret.yaml.j2 @@ -0,0 +1,7 @@ +apiVersion: v1 +data: + nmstate: {{ lookup('template', worker_network_config_template, template_vars=dict(provision_nic=prov_nic,baremetal_nic=bm_nic)) | b64encode }} +kind: Secret +metadata: + name: "{{ host_name }}-network-config-secret" + namespace: openshift-machine-api