--- - name: Group controller hosts by their BMC type hosts: controllers gather_facts: no tasks: - name: Group controller hosts by their BMC type group_by: key: "controllers_with_bmcs_of_type_{{ bmc_type | default('unknown') }}" - name: Check whether any changes to controller BIOS and RAID configuration are required hosts: controllers_with_bmcs_of_type_idrac gather_facts: no vars: # Set this to False to avoid rebooting the nodes after configuration. drac_reboot: True roles: - role: stackhpc.drac drac_address: "{{ ipmi_address }}" drac_username: "{{ ipmi_username }}" drac_password: "{{ ipmi_password }}" drac_bios_config: "{{ controller_bios_config }}" drac_raid_config: "{{ controller_raid_config }}" drac_check_mode: True tasks: - name: Set a fact about whether the configuration changed set_fact: bios_or_raid_change: "{{ drac_result | changed }}" - name: Ensure that controller BIOS and RAID volumes are configured hosts: controllers_with_bmcs_of_type_idrac gather_facts: no vars: # Set this to False to avoid rebooting the nodes after configuration. drac_reboot: True pre_tasks: - name: Set the controller nodes' maintenance mode command: > docker exec bifrost_deploy bash -c '. env-vars && export OS_URL=$IRONIC_URL && export OS_TOKEN=$OS_AUTH_TOKEN && export BIFROST_INVENTORY_SOURCE=ironic && ansible baremetal --connection local --inventory /etc/bifrost/inventory/ -e @/etc/bifrost/bifrost.yml -e @/etc/bifrost/dib.yml --limit {{ inventory_hostname }} -m command -a "openstack baremetal node maintenance set {% raw %}{{ inventory_hostname }}{% endraw %} --reason BIOS-RAID"' register: show_result # We use this convoluted construct to work around Ansible's limitations # in evaluation of the delegate_to keyword. delegate_to: "{{ item }}" with_items: - "{{ hostvars[groups['seed'][0]].ansible_host }}" when: "{{ bios_or_raid_change | bool }}" roles: - role: stackhpc.drac drac_address: "{{ ipmi_address }}" drac_username: "{{ ipmi_username }}" drac_password: "{{ ipmi_password }}" drac_bios_config: "{{ controller_bios_config }}" drac_raid_config: "{{ controller_raid_config }}" when: "{{ bios_or_raid_change | bool }}" tasks: - name: Unset the controller nodes' maintenance mode command: > docker exec bifrost_deploy bash -c '. env-vars && export OS_URL=$IRONIC_URL && export OS_TOKEN=$OS_AUTH_TOKEN && export BIFROST_INVENTORY_SOURCE=ironic && ansible baremetal --connection local --inventory /etc/bifrost/inventory/ -e @/etc/bifrost/bifrost.yml -e @/etc/bifrost/dib.yml --limit {{ inventory_hostname }} -m command -a "openstack baremetal node maintenance unset {% raw %}{{ inventory_hostname }}{% endraw %}"' register: show_result # We use this convoluted construct to work around Ansible's limitations # in evaluation of the delegate_to keyword. delegate_to: "{{ item }}" with_items: - "{{ hostvars[groups['seed'][0]].ansible_host }}" when: "{{ bios_or_raid_change | bool }}"