mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-19 06:40:21 -07:00
fix precedence issue with facts and vars (#32302)
avoid making gathered facts high precedence, only set_fact is supposed to be.
vars set via set_fact with cacheable are higher precedence than plain facts.
Previously (after 6fbd0a8bb5
) regular facts would end up with a
higher precedence than host or play vars, but they should not be. Facts were getting added to 'non_persistent_facts' (equivalent to 'register' vars) which is higher precedence than facts should be.
added 'cacheable set_facts' to precedence docs
'ansible_facts_cacheable' -> '_ansible_facts_cacheable' (made 'private')
This commit is contained in:
parent
d1e55551e9
commit
41685fb516
3 changed files with 8 additions and 7 deletions
|
@ -511,13 +511,12 @@ class StrategyBase:
|
|||
for target_host in host_list:
|
||||
self._variable_manager.set_host_variable(target_host, var_name, var_value)
|
||||
else:
|
||||
cacheable = result_item.pop('ansible_facts_cacheable', True)
|
||||
cacheable = result_item.pop('_ansible_facts_cacheable', False)
|
||||
for target_host in host_list:
|
||||
if cacheable:
|
||||
if not original_task.action == 'set_fact' or cacheable:
|
||||
self._variable_manager.set_host_facts(target_host, result_item['ansible_facts'].copy())
|
||||
|
||||
# If we are setting a fact, it should populate non_persistent_facts as well
|
||||
self._variable_manager.set_nonpersistent_facts(target_host, result_item['ansible_facts'].copy())
|
||||
if original_task.action == 'set_fact':
|
||||
self._variable_manager.set_nonpersistent_facts(target_host, result_item['ansible_facts'].copy())
|
||||
|
||||
if 'ansible_stats' in result_item and 'data' in result_item['ansible_stats'] and result_item['ansible_stats']['data']:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue