-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead #76
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 <[email protected]>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors Ansible variable usage in RedHat vars files to use the new ansible_facts syntax for architecture, ensuring compatibility with INJECT_FACTS_AS_VARS=false and avoiding deprecation warnings in Ansible 2.20+. 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, and left some high level feedback:
- Given the move to
ansible_facts['architecture']here, it would be good to double-check other vars/roles for remaining bare fact usages (e.g.,ansible_architecture) to keep the deprecation handling consistent across the codebase. - In
vars/RedHat_10.ymlthe repo id still referencesrhel-9(preexisting), which might be unintended for a RHEL 10-specific vars file and worth verifying while touching this area.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Given the move to `ansible_facts['architecture']` here, it would be good to double-check other vars/roles for remaining bare fact usages (e.g., `ansible_architecture`) to keep the deprecation handling consistent across the codebase.
- In `vars/RedHat_10.yml` the repo id still references `rhel-9` (preexisting), which might be unintended for a RHEL 10-specific vars file and worth verifying while touching this area.
## Individual Comments
### Comment 1
<location> `vars/RedHat_10.yml:4` </location>
<code_context>
---
__gfs2_repos:
- - id: rhel-9-for-{{ ansible_architecture }}-resilientstorage-rpms
+ - id: rhel-9-for-{{ ansible_facts['architecture'] }}-resilientstorage-rpms
name: Resilient Storage
</code_context>
<issue_to_address>
**issue (bug_risk):** Repo id for RedHat_10 still references rhel-9, which is likely incorrect.
In the RedHat_10 vars file, this repo id still uses the `rhel-9-for-...` prefix, which is probably a copy/paste error and may point RHEL 10 hosts at the wrong channel. Please update this to the correct RHEL 10 repo id (e.g. `rhel-10-for-...`).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| --- | ||
| __gfs2_repos: | ||
| - id: rhel-9-for-{{ ansible_architecture }}-resilientstorage-rpms | ||
| - id: rhel-9-for-{{ ansible_facts['architecture'] }}-resilientstorage-rpms |
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.
issue (bug_risk): Repo id for RedHat_10 still references rhel-9, which is likely incorrect.
In the RedHat_10 vars file, this repo id still uses the rhel-9-for-... prefix, which is probably a copy/paste error and may point RHEL 10 hosts at the wrong channel. Please update this to the correct RHEL 10 repo id (e.g. rhel-10-for-...).
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 [email protected]
Summary by Sourcery
Enhancements: