mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix set_fact + run_once to assign variables to all hosts in the list
Fixes #13921
This commit is contained in:
parent
46e515131e
commit
b5058736ce
1 changed files with 10 additions and 10 deletions
|
@ -309,23 +309,23 @@ class StrategyBase:
|
||||||
else:
|
else:
|
||||||
actual_host = host
|
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':
|
if result[0] == 'set_host_var':
|
||||||
var_name = result[4]
|
var_name = result[4]
|
||||||
var_value = result[5]
|
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:
|
for target_host in host_list:
|
||||||
self._variable_manager.set_host_variable(target_host, var_name, var_value)
|
self._variable_manager.set_host_variable(target_host, var_name, var_value)
|
||||||
elif result[0] == 'set_host_facts':
|
elif result[0] == 'set_host_facts':
|
||||||
facts = result[4]
|
facts = result[4]
|
||||||
if task.action == 'set_fact':
|
for target_host in host_list:
|
||||||
self._variable_manager.set_nonpersistent_facts(actual_host, facts)
|
if task.action == 'set_fact':
|
||||||
else:
|
self._variable_manager.set_nonpersistent_facts(target_host, facts)
|
||||||
self._variable_manager.set_host_facts(actual_host, facts)
|
else:
|
||||||
|
self._variable_manager.set_host_facts(target_host, facts)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise AnsibleError("unknown result message received: %s" % result[0])
|
raise AnsibleError("unknown result message received: %s" % result[0])
|
||||||
|
|
Loading…
Add table
Reference in a new issue