--- # Update the Bifrost inventory with the IP allocation and other variables. - name: Ensure the Bifrost overcloud inventory is populated hosts: overcloud gather_facts: no max_fail_percentage: >- {{ kolla_bifrost_hostvars_max_fail_percentage | default(kayobe_max_fail_percentage) | default(100) }} tags: - kolla-bifrost-hostvars become: true vars: seed_host: "{{ groups['seed'][0] }}" # NOTE: Without this, the seed's ansible_host variable will not be # respected when using delegate_to. ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}" bifrost_hostvars: addressing_mode: static deploy_image_filename: "{{ kolla_bifrost_deploy_image_filename }}" deploy_image_rootfs: "{{ kolla_bifrost_deploy_image_rootfs | default(omit, true) }}" ipv4_interface_mac: "{% if kolla_bifrost_ipv4_interface_mac is defined %}{{ kolla_bifrost_ipv4_interface_mac }}{% else %}{% raw %}{{ extra.pxe_interface_mac | default }}{% endraw %}{% endif %}" ipv4_address: "{{ admin_oc_net_name | net_ip }}" ipv4_subnet_mask: "{{ admin_oc_net_name | net_mask }}" # If the admin network does not have a gateway defined and seed SNAT is # enabled, use the seed as a gateway to allow external access until other # networks have been configured. Otherwise, do not set any gateway. ipv4_gateway: "{{ (admin_oc_net_name | net_gateway) or (admin_oc_net_name | net_ip(seed_host) if seed_enable_snat | bool) }}" ipv4_nameserver: "{{ resolv_nameservers }}" network_mtu: "{{ admin_oc_net_name | net_mtu or '1500' }}" vlan_id: "{{ '' if admin_oc_net_name == provision_oc_net_name else (admin_oc_net_name | net_vlan) }}" user_data_content: "{{ kolla_bifrost_deploy_image_user_data_content }}" tasks: - block: - name: Ensure the Bifrost host variables directory exists file: path: "/etc/kolla/bifrost/inventory/host_vars" state: directory run_once: true - name: Ensure the Bifrost inventory exists file: path: "/etc/kolla/bifrost/inventory/bifrost_inventory.py" src: "/bifrost/playbooks/inventory/bifrost_inventory.py" state: link # This file should only exist within the bifrost_deploy container. force: True run_once: true - block: - name: Query overcloud nodes' hardware introspection data command: > docker exec bifrost_deploy bash -c ' env BIFROST_INVENTORY_SOURCE=ironic BIFROST_NODE_NAMES="{{ inventory_hostname }}" OS_CLOUD=bifrost ansible baremetal --connection local --inventory /etc/bifrost/inventory/ -e @/etc/bifrost/bifrost.yml -e @/etc/bifrost/dib.yml --limit {{ inventory_hostname }} -m shell -a "env OS_CLOUD=bifrost baremetal introspection data save {% raw %}{{ inventory_hostname }}{% endraw %}"' register: save_result changed_when: False # Ignore errors, log a message later. delegate_to: "{{ seed_host }}" vars: # NOTE: Without this, the seed's ansible_host variable will not be # respected when using delegate_to. ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}" - name: Set interface MAC from Ironic introspection data vars: introspection_data: "{{ save_result.stdout_lines[1:] | join('\n') | from_json }}" set_fact: kolla_bifrost_ipv4_interface_mac: "{{ introspection_data.all_interfaces[admin_oc_net_name | net_physical_interface | first].mac }}" when: kolla_bifrost_use_introspection_mac | bool - name: Ensure the Bifrost host variable files exist copy: content: | --- # This file is managed via Ansible. Do not edit. # Bifrost host variables for {{ inventory_hostname }} {{ bifrost_hostvars | to_nice_yaml }} dest: "/etc/kolla/bifrost/inventory/host_vars/{{ inventory_hostname }}" delegate_to: "{{ seed_host }}"