
Hypervisor list for Nova get's populated with node FQDNs, which might be completely different then nodename. This is also reproducible in AIO, where ansible_facts['nodename'] is `aio1`, while ansible_facts['fqdn'] is `aio1.openstack.local`. And the fqdn is defined in hypervisor listing. Since there could be a confusion in hostname/nodename/fqdn from deployment to deployment, we make the fact variable configurable. Related-Bug: #2081741 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-openstack_hosts/+/930272 Change-Id: If43d721abb978d305abba8ee01d6de2ed2bf2553
46 lines
1.4 KiB
YAML
46 lines
1.4 KiB
YAML
---
|
|
- name: Ensuring that compute node has UUID state defined
|
|
hosts: nova_compute
|
|
vars:
|
|
nova_compute_id_file: /var/lib/nova/compute_id
|
|
nova_hypervisor_fact_name: "{{ ansible_facts['fqdn'] }}"
|
|
handlers:
|
|
|
|
- name: Restart nova
|
|
ansible.builtin.service:
|
|
name: nova-compute
|
|
state: restarted
|
|
|
|
tasks:
|
|
|
|
- name: Checking if compute file exist
|
|
ansible.builtin.stat:
|
|
path: "{{ nova_compute_id_file }}"
|
|
register: _compute_id_status
|
|
|
|
- name: Get list of existing hypervisors # noqa: run-once[task]
|
|
ansible.builtin.command: openstack --os-cloud default hypervisor list -f json -c ID -c "Hypervisor Hostname"
|
|
run_once: true
|
|
delegate_to: "{{ groups['utility_all'][0] }}"
|
|
register: nova_hypervisors
|
|
changed_when: false
|
|
|
|
- name: Get node UUID if needed
|
|
when: not _compute_id_status.stat.exists
|
|
block:
|
|
|
|
- name: Register hypervisors fact
|
|
ansible.builtin.set_fact:
|
|
nova_hv: "{{ nova_hypervisors.stdout | from_json | selectattr('Hypervisor Hostname', 'eq', nova_hypervisor_fact_name) }}"
|
|
|
|
- name: Place node UUID to the expected location
|
|
ansible.builtin.copy:
|
|
dest: "{{ nova_compute_id_file }}"
|
|
content: >
|
|
{{ nova_hv[0]['ID'] }}
|
|
owner: nova
|
|
group: nova
|
|
mode: "0640"
|
|
when: nova_hv
|
|
notify: Restart nova
|