From b5058736cee5df234732f8f4854cd0e5f676dd60 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 18 Jan 2016 14:50:20 -0500 Subject: [PATCH] Fix set_fact + run_once to assign variables to all hosts in the list Fixes #13921 --- lib/ansible/plugins/strategy/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 7e726f0d34..00744dbf73 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -309,23 +309,23 @@ class StrategyBase: else: actual_host = host + if task.run_once: + host_list = [host for host in self._inventory.get_hosts(iterator._play.hosts) if host.name not in self._tqm._unreachable_hosts] + else: + host_list = [actual_host] + if result[0] == 'set_host_var': var_name = result[4] var_value = result[5] - - if task.run_once: - host_list = [host for host in self._inventory.get_hosts(iterator._play.hosts) if host.name not in self._tqm._unreachable_hosts] - else: - host_list = [actual_host] - for target_host in host_list: self._variable_manager.set_host_variable(target_host, var_name, var_value) elif result[0] == 'set_host_facts': facts = result[4] - if task.action == 'set_fact': - self._variable_manager.set_nonpersistent_facts(actual_host, facts) - else: - self._variable_manager.set_host_facts(actual_host, facts) + for target_host in host_list: + if task.action == 'set_fact': + self._variable_manager.set_nonpersistent_facts(target_host, facts) + else: + self._variable_manager.set_host_facts(target_host, facts) else: raise AnsibleError("unknown result message received: %s" % result[0])