Skip to content

Commit e5f9d1d

Browse files
cjeanneropenshift-merge-bot[bot]
authored andcommitted
Avoid failures on cleaning
While working on integrating dnsmasq role in the reproducer, a random issue, related to the facts, might happen. It seems to be caused by the way ansible manages the handler - the `ansible_facts.packages` isn't available anymore, and the condition triggering the libvirt cleanup fails. While it was already done. This condition arrises when dnsmasq role is in the game, and the handler kicks at the end of the playbook. In the same fashion, the handler might be triggered when the service is already removed, leading to another crash of the cleanup playbook. The added conditions ensure the handler will succeed even if the service is already removed, but would still fail if there's a real issue with the service configuration.
1 parent 75c6ef4 commit e5f9d1d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

roles/dnsmasq/handlers/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
- name: Restart dnsmasq
1818
become: true
19+
register: _dnsmasq
1920
ansible.builtin.systemd_service:
2021
name: cifmw-dnsmasq.service
2122
state: restarted
23+
failed_when:
24+
- _dnsmasq.msg is defined
25+
- _dnsmasq.msg is not
26+
match('Could not find the requested service cifmw-dnsmasq.service')

roles/libvirt_manager/tasks/clean_layout.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
ansible.builtin.package_facts: {}
44

55
- name: Perform the libvirt cleanup
6-
when: >-
7-
cifmw_libvirt_manager_dependency_packages |
8-
difference(ansible_facts.packages.keys()) |
9-
length == 0
6+
when:
7+
- ansible_facts.packages is defined
8+
- >-
9+
cifmw_libvirt_manager_dependency_packages |
10+
difference(ansible_facts.packages.keys()) |
11+
length == 0
1012
block:
1113
- name: List all of the existing virtual machines
1214
register: vms_list

0 commit comments

Comments
 (0)