mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-27 23:43:06 +00:00
use ansible_facts to reference facts
By default, Ansible injects a variable for every fact, prefixed with ansible_. This can result in a large number of variables for each host, which at scale can incur a performance penalty. Ansible provides a configuration option [0] that can be set to False to prevent this injection of facts. In this case, facts should be referenced via ansible_facts.. This change updates all references to Ansible facts from using individual fact variables to using the items in the ansible_facts dictionary. This allows users to disable fact variable injection in their Ansible configuration, which may provide some performance improvement. [0] https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
This commit is contained in:
parent
9d7cfc9661
commit
170b91c249
13 changed files with 28 additions and 28 deletions
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
- name: Check OS version and family
|
||||
ansible.builtin.assert:
|
||||
that: (ansible_distribution != 'CentOS' and ansible_os_family == 'RedHat' or ansible_os_family == "Rocky") and ansible_distribution_major_version is version_compare('9', '==')
|
||||
fail_msg: "This role can only be run against Supported OSs. {{ ansible_distribution }} {{ ansible_distribution_major_version }} is not supported."
|
||||
success_msg: "This role is running against a supported OS {{ ansible_distribution }} {{ ansible_distribution_major_version }}"
|
||||
that: (ansible_facts.distribution != 'CentOS' and ansible_facts.os_family == 'RedHat' or ansible_facts.os_family == "Rocky") and ansible_facts.distribution_major_version is version_compare('9', '==')
|
||||
fail_msg: "This role can only be run against Supported OSs. {{ ansible_facts.distribution }} {{ ansible_facts.distribution_major_version }} is not supported."
|
||||
success_msg: "This role is running against a supported OS {{ ansible_facts.distribution }} {{ ansible_facts.distribution_major_version }}"
|
||||
when:
|
||||
- os_check
|
||||
- not system_is_ec2
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
- system_is_container
|
||||
when:
|
||||
- ansible_connection == 'docker' or
|
||||
ansible_virtualization_type in ["docker", "lxc", "openvz", "podman", "container"]
|
||||
ansible_facts.virtualization_type in ["docker", "lxc", "openvz", "podman", "container"]
|
||||
tags:
|
||||
- container_discovery
|
||||
- always
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
- always
|
||||
|
||||
- name: Include OS specific variables
|
||||
ansible.builtin.include_vars: "{{ ansible_distribution }}.yml"
|
||||
ansible.builtin.include_vars: "{{ ansible_facts.distribution }}.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue