diff --git a/handlers/main.yml b/handlers/main.yml index 183bcc9..9d787ed 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -20,6 +20,9 @@ state: "{{ item.enabled | bool | ternary('started', 'stopped') }}" become: true loop: "{{ _libvirt_socket_services }}" + when: + - item.listen_address is not none + - item.listen_address | length > 0 loop_control: label: "{{ item.service }}" listen: diff --git a/tasks/config.yml b/tasks/config.yml index 7817377..45beb5f 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -139,15 +139,13 @@ name: "{{ item.service }}" state: "{{ item.enabled | bool | ternary('started', 'stopped') }}" enabled: "{{ item.enabled | bool }}" - become: True - loop: "{{ _libvirt_services }}" + become: true + loop: "{{ _libvirt_services + _libvirt_socket_services }}" + when: item.listen_address is not defined or + (item.listen_address is not none and item.listen_address | length > 0) loop_control: label: "{{ item.service }}" vars: _libvirt_services: - - service: libvirtd-tcp.socket - enabled: "{{ libvirt_host_tcp_listen | bool }}" - - service: libvirtd-tls.socket - enabled: "{{ libvirt_host_tls_listen | bool }}" - service: libvirtd enabled: true