Skip to content

Commit bd896df

Browse files
committed
fix: add condition to execute socket services
When listen_address is not defined (default), the drop-in files are not created. Make sure the role will not try to manage the non-existing services.
1 parent 9edce18 commit bd896df

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

handlers/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
state: "{{ item.enabled | bool | ternary('started', 'stopped') }}"
2121
become: true
2222
loop: "{{ _libvirt_socket_services }}"
23+
when:
24+
- item.listen_address is not none
25+
- item.listen_address | length > 0
2326
loop_control:
2427
label: "{{ item.service }}"
2528
listen:

tasks/config.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,13 @@
139139
name: "{{ item.service }}"
140140
state: "{{ item.enabled | bool | ternary('started', 'stopped') }}"
141141
enabled: "{{ item.enabled | bool }}"
142-
become: True
143-
loop: "{{ _libvirt_services }}"
142+
become: true
143+
loop: "{{ _libvirt_services + _libvirt_socket_services }}"
144+
when: item.listen_address is not defined or
145+
(item.listen_address is not none and item.listen_address | length > 0)
144146
loop_control:
145147
label: "{{ item.service }}"
146148
vars:
147149
_libvirt_services:
148-
- service: libvirtd-tcp.socket
149-
enabled: "{{ libvirt_host_tcp_listen | bool }}"
150-
- service: libvirtd-tls.socket
151-
enabled: "{{ libvirt_host_tls_listen | bool }}"
152150
- service: libvirtd
153151
enabled: true

0 commit comments

Comments
 (0)