From 1b8c2a2b0b1b87b41598f44ae57b17dfcc83ac73 Mon Sep 17 00:00:00 2001 From: stephane Date: Thu, 6 Oct 2016 15:38:40 -0700 Subject: [PATCH] Restore "skipping: no hosts matched" message In https://github.com/ansible/ansible/commit/159aa26b36a6455ebc38d527c294c60899892c04 the result of _get_serialized_branches when no hosts were matched changed from [[]] to []. Thus, the v2_playbook_on_no_hosts_matched callback would not fire. Change the check so we get the error message again. Fixes #17706 --- lib/ansible/executor/playbook_executor.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py index 39e95c2261..5923deafc0 100644 --- a/lib/ansible/executor/playbook_executor.py +++ b/lib/ansible/executor/playbook_executor.py @@ -142,12 +142,11 @@ class PlaybookExecutor: break_play = False # we are actually running plays - for batch in self._get_serialized_batches(new_play): - if len(batch) == 0: - self._tqm.send_callback('v2_playbook_on_play_start', new_play) - self._tqm.send_callback('v2_playbook_on_no_hosts_matched') - break - + batches = self._get_serialized_batches(new_play) + if len(batches) == 0: + self._tqm.send_callback('v2_playbook_on_play_start', new_play) + self._tqm.send_callback('v2_playbook_on_no_hosts_matched') + for batch in batches: # restrict the inventory to the hosts in the serialized batch self._inventory.restrict_to_hosts(batch) # and run it...