mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-05 05:34:22 -07:00
Fix some bugs related to facts/nonpersistent-facts cache split
Fixes #12313
This commit is contained in:
parent
1e2dc212bd
commit
292e2da4e1
2 changed files with 20 additions and 2 deletions
|
@ -267,7 +267,7 @@ class StrategyBase:
|
||||||
return v
|
return v
|
||||||
|
|
||||||
var_value = _wrap_var(var_value)
|
var_value = _wrap_var(var_value)
|
||||||
self._variable_manager.set_host_facts(host, {var_name: var_value})
|
self._variable_manager.set_nonpersistent_facts(host, {var_name: var_value})
|
||||||
|
|
||||||
elif result[0] in ('set_host_var', 'set_host_facts'):
|
elif result[0] in ('set_host_var', 'set_host_facts'):
|
||||||
host = result[1]
|
host = result[1]
|
||||||
|
@ -293,6 +293,9 @@ class StrategyBase:
|
||||||
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':
|
||||||
|
self._variable_manager.set_nonpersistent_facts(target_host, facts)
|
||||||
|
else:
|
||||||
self._variable_manager.set_host_facts(target_host, facts)
|
self._variable_manager.set_host_facts(target_host, facts)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -390,6 +390,21 @@ class VariableManager:
|
||||||
|
|
||||||
assert isinstance(facts, dict)
|
assert isinstance(facts, dict)
|
||||||
|
|
||||||
|
if host.name not in self._fact_cache:
|
||||||
|
self._fact_cache[host.name] = facts
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self._fact_cache[host.name].update(facts)
|
||||||
|
except KeyError:
|
||||||
|
self._fact_cache[host.name] = facts
|
||||||
|
|
||||||
|
def set_nonpersistent_facts(self, host, facts):
|
||||||
|
'''
|
||||||
|
Sets or updates the given facts for a host in the fact cache.
|
||||||
|
'''
|
||||||
|
|
||||||
|
assert isinstance(facts, dict)
|
||||||
|
|
||||||
if host.name not in self._nonpersistent_fact_cache:
|
if host.name not in self._nonpersistent_fact_cache:
|
||||||
self._nonpersistent_fact_cache[host.name] = facts
|
self._nonpersistent_fact_cache[host.name] = facts
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue