Disallow (and rewrite) injected variables #3457
Unanswered
MarkusTeufelberger
asked this question in
New rules
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
See also #3456
Ansible since version 2.5 stores all its host facts in the
ansible_facts
dictionary, but since then has kept its previous design of injecting them into the global namespace. This is turned on by default (e.g.ansible_facts['distribution']
is also available asansible_distribution
).This apparently has performance implications (lots of copying around facts for every single host in the inventory probably adds up over time), makes roles slightly less portable (in theory https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars could be turned off by users from its current default of being enabled already now) and there are apparently plans to change the default value and set
INJECT_FACTS_AS_VARS=False
as a default some time in the future (2.16 might already warn about this, the real change probably would end up in 2.20 or so).This is also a great candidate for automatic transforms (
ansible_distribution
-->ansible_facts['distribution']
) to make the transition easier or even automated for users. Either by being very explicit and safe (maintain a growing list of facts before/after) or by rewriting as much as possible (variable starts withansible_...
? rewrite toansible_facts['...']
!) from the get-go.In any case, this is likely something that will come up this summer either way. It can also be tested already by users by setting fact injection to false to find out how/where they are affected.
Beta Was this translation helpful? Give feedback.
All reactions