From c340a6efe69db8d69f90943426ef52feb54ef296 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 17 May 2018 08:15:31 +0100 Subject: [PATCH] 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 --- playbooks/infra-journal-remote.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/playbooks/infra-journal-remote.yml b/playbooks/infra-journal-remote.yml index 19bbb352f0..50ad0aba6a 100644 --- a/playbooks/infra-journal-remote.yml +++ b/playbooks/infra-journal-remote.yml @@ -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] }}"