-
Notifications
You must be signed in to change notification settings - Fork 61
refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead #577
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
Conversation
…stead Ansible 2.20 has deprecated the use of Ansible facts as variables. For example, `ansible_distribution` is now deprecated in favor of `ansible_facts["distribution"]`. This is due to making the default setting `INJECT_FACTS_AS_VARS=false`. For now, this will create WARNING messages, but in Ansible 2.24 it will be an error. See https://docs.ansible.com/projects/ansible/latest/porting_guides/porting_guide_core_2.20.html#inject-facts-as-vars Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Reviewer's GuideRefactors the role and its tests to stop using deprecated top-level Ansible fact variables and instead consistently access facts via the ansible_facts dictionary so it works with INJECT_FACTS_AS_VARS=false, while also ensuring required facts (including pkg_mgr) are gathered. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[citest] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `vars/main.yml:9` </location>
<code_context>
- distribution_major_version
- distribution_version
- os_family
+ - pkg_mgr
# the subsets of ansible_facts that need to be gathered in case any of the
</code_context>
<issue_to_address>
**issue:** Architecture fact is now used via ansible_facts but isn’t listed in required facts, which could lead to missing data when gathering a minimal fact subset.
`pkg_mgr` was correctly added to `__storage_required_facts` now that it’s accessed via `ansible_facts['pkg_mgr']`. Similarly, several distro var files now use `ansible_facts['architecture']`, but `architecture` is not in `__storage_required_facts`. If facts are gathered with a minimal subset, `architecture` may be missing at runtime, so it should likely be added here as well.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #577 +/- ##
==========================================
- Coverage 16.54% 10.34% -6.21%
==========================================
Files 2 8 +6
Lines 284 2020 +1736
Branches 79 0 -79
==========================================
+ Hits 47 209 +162
- Misses 237 1811 +1574
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Ansible 2.20 has deprecated the use of Ansible facts as variables. For
example,
ansible_distributionis now deprecated in favor ofansible_facts["distribution"]. This is due to making the defaultsetting
INJECT_FACTS_AS_VARS=false. For now, this will create WARNINGmessages, but in Ansible 2.24 it will be an error.
See https://docs.ansible.com/projects/ansible/latest/porting_guides/porting_guide_core_2.20.html#inject-facts-as-vars
Signed-off-by: Rich Megginson rmeggins@redhat.com
Summary by Sourcery
Update role variables, tasks, and tests to use the ansible_facts dictionary instead of legacy fact variables for compatibility with newer Ansible versions.
Enhancements:
Tests: