Make sure setting facts with run_once makes copies of the data

When using run_once, there is only one dict of facts so passing that
to the VariableManager results in the fact cache containing the same
dictionary reference for all hosts in inventory. This patch fixes that
by making sure we pass a copy of the facts dict to VariableManager.

Fixes #14279
pull/15851/head
James Cammarata 9 years ago
parent 2cc50c6dc6
commit d2bade6daf

@ -377,9 +377,9 @@ class StrategyBase:
facts = result[4] facts = result[4]
for target_host in host_list: for target_host in host_list:
if task.action == 'set_fact': if task.action == 'set_fact':
self._variable_manager.set_nonpersistent_facts(target_host, facts) self._variable_manager.set_nonpersistent_facts(target_host, facts.copy())
else: else:
self._variable_manager.set_host_facts(target_host, facts) self._variable_manager.set_host_facts(target_host, facts.copy())
elif result[0].startswith('v2_runner_item') or result[0] == 'v2_runner_retry': elif result[0].startswith('v2_runner_item') or result[0] == 'v2_runner_retry':
self._tqm.send_callback(result[0], result[1]) self._tqm.send_callback(result[0], result[1])
elif result[0] == 'v2_on_file_diff': elif result[0] == 'v2_on_file_diff':

Loading…
Cancel
Save