Files
nova/roles/run-evacuate-hook/tasks/main.yaml
T
Sean Mooney 6c9110bb8b Handle missing libvirt services in evacuate hook
On Debian 13 (Trixie), libvirt packaging is modularized and
the libvirt-daemon-lock package (providing virtlockd) is
optional. The evacuate hook previously assumed all libvirt
services were installed and failed when stopping/starting
missing units.

Extract a reusable manage_libvirt_service.yaml task file that
checks if a service exists via systemctl list-unit-files
before managing its units. This prevents failures when
optional libvirt packages are not installed and future-proofs
against further packaging changes.

Generated-By: claude-code
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change-Id: Ie84e2e8ab2d3065b1562ee5e256fa163541955f7
Signed-off-by: Sean Mooney <work@seanmooney.info>
2026-02-17 18:22:22 +00:00

114 lines
2.9 KiB
YAML

- name: Setup resources and mark the subnode as forced down
become: true
become_user: stack
shell: "/opt/stack/nova/roles/run-evacuate-hook/files/setup_evacuate_resources.sh"
environment:
SUBNODE_HOSTNAME: "{{ hostvars['compute1']['ansible_hostname'] }}"
- name: Fence subnode by stopping n-cpu
delegate_to: compute1
become: true
systemd:
name: devstack@n-cpu
state: stopped
- name: Check if q-agt exists
shell: sudo systemctl status devstack@q-agt
ignore_errors: true
register: qagtstatus
- name: Fence subnode by stopping q-agt (if exists)
delegate_to: compute1
become: true
systemd:
name: devstack@q-agt
state: stopped
when: qagtstatus.rc | int == 0
- name: Make sure lxml is installed
delegate_to: compute1
become: true
package:
name: python3-lxml
state: present
- name: Register running domains on subnode
delegate_to: compute1
become: true
virt:
command: list_vms
state: running
register: subnode_vms
- name: Destroy running domains on subnode
delegate_to: compute1
become: true
virt:
name: "{{ item }}"
state: destroyed
with_items: "{{ subnode_vms.list_vms }}"
- name: Stop libvirt services on "{{ inventory_hostname }}"
include_tasks: manage_libvirt_service.yaml
vars:
service_name: "{{ item.name }}"
service_state: stopped
service_enabled: "no"
service_units: "{{ item.units }}"
loop:
- name: libvirtd
units:
- libvirtd.service
- libvirtd.socket
- libvirtd-admin.socket
- libvirtd-ro.socket
- name: virtlogd
units:
- virtlogd.service
- virtlogd-admin.socket
- virtlogd.socket
- name: virtlockd
units:
- virtlockd.service
- virtlockd-admin.socket
- virtlockd.socket
- name: Run negative evacuate tests
become: true
become_user: stack
shell: "/opt/stack/nova/roles/run-evacuate-hook/files/test_negative_evacuate.sh"
environment:
CONTROLLER_HOSTNAME: "{{ hostvars['controller']['ansible_hostname'] }}"
- name: Start libvirt services on "{{ inventory_hostname }}"
include_tasks: manage_libvirt_service.yaml
vars:
service_name: "{{ item.name }}"
service_state: started
service_enabled: "yes"
service_units: "{{ item.units }}"
loop:
- name: libvirtd
units:
- libvirtd.service
- libvirtd.socket
- libvirtd-admin.socket
- libvirtd-ro.socket
- name: virtlogd
units:
- virtlogd.service
- virtlogd-admin.socket
- virtlogd.socket
- name: virtlockd
units:
- virtlockd.service
- virtlockd-admin.socket
- virtlockd.socket
- name: Run evacuate tests
become: true
become_user: stack
shell: "/opt/stack/nova/roles/run-evacuate-hook/files/test_evacuate.sh"
environment:
CONTROLLER_HOSTNAME: "{{ hostvars['controller']['ansible_hostname'] }}"