-
Notifications
You must be signed in to change notification settings - Fork 11
refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead #157
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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors Ansible variable usage to rely on the ansible_facts dictionary instead of injected fact variables, updating role variables, templates, tests, and documentation to be compatible with INJECT_FACTS_AS_VARS=false and Ansible 2.20+ deprecations. Flow diagram for updated use of ansible_facts in PostgreSQL roleflowchart TD
AnsiblePlaybook[Ansible playbook] --> GatherFacts[Gather facts]
GatherFacts --> ansible_facts[ansible_facts dict]
ansible_facts --> RequiredFactsVars[Set __postgresql_required_facts using ansible_facts keys]
ansible_facts --> NoSubsetFactsVars[Set __postgresql_no_subset_facts using memory_mb]
RequiredFactsVars --> CheckRequiredFacts[Check required facts present]
NoSubsetFactsVars --> CheckRequiredFacts
CheckRequiredFacts -->|missing distribution or memory_mb| FailTask[Fail task or gather extra subsets]
CheckRequiredFacts -->|all present| UseFacts[Use ansible_facts in role]
UseFacts --> DistroFlags[Compute __postgresql_is_rh_distro and __postgresql_is_rh_distro_fedora from ansible_facts.distribution]
UseFacts --> TuningTemplate[Render postgresql-internal.conf.j2 using ansible_facts.memory_mb]
DistroFlags --> RoleConditionals[Role conditionals based on distro]
TuningTemplate --> PostgresqlConf[postgresql-internal.conf]
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 left some high level feedback:
- The PR mixes bracket and attribute access for facts (e.g.,
ansible_facts['distribution']vsansible_facts.memory_mb); consider standardizing on one style (typically bracket access) for consistency and to avoid surprises with complex or nested facts. - In
tests/tests_include_vars_from_parent.yml, the comment now refers toansible_facts['distribution']while the actual expression still usesfacts['distribution']; consider aligning the comment with the implementation to avoid confusion for future readers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The PR mixes bracket and attribute access for facts (e.g., `ansible_facts['distribution']` vs `ansible_facts.memory_mb`); consider standardizing on one style (typically bracket access) for consistency and to avoid surprises with complex or nested facts.
- In `tests/tests_include_vars_from_parent.yml`, the comment now refers to `ansible_facts['distribution']` while the actual expression still uses `facts['distribution']`; consider aligning the comment with the implementation to avoid confusion for future readers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…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>
75fb4b7 to
6db6272
Compare
|
[citest] |
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 Ansible role and tests to use the new ansible_facts-based fact access instead of legacy fact variables for compatibility with INJECT_FACTS_AS_VARS=false.
Enhancements:
Documentation:
Tests: