Replies: 1 comment
-
ansible-core upstream is changing the default so that facts will not be "injected" as vars in the future, see: It would really helpful if ansible-lint count help detecting these cases. While one could alternatively set "inject_facts_as_vars = False" in ansible.cfg that requires running the code and then the code wouldn't work past the first instance so having ansible-lint reporting all occasions alongside with any other possible findings would make things a lot easier. Thanks. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
In the investigation of an ansible performance problem related to facts (ansible/ansible#73654) , it was found that having INJECT_FACTS_AS_VARS set to true (which is the default) can lead to a performance impact when processing result. The larger the amount of host facts, the longer task result processing takes. It would be beneficial to warn if someone is relying on these facts. Since it's dynamic, it might be difficult to determine which vars, but there are common ones like ansible_distribution* or ansible_{hostname,fqdn,nodename,os}
Additionally it might be beneficial to warn about an unfiltered setup module call as pulling in all the facts can have unintended performance issues.
Related changes: https://review.opendev.org/q/owner:aschultz%2540redhat.com+topic:ansible-facts
Issue Type
STEPS TO FIND SIMILAR VARS
I found our usage of these things by looking in our yaml files with something like:
grep ansible_ * -r | egrep -v "_(facts|become|user|host|limit|check_mode|ssh|connection|managed|verbose|job|home|log|loop|async|limit|filter|version|_inventory|\.py|group_vars)" | grep ansible_
Desired Behaviour
Warn when things like ansible_hostname, ansible_fqdn, ansible_distribution, etc are used.
Beta Was this translation helpful? Give feedback.
All reactions