From 7837c9b7f8d3de78cebdfc37bcf38775b7f8c292 Mon Sep 17 00:00:00 2001 From: Rafal Lewandowski Date: Mon, 27 May 2024 16:34:51 +0200 Subject: [PATCH] Add ironic config files clean up tasks to overcloud deprovision Closes-Bug: #2067288 Change-Id: I57fb4c1697a31d4f592d79a31a04507cf91e97c7 --- ansible/overcloud-deprovision.yml | 39 +++++++++++++++++++ ...ovision_leftover_fix-6b3150b32cbf9007.yaml | 5 +++ 2 files changed, 44 insertions(+) create mode 100644 releasenotes/notes/deprovision_leftover_fix-6b3150b32cbf9007.yaml diff --git a/ansible/overcloud-deprovision.yml b/ansible/overcloud-deprovision.yml index 824f8ccbb..b389da11c 100644 --- a/ansible/overcloud-deprovision.yml +++ b/ansible/overcloud-deprovision.yml @@ -46,6 +46,22 @@ Deprovision has not been confirmed. You must either type 'yes' when prompted, or set ``confirm_deprovision=yes``. + - name: Get PXE MAC address + command: > + docker exec bifrost_deploy + bash -c ' + export OS_CLOUD=bifrost && + export OS_BAREMETAL_API_VERSION=1.34 && + export BIFROST_INVENTORY_SOURCE=ironic && + export BIFROST_NODE_NAMES="{{ inventory_hostname }}" && + openstack baremetal port list --node {{ inventory_hostname }} --fields address -f value' + register: pxe_result + 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: Check the ironic node's initial provision state command: > docker exec bifrost_deploy @@ -156,3 +172,26 @@ - wait_available | bool - initial_provision_state != 'available' - final_provision_state != 'available' + + - name: Delete host_vars file + become: yes + ansible.builtin.file: + path: /etc/kolla/bifrost/inventory/host_vars/{{ inventory_hostname }} + state: absent + 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: Delete ironic-mac-addr.conf + command: > + docker exec bifrost_deploy + bash -c ' + rm -f /etc/dnsmasq.d/bifrost.dhcp-hosts.d/ironic-{{ item }}.conf' + loop: "{{ pxe_result.stdout_lines }}" + 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) }}" diff --git a/releasenotes/notes/deprovision_leftover_fix-6b3150b32cbf9007.yaml b/releasenotes/notes/deprovision_leftover_fix-6b3150b32cbf9007.yaml new file mode 100644 index 000000000..70b9cafbf --- /dev/null +++ b/releasenotes/notes/deprovision_leftover_fix-6b3150b32cbf9007.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes issue of ironic files being left behind after node deprovision which + prevents it from being enrolled and provisioned again.