kayobe/ansible/roles/ipa-images/tasks/set-driver-info.yml
Grzegorz Koper 80f6db34cd Bump up Ansible supported versions to 7.x/8.x
This change bumps up the maximum supported version of Ansible to 8.x
(ansible-core 2.15.x) and minimum to 7.x (ansible-core 2.14.x).

Depends on:
https://github.com/stackhpc/ansible-role-systemd-networkd/pull/10

https://github.com/stackhpc/ansible-role-dell-powerconnect-switch/pull/13

https://github.com/stackhpc/ansible-role-mellanox-switch/pull/8

gateway_ip was being set to empty string. This was triggering neutron
""Invalid input for gateway_ip. Reason: '' is not a valid IP address."
Omitting by default.

Installing openstack.cloud collection.
Upgrade failed as Ansible in kayobe-venv was not upgraded.

Change-Id: Ia3550644e5fc3e83f792e46d42b4c35d5eec4705
2023-11-07 18:33:06 +01:00

63 lines
2.3 KiB
YAML

---
- name: Retrieve deployment image uuids
openstack.cloud.image_info:
auth_type: "{{ ipa_images_openstack_auth_type }}"
auth: "{{ ipa_images_openstack_auth }}"
cacert: "{{ ipa_images_openstack_cacert | default(omit, true) }}"
interface: "{{ ipa_images_openstack_interface | default(omit, true) }}"
image: "{{ item.name }}"
with_items:
- name: "{{ ipa_images_kernel_name }}"
- name: "{{ ipa_images_ramdisk_name }}"
register: ipa_images_glance
- name: Set fact containing kernel uuid
set_fact:
ipa_images_kernel_uuid: "{{ ipa_images_glance.results[0].images[0].id }}"
- name: Set fact containing ramdisk uuid
set_fact:
ipa_images_ramdisk_uuid: "{{ ipa_images_glance.results[1].images[0].id }}"
- name: Get a list of ironic nodes
command: |
{{ ipa_images_venv }}/bin/openstack baremetal node list --fields name uuid driver_info -f json
register: ipa_images_ironic_node_list
changed_when: False
environment: "{{ ipa_images_openstack_auth_env }}"
- name: Make sure openstack nodes are in baremetal-compute group
add_host:
name: "{{ item.Name }}"
groups: baremetal-compute
when:
- item.Name is not none
- item.Name not in groups["baremetal-compute"]
with_items: "{{ ipa_images_ironic_node_list.stdout | from_json }}"
- name: Set fact containing filtered list of nodes
set_fact:
ipa_images_compute_node_whitelist: "{{ query('inventory_hostnames', ipa_images_compute_node_limit) | unique }}"
- name: Initialise a fact containing the ironic nodes
set_fact:
ipa_images_ironic_nodes: []
- name: Update a fact containing the ironic nodes
set_fact:
ipa_images_ironic_nodes: "{{ ipa_images_ironic_nodes + [item] }}"
with_items: "{{ ipa_images_ironic_node_list.stdout | from_json }}"
when: item['Name'] in ipa_images_compute_node_whitelist
- name: Ensure ironic nodes use the new Ironic Python Agent (IPA) images
command: >
{{ ipa_images_venv }}/bin/openstack baremetal node set {{ item.UUID }}
--driver-info deploy_kernel={{ ipa_images_kernel_uuid }}
--driver-info deploy_ramdisk={{ ipa_images_ramdisk_uuid }}
with_items: "{{ ipa_images_ironic_nodes }}"
when:
item["Driver Info"].deploy_kernel != ipa_images_kernel_uuid or
item["Driver Info"].deploy_ramdisk != ipa_images_ramdisk_uuid
environment: "{{ ipa_images_openstack_auth_env }}"