-
Notifications
You must be signed in to change notification settings - Fork 35
refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead #314
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,14 +5,20 @@ __firewall_usr_lib_dir: /usr/lib/firewalld | |
|
|
||
| # ansible_facts required by the role | ||
| __firewall_required_facts: | ||
| - discovered_interpreter_python | ||
| - distribution_major_version | ||
| - distribution | ||
| - python_version | ||
| - service_mgr | ||
|
|
||
| __firewall_no_subsets_facts: | ||
| - discovered_interpreter_python | ||
|
|
||
| # the subsets of ansible_facts that need to be gathered in case any of the | ||
| # facts in required_facts is missing; see the documentation of | ||
| # the 'gather_subset' parameter of the 'setup' module | ||
| __firewall_required_facts_subsets: "{{ ['!all', '!min'] + | ||
| __firewall_required_facts }}" | ||
| __firewall_required_facts | difference(__firewall_no_subsets_facts) }}" | ||
|
Comment on lines
+14
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: The This expression depends on Jinja evaluating it as __firewall_required_facts_subsets: "{{ (['!all', '!min'] + __firewall_required_facts)
| difference(__firewall_no_subsets_facts) }}" |
||
|
|
||
| __firewall_packages_base: [firewalld] | ||
|
|
||
|
|
@@ -42,8 +48,8 @@ __firewall_rh_distros: | |
| __firewall_rh_distros_fedora: "{{ __firewall_rh_distros + ['Fedora'] }}" | ||
|
|
||
| # Use this in conditionals to check if distro is Red Hat or clone | ||
| __firewall_is_rh_distro: "{{ ansible_distribution in __firewall_rh_distros }}" | ||
| __firewall_is_rh_distro: "{{ ansible_facts['distribution'] in __firewall_rh_distros }}" | ||
|
|
||
| # Use this in conditionals to check if distro is Red Hat or clone, or Fedora | ||
| __firewall_is_rh_distro_fedora: "{{ ansible_distribution in __firewall_rh_distros_fedora }}" | ||
| __firewall_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __firewall_rh_distros_fedora }}" | ||
| # END - DO NOT EDIT THIS BLOCK - rh distros variables | ||
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.
suggestion: Indexing
ansible_facts['discovered_interpreter_python']directly may raise an error if the fact is unexpectedly missing.Inside
d(), this will fail outright ifdiscovered_interpreter_pythonisn’t inansible_facts. To make it more robust while preserving the new behavior, you could use: