diff --git a/defaults/main.yml b/defaults/main.yml index 899397d..16313b9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -40,27 +40,27 @@ libvirt_host_var_prefix: "" # Where the Unix Domain sockets are stored libvirt_host_socket_dir: >- - {%- if libvirt_host_var_prefix -%} + {%- if libvirt_host_var_prefix is truthy -%} /var/run/{{ libvirt_host_var_prefix }} {%- endif -%} # Path to PID file which prevents mulitple instances of the daemon from # spawning libvirt_host_pid_path: >- - {%- if libvirt_host_var_prefix -%} + {%- if libvirt_host_var_prefix is truthy -%} /var/run/{{ libvirt_host_var_prefix }}.pid {%- endif -%} # Command line arguments passed to libvirtd by the init system when # libvirtd is started - quotes will be added libvirt_host_libvirtd_args: >- - {%- if libvirt_host_pid_path -%} + {%- if libvirt_host_pid_path is truthy -%} -p {{ libvirt_host_pid_path }} {%- endif %} # The libvirt connnection URI libvirt_host_uri: >- - {%- if libvirt_host_socket_dir -%} + {%- if libvirt_host_socket_dir is truthy -%} qemu+unix:///system?socket={{ libvirt_host_socket_dir }}/libvirt-sock {%- endif %} diff --git a/tasks/config.yml b/tasks/config.yml index 49c4e71..38dfd1b 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -9,7 +9,7 @@ group: root mode: 0755 become: true - when: libvirt_host_socket_dir | length > 0 + when: libvirt_host_socket_dir is truthy - name: Process lineinfile rules lineinfile: "{{ rule.args }}" @@ -56,8 +56,7 @@ become: true loop: "{{ _libvirt_socket_services | selectattr('enabled') }}" when: - - item.listen_address is not none - - item.listen_address | length > 0 + - item.listen_address is truthy loop_control: label: "{{ item.service }}" vars: @@ -73,8 +72,7 @@ become: true loop: "{{ _libvirt_socket_services | selectattr('enabled') }}" when: - - item.listen_address is not none - - item.listen_address | length > 0 + - item.listen_address is truthy loop_control: label: "{{ item.service }}" vars: diff --git a/tasks/install-daemon.yml b/tasks/install-daemon.yml index f08e9fe..f98d191 100644 --- a/tasks/install-daemon.yml +++ b/tasks/install-daemon.yml @@ -33,7 +33,7 @@ when: - ansible_facts.os_family == "RedHat" - ansible_facts.distribution_major_version | int == 7 - - libvirt_host_qemu_emulators | length > 0 + - libvirt_host_qemu_emulators is truthy - name: Ensure QEMU emulator packages are installed package: diff --git a/tasks/main.yml b/tasks/main.yml index b1f7315..1068bc9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,7 +26,7 @@ when: libvirt_host_install_client | bool - name: Include pools.yml include_tasks: pools.yml - when: libvirt_host_pools | length > 0 + when: libvirt_host_pools is truthy - name: Include networks.yml include_tasks: networks.yml - when: libvirt_host_networks | length > 0 + when: libvirt_host_networks is truthy diff --git a/tasks/post-install-Debian.yml b/tasks/post-install-Debian.yml index bdb1425..ac95179 100644 --- a/tasks/post-install-Debian.yml +++ b/tasks/post-install-Debian.yml @@ -21,7 +21,7 @@ insertafter: '^#libvirtd_opts=' regexp: '^libvirtd_opts=' line: "libvirtd_opts={{ libvirt_host_libvirtd_args }}" - condition: "{{ libvirt_host_libvirtd_args | length > 0 }}" + condition: "{{ libvirt_host_libvirtd_args is truthy }}" vars: libvirt_env_path: "{{ '/etc/default/libvirt-bin' if libvirt_bin_stat.stat.exists else '/etc/default/libvirtd' }}" tags: vars diff --git a/tasks/validate.yml b/tasks/validate.yml index 70ab253..9b72745 100644 --- a/tasks/validate.yml +++ b/tasks/validate.yml @@ -35,4 +35,4 @@ defined when: - libvirt_host_enable_sasl_support | bool - - libvirt_host_sasl_credentials | rejectattr('password') | length > 0 + - libvirt_host_sasl_credentials | rejectattr('password') is truthy diff --git a/templates/libvirtd.conf.j2 b/templates/libvirtd.conf.j2 index fdf9568..9983d6b 100644 --- a/templates/libvirtd.conf.j2 +++ b/templates/libvirtd.conf.j2 @@ -1,5 +1,5 @@ # {{ ansible_managed }} -{% if libvirt_host_socket_dir | length > 0 %} +{% if libvirt_host_socket_dir is truthy %} unix_sock_dir = "{{ libvirt_host_socket_dir }}" {% endif %} {% for key, value in libvirt_host_libvirtd_conf.items() %} diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 274a359..eac865c 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -70,4 +70,4 @@ libvirt_host_lineinfile_extra_rules: insertafter: '^#LIBVIRTD_ARGS=' regexp: '^LIBVIRTD_ARGS=' line: LIBVIRTD_ARGS="{{ libvirt_host_libvirtd_args }}" - condition: "{{ libvirt_host_libvirtd_args != '' }}" + condition: "{{ libvirt_host_libvirtd_args is truthy }}"