Skip to content

Commit 555689a

Browse files
committed
guestfs: fix dnsmasq check to avoid false positives in container environments
The dnsmasq configuration check was too strict and caused false positives on systems where dnsmasq configuration directories exist but the service is not actually running. This particularly affected systems with Incus installed which creates /etc/dnsmasq.d/incus symlink for container networking without running the dnsmasq systemd service. The original check verified the existence of /etc/dnsmasq.conf and /etc/dnsmasq.d directory and would fail if either existed regardless of whether the dnsmasq service was actually running and conflicting with libvirt networking. Replace the filesystem-based checks with a simple service status check that only fails if the dnsmasq service is actually active. This addresses the root cause of the networking conflict which is the running dnsmasq service not the presence of configuration files that may be used by other tools. Remove the checks for configuration file existence and service enabled status keeping only the check for active service state. The check now uses systemctl is-active which returns zero only when the service is currently running and will return non-zero for inactive not-found or any other non-active state. This allows kdevops to run successfully on systems where dnsmasq directories exist for other purposes such as Incus container networking while still protecting against actual conflicts with running dnsmasq services. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent be604b8 commit 555689a

File tree

1 file changed

+7
-45
lines changed

1 file changed

+7
-45
lines changed

playbooks/roles/guestfs/tasks/bringup/network.yml

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,26 @@
11
---
2-
- name: Check for dnsmasq configuration files
3-
ansible.builtin.stat:
4-
path: "{{ item }}"
5-
loop:
6-
- /etc/dnsmasq.conf
7-
- /etc/dnsmasq.d
8-
register: dnsmasq_config_files
9-
when:
10-
- distro_debian_based|bool
11-
12-
- name: Fail if dnsmasq configuration files exist
13-
ansible.builtin.fail:
14-
msg: |
15-
dnsmasq configuration files or directories still exist.
16-
Please remove the following to fully uninstall
17-
dnsmasq:\n{{ dnsmasq_config_files | join('\n') }}
18-
when:
19-
- distro_debian_based|bool
20-
- dnsmasq_config_files.results | selectattr('stat.exists') | list | length > 0
21-
22-
- name: Check if dnsmasq service is enabled
23-
# noqa: command-instead-of-module
24-
become: true
25-
become_flags: "su - -c"
26-
become_method: ansible.builtin.sudo
27-
ansible.builtin.command:
28-
cmd: "systemctl is-enabled dnsmasq"
29-
register: dnsmasq_enabled
30-
failed_when: false
31-
changed_when: false
32-
when:
33-
- distro_debian_based|bool
34-
- dnsmasq_config_files | length > 0
35-
36-
- name: Check if dnsmasq service is active
2+
- name: Check if dnsmasq service is running
373
# noqa: command-instead-of-module
384
become: true
395
become_flags: "su - -c"
406
become_method: ansible.builtin.sudo
417
ansible.builtin.command:
428
cmd: "systemctl is-active dnsmasq"
43-
register: dnsmasq_active
9+
register: dnsmasq_status
4410
failed_when: false
4511
changed_when: false
4612
when:
4713
- distro_debian_based|bool
48-
- dnsmasq_config_files | length > 0
4914

50-
- name: Fail if dnsmasq service is enabled or active
15+
- name: Fail if dnsmasq service conflicts with libvirt
5116
ansible.builtin.fail:
5217
msg: |
53-
dnsmasq service is
54-
{{ 'enabled' if dnsmasq_enabled.rc == 0 else 'active' if dnsmasq_active.rc == 0 else 'present' }}.
55-
Please ensure dnsmasq is fully uninstalled and disabled.
56-
Run 'sudo systemctl disable dnsmasq' and 'sudo systemctl
57-
stop dnsmasq' to disable and stop the service.
18+
dnsmasq service is running and will conflict with libvirt networking.
19+
The libvirt default network requires control of DHCP/DNS services.
20+
Disable dnsmasq with: sudo systemctl disable --now dnsmasq
5821
when:
5922
- distro_debian_based|bool
60-
- dnsmasq_config_files | length > 0
61-
- (dnsmasq_enabled.rc == 0) or (dnsmasq_active.rc == 0)
23+
- dnsmasq_status.rc == 0
6224

6325
- name: Check if libvirt default network is running
6426
become: true

0 commit comments

Comments
 (0)