Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow role to run with INJECT_FACTS_AS_VARS set to false #117

Open
kennethso168 opened this issue Feb 21, 2024 · 1 comment
Open

Allow role to run with INJECT_FACTS_AS_VARS set to false #117

kennethso168 opened this issue Feb 21, 2024 · 1 comment

Comments

@kennethso168
Copy link

Currently, the role failed to run with INJECT_FACTS_AS_VARS set to false as the required ansible_* variables (e.g. ansible_os_family) are not defined.

The configuration INJECT_FACTS_AS_VARS and the Ansible fact namespace ansible_facts.* has been added in Ansible 2.5. In the porting guide of that version it stated that:

A new configuration variable, inject_facts_as_vars, has been added to ansible.cfg. Its default setting, ‘True’, keeps the 2.4 behavior of facts variables being set in the old ansible_* locations (while also writing them to the new namespace). This variable is expected to be set to ‘False’ in a future release. When inject_facts_as_vars is set to False, you must refer to ansible_facts through the new ansible_facts.* namespace.

It was also confirmed by Ansible developer on reddit that INJECT_FACTS_AS_VARS was planned to be deprecated in the future.

Therefore, it would be great if the role supported INJECT_FACTS_AS_VARS=false as well.

To fix this just change all ansible_* variables to ansible_facts.*. This should work for ansible versions >=2.5. I can do a PR when I have time.

@DO1JLR
Copy link
Member

DO1JLR commented Feb 22, 2024

Interesting, I was not aware of that.

Thanks for bringing this up. I will be happy to merge your pull request. If I find the time to fix it myself before you create a pull-request, I will do so and post a comment in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants