Created
December 14, 2017 13:29
-
-
Save mkrizek/6c776f1618c57febd8b30f2ae84fd544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py | |
index 6a9428ddfd..a6bee588ef 100644 | |
--- a/lib/ansible/plugins/strategy/__init__.py | |
+++ b/lib/ansible/plugins/strategy/__init__.py | |
@@ -865,10 +865,10 @@ class StrategyBase: | |
# * raise an error or show a warning when a conditional is used | |
# on a meta task that doesn't support them | |
- def _evaluate_conditional(h): | |
- all_vars = self._variable_manager.get_vars(play=iterator._play, host=h, task=task) | |
- templar = Templar(loader=self._loader, variables=all_vars) | |
- return task.evaluate_conditional(templar, all_vars) | |
+ all_vars = self._variable_manager.get_vars(play=iterator._play, host=target_host, task=task) | |
+ templar = Templar(loader=self._loader, variables=all_vars) | |
+ play_context.post_validate(templar) | |
+ | |
skipped = False | |
msg = '' | |
@@ -882,7 +882,7 @@ class StrategyBase: | |
self._inventory.refresh_inventory() | |
msg = "inventory successfully refreshed" | |
elif meta_action == 'clear_facts': | |
- if _evaluate_conditional(target_host): | |
+ if task.evaluate_conditional(templar, all_vars): | |
for host in self._inventory.get_hosts(iterator._play.hosts): | |
hostname = host.get_name() | |
self._variable_manager.clear_facts(hostname) | |
@@ -890,7 +890,7 @@ class StrategyBase: | |
else: | |
skipped = True | |
elif meta_action == 'clear_host_errors': | |
- if _evaluate_conditional(target_host): | |
+ if task.evaluate_conditional(templar, all_vars): | |
for host in self._inventory.get_hosts(iterator._play.hosts): | |
self._tqm._failed_hosts.pop(host.name, False) | |
self._tqm._unreachable_hosts.pop(host.name, False) | |
@@ -899,7 +899,7 @@ class StrategyBase: | |
else: | |
skipped = True | |
elif meta_action == 'end_play': | |
- if _evaluate_conditional(target_host): | |
+ if task.evaluate_conditional(templar, all_vars): | |
for host in self._inventory.get_hosts(iterator._play.hosts): | |
if host.name not in self._tqm._unreachable_hosts: | |
iterator._host_states[host.name].run_state = iterator.ITERATING_COMPLETE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment