diff --git a/manifests/function/baremetal-operator/ironic-vars.yaml b/manifests/function/baremetal-operator/ironic-vars.yaml index f8d064548..606fe1174 100644 --- a/manifests/function/baremetal-operator/ironic-vars.yaml +++ b/manifests/function/baremetal-operator/ironic-vars.yaml @@ -7,7 +7,7 @@ metadata: data: PROVISIONING_IP: "192.168.10.100" DHCP_RANGE: "192.168.10.200,192.168.10.250" - PROVISIONING_INTERFACE: "pxe0" + PROVISIONING_INTERFACE: "pxe" HTTP: "80" DEPLOY_KERNEL_PATH: "/images/tinyipa-stable-ussuri.vmlinuz" DEPLOY_RAMDISK_PATH: "/images/tinyipa-stable-ussuri.gz" diff --git a/manifests/site/test-site/ephemeral/initinfra/patch_bmo_config.yaml b/manifests/site/test-site/ephemeral/initinfra/patch_bmo_config.yaml index fe1e595ad..807852aa8 100644 --- a/manifests/site/test-site/ephemeral/initinfra/patch_bmo_config.yaml +++ b/manifests/site/test-site/ephemeral/initinfra/patch_bmo_config.yaml @@ -7,4 +7,3 @@ metadata: data: PROVISIONING_IP: "10.23.24.101" DHCP_RANGE: "10.23.24.200,10.23.24.250" - PROVISIONING_INTERFACE: "enp0s4" diff --git a/manifests/site/test-site/shared/catalogues/hosts.yaml b/manifests/site/test-site/shared/catalogues/hosts.yaml index 38ff591b5..618f936fb 100644 --- a/manifests/site/test-site/shared/catalogues/hosts.yaml +++ b/manifests/site/test-site/shared/catalogues/hosts.yaml @@ -19,10 +19,13 @@ hosts: pxe: 52:54:00:b6:ed:31 bootMode: legacy node02: - macAddress: 00:3b:8b:0c:ec:8b + macAddress: 52:54:00:b6:ed:02 bmcAddress: redfish+http://10.23.25.2:8000/redfish/v1/Systems/air-target-2 bmcUsername: username bmcPassword: password ipAddresses: oam-ipv4: 10.23.25.101 pxe-ipv4: 10.23.24.101 + macAddresses: + oam: 52:54:00:9b:27:02 + pxe: 52:54:00:b6:ed:02 diff --git a/manifests/type/gating/shared/catalogues/common-networking.yaml b/manifests/type/gating/shared/catalogues/common-networking.yaml index 89c751c42..38f855bee 100644 --- a/manifests/type/gating/shared/catalogues/common-networking.yaml +++ b/manifests/type/gating/shared/catalogues/common-networking.yaml @@ -7,12 +7,12 @@ metadata: commonNetworking: links: - id: oam - name: enp0s3 + name: oam type: phy mtu: "1500" # ethernet_mac_address: (optional) - id: pxe - name: enp0s4 + name: pxe type: phy mtu: "1500" # ethernet_mac_address: (optional) diff --git a/playbooks/airship-airshipctl-build-gate.yaml b/playbooks/airship-airshipctl-build-gate.yaml index 05acf2d4d..753e34fe5 100644 --- a/playbooks/airship-airshipctl-build-gate.yaml +++ b/playbooks/airship-airshipctl-build-gate.yaml @@ -60,58 +60,17 @@ - name: clone document model command: git clone -q {{ airship_config_primary_repo_url }} {{ remote_work_dir }} when: remote_work_dir is defined - - name: get BareMetalHost objects - shell: | - set -e - kustomize build --enable_alpha_plugins \ - {{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/ephemeral/controlplane | - kustomize config grep "kind=BareMetalHost" - register: bmh_command - failed_when: "bmh_command.stdout == ''" - environment: - KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins" - KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true" - - set_fact: - bmh: "{{ bmh_command.stdout | from_yaml_all | list }}" - - name: get network configuration for BareMetalHost objects - shell: | - set -e - kustomize build --enable_alpha_plugins \ - {{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/ephemeral/controlplane | - kustomize config grep "metadata.name={{ item.spec.networkData.name }}" - register: netdata_command - failed_when: "netdata_command.stdout == ''" - environment: - KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins" - KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true" - with_items: "{{ bmh }}" - - name: get links from network data per BareMetalHost object - set_fact: - links: | - {{ - netdata_command.results | - map(attribute='stdout')| map('from_yaml') | - map(attribute='stringData.networkData') | map('from_yaml') | - map(attribute='links') | list - }} - - name: define list of VM mac addresses - set_fact: - vm_nic: "{{ dict(['nat_mac', 'provision_mac'] | zip([nat_mac_list[0], item.spec.bootMACAddress])) }}" - vars: - nat_mac_list: | - {{ - links[idx] | - rejectattr('ethernet_mac_address', 'undefined') | - selectattr('ethernet_mac_address', '!=', item.spec.bootMACAddress) | - map(attribute='ethernet_mac_address') | list - }} - failed_when: nat_mac_list | length == 0 - loop: "{{ bmh }}" - loop_control: - index_var: idx - register: vm_nic_fact - - set_fact: - target_vm_nics: "{{ vm_nic_fact.results | map(attribute='ansible_facts.vm_nic') | list }}" + - name: get MACs from BareMetalHost objects + include_tasks: + file: get-mac-addresses.yaml + vars: + name: "{{ roleinputvar.name }}" + path: "{{ roleinputvar.path }}" + loop: + - { name: 'target', path: 'ephemeral/controlplane' } + - { name: 'ephemeral', path: 'ephemeral/bootstrap' } + loop_control: + loop_var: roleinputvar - name: deploy-gate include_role: @@ -131,6 +90,7 @@ ephemeral_vm_memory_mb: 6124 ephemeral_vm_vcpus: 4 ephemeral_disk_size: 20G + ephemeral_vm_nics: "{{ ephemeral_vm_nics }}" target_disk_size: 10G disk_format: qcow2 target_vms_count: 1 diff --git a/playbooks/get-mac-addresses.yaml b/playbooks/get-mac-addresses.yaml new file mode 100644 index 000000000..f1e8a263c --- /dev/null +++ b/playbooks/get-mac-addresses.yaml @@ -0,0 +1,64 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: get BareMetalHost objects + shell: | + set -e + kustomize build --enable_alpha_plugins \ + {{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/{{ path }} | + kustomize config grep "kind=BareMetalHost" + register: bmh_command + failed_when: "bmh_command.stdout == ''" + environment: + KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins" + KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true" +- set_fact: + bmh: "{{ bmh_command.stdout | from_yaml_all | list }}" +- name: get network configuration for BareMetalHost objects + shell: | + set -e + kustomize build --enable_alpha_plugins \ + {{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/{{ path }} | + kustomize config grep "metadata.name={{ item.spec.networkData.name }}" + register: netdata_command + failed_when: "netdata_command.stdout == ''" + environment: + KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins" + KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true" + with_items: "{{ bmh }}" +- name: get links from network data per BareMetalHost object + set_fact: + links: | + {{ + netdata_command.results | + map(attribute='stdout')| map('from_yaml') | + map(attribute='stringData.networkData') | map('from_yaml') | + map(attribute='links') | list + }} +- name: define list of VM mac addresses + set_fact: + vm_nic: "{{ dict(['nat_mac', 'provision_mac'] | zip([nat_mac_list[0], item.spec.bootMACAddress])) }}" + vars: + nat_mac_list: | + {{ + links[idx] | + rejectattr('ethernet_mac_address', 'undefined') | + selectattr('ethernet_mac_address', '!=', item.spec.bootMACAddress) | + map(attribute='ethernet_mac_address') | list + }} + failed_when: nat_mac_list | length == 0 + loop: "{{ bmh }}" + loop_control: + index_var: idx + register: vm_nic_fact +- set_fact: + "{{ name }}_vm_nics": "{{ vm_nic_fact.results | map(attribute='ansible_facts.vm_nic') | list }}" diff --git a/roles/airship-libvirt-gate/tasks/build-infra.yaml b/roles/airship-libvirt-gate/tasks/build-infra.yaml index 9efc9952d..915458e19 100644 --- a/roles/airship-libvirt-gate/tasks/build-infra.yaml +++ b/roles/airship-libvirt-gate/tasks/build-infra.yaml @@ -112,7 +112,9 @@ pool: "{{ airship_gate_names.pool }}" interfaces: - network: "{{ airship_gate_names.nat_network }}" + mac: "{{ chosen_flavor.ephemeral_vm_nics[0].nat_mac | default('')}}" - network: "{{ airship_gate_names.provision_network }}" + mac: "{{ chosen_flavor.ephemeral_vm_nics[0].provision_mac | default('')}}" - name: Add noauth sushy-emulator to apache include_role: