infra-journal-remote: Skip playbook on empty emtpy log_hosts group

If the log_hosts group is empty, then the deployment fails with the
following error:

{{ hostvars[groups['log_hosts'][0]]['ansible_host'] }}: list object has no element 0"}

As such, we need to skip the playbook if no hosts are defined in that
group.

Change-Id: Icf528f8c71e61de9e5a4c1e4004f5b269508d051
This commit is contained in:
Markos Chandras 2018-05-17 08:15:31 +01:00
parent 362e9b24f2
commit c340a6efe6

View File

@ -26,6 +26,11 @@
when:
- ansible_pkg_mgr == 'zypper'
- name: Skip playbook if log_hosts group is empty
meta: end_play
when:
- groups['log_hosts'] | length == 0
- name: Install systemd-journal-remote
package:
name: "{{ systemd_journal_remote_distro_package[ansible_pkg_mgr] }}"