diff --git a/README-ostree.md b/README-ostree.md index a9f0185b..77d81b4a 100644 --- a/README-ostree.md +++ b/README-ostree.md @@ -20,8 +20,8 @@ Usage: .ostree/get_ostree_data.sh packages runtime DISTRO-VERSION FORMAT ``` -`DISTRO-VERSION` is in the format that Ansible uses for `ansible_distribution` -and `ansible_distribution_version` - for example, `Fedora-38`, `CentOS-8`, +`DISTRO-VERSION` is in the format that Ansible uses for `ansible_facts['distribution']` +and `ansible_facts['distribution_version']` - for example, `Fedora-38`, `CentOS-8`, `RedHat-9.4` `FORMAT` is one of `toml`, `json`, `yaml`, `raw` diff --git a/README.md b/README.md index 3ddcadb6..5e476bab 100644 --- a/README.md +++ b/README.md @@ -486,7 +486,7 @@ To configure the private key of the logging system, `private_key_src` and/or `pr #### logging_domain -The default DNS domain used to accept remote incoming logs from remote hosts. Default to "{{ ansible_domain if ansible_domain else ansible_hostname }}" +The default DNS domain used to accept remote incoming logs from remote hosts. Default to "{{ ansible_facts['domain'] if ansible_facts['domain'] else ansible_facts['hostname'] }}" ### Server performance optimization options diff --git a/defaults/main.yml b/defaults/main.yml index 19c06313..f575734c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -79,7 +79,7 @@ logging_pki_files: [] # logging_domain # # The default DNS domain used to accept remote incoming logs from remote hosts. -logging_domain: '{{ ansible_domain if ansible_domain else ansible_hostname }}' +logging_domain: '{{ ansible_facts["domain"] if ansible_facts["domain"] else ansible_facts["hostname"] }}' # logging_elasticsearch_password # @@ -125,17 +125,26 @@ logging_custom_templates: [] # ansible_facts required by the role __logging_required_facts: + - default_ipv4 # requires the iproute package for the ip command - distribution - distribution_major_version - distribution_version + - domain + - fqdn + - hostname - os_family - - default_ipv4 # requires the iproute package for the ip command + - pkg_mgr + +__logging_no_subsets_facts: + - domain + - fqdn + - hostname # 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 __logging_required_facts_subsets: "{{ ['!all', '!min'] + - __logging_required_facts }}" + __logging_required_facts | difference(__logging_no_subsets_facts) }}" # BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables # Ansible distribution identifiers that the role treats like RHEL @@ -149,8 +158,8 @@ __logging_rh_distros: __logging_rh_distros_fedora: "{{ __logging_rh_distros + ['Fedora'] }}" # Use this in conditionals to check if distro is Red Hat or clone -__logging_is_rh_distro: "{{ ansible_distribution in __logging_rh_distros }}" +__logging_is_rh_distro: "{{ ansible_facts['distribution'] in __logging_rh_distros }}" # Use this in conditionals to check if distro is Red Hat or clone, or Fedora -__logging_is_rh_distro_fedora: "{{ ansible_distribution in __logging_rh_distros_fedora }}" +__logging_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __logging_rh_distros_fedora }}" # END - DO NOT EDIT THIS BLOCK - rh distros variables diff --git a/roles/rsyslog/tasks/main_core.yml b/roles/rsyslog/tasks/main_core.yml index 87eafe63..4a79da5d 100644 --- a/roles/rsyslog/tasks/main_core.yml +++ b/roles/rsyslog/tasks/main_core.yml @@ -24,7 +24,7 @@ - name: Reset original confs - logging package is absent # we can't do this with "package", dnf5 does not remove reverse # dependencies (such as rsyslog-gnutls) any more - command: "{{ ansible_pkg_mgr }} remove -y {{ __rsyslog_only_packages | join(' ') }}" + command: "{{ ansible_facts['pkg_mgr'] }} remove -y {{ __rsyslog_only_packages | join(' ') }}" # we know it's a change here, as we just rpm -V'ed it above changed_when: true register: __rsyslog_erased diff --git a/roles/rsyslog/templates/input_ovirt.j2 b/roles/rsyslog/templates/input_ovirt.j2 index a2ffa01a..8eb88619 100644 --- a/roles/rsyslog/templates/input_ovirt.j2 +++ b/roles/rsyslog/templates/input_ovirt.j2 @@ -54,9 +54,9 @@ if $syslogtag == "{{ __rsyslog_input.name }}" then { set $!service = $syslogtag; set $!message = $.ovirt!message; set $!level = $.ovirt!level; - set $!hostname = '{{ ansible_fqdn }}'; + set $!hostname = '{{ ansible_facts["fqdn"] }}'; set $!ovirt!cluster_name = '{{ __ovirt_vds_cluster_name }}'; - set $!ipaddr4 = '{{ ansible_default_ipv4.address }}'; + set $!ipaddr4 = '{{ ansible_facts["default_ipv4"]["address"] }}'; set $!ovirt!engine_fqdn = '{{ __ovirt_engine_fqdn }}'; set $.input_type = "ovirt"; set $!ovirt!class = $.ovirt!class; diff --git a/roles/rsyslog/templates/input_relp.j2 b/roles/rsyslog/templates/input_relp.j2 index 0e161ffb..f7071cff 100644 --- a/roles/rsyslog/templates/input_relp.j2 +++ b/roles/rsyslog/templates/input_relp.j2 @@ -1,8 +1,8 @@ input(name="{{ __rsyslog_input.name }}" type="imrelp" port="{{ __rsyslog_input.port | d(20514) | int }}" -{% if ansible_distribution in ['CentOS', 'RedHat'] and - ansible_distribution_major_version is version('7', '>') %} +{% if ansible_facts['distribution'] in ['CentOS', 'RedHat'] and + ansible_facts['distribution_major_version'] is version('7', '>') %} maxDataSize="{{ __rsyslog_input.max_data_size | d(logging_max_message_size) | int }}" {% endif %} {% if __rsyslog_input.tls | default(true) %} diff --git a/tests/tests_combination.yml b/tests/tests_combination.yml index 5c342170..55c40c45 100644 --- a/tests/tests_combination.yml +++ b/tests/tests_combination.yml @@ -55,8 +55,8 @@ input_log_path: "{{ __test_inputfiles_dir }}/*.log" # Not supported on EL 7 endmsg_regex: "{{ omit - if ansible_distribution in ['CentOS', 'RedHat'] and - ansible_distribution_major_version is version('7', '==') + if ansible_facts['distribution'] in ['CentOS', 'RedHat'] and + ansible_facts['distribution_major_version'] is version('7', '==') else 'xyz' }}" - name: basic_input type: basics diff --git a/tests/tests_include_vars_from_parent.yml b/tests/tests_include_vars_from_parent.yml index c5d5cd09..5408cd4d 100644 --- a/tests/tests_include_vars_from_parent.yml +++ b/tests/tests_include_vars_from_parent.yml @@ -30,10 +30,10 @@ # create all variants like CentOS, CentOS_8.1, CentOS-8.1, # CentOS-8, CentOS-8.1 # more formally: - # {{ ansible_distribution }}-{{ ansible_distribution_version }} - # {{ ansible_distribution }}-{{ ansible_distribution_major_version }} - # {{ ansible_distribution }} - # {{ ansible_os_family }} + # {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }} + # {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }} + # {{ ansible_facts['distribution'] }} + # {{ ansible_facts['os_family'] }} # and the same for _ as separator. varfiles: "{{ [facts['distribution']] | product(separators) | map('join') | product(versions) | map('join') | list + diff --git a/tests/tests_relp.yml b/tests/tests_relp.yml index 46f43ca3..250e42a0 100644 --- a/tests/tests_relp.yml +++ b/tests/tests_relp.yml @@ -190,8 +190,8 @@ register: __result failed_when: __result.stdout != "1" when: - - ansible_distribution in ['CentOS', 'RedHat'] - - ansible_distribution_major_version is version('7', '>') + - ansible_facts['distribution'] in ['CentOS', 'RedHat'] + - ansible_facts['distribution_major_version'] is version('7', '>') - name: Check preserveFQDN is on command: grep -c 'preserveFQDN="on"' {{ __test_relp_global }} diff --git a/tests/vars/rh_distros_vars.yml b/tests/vars/rh_distros_vars.yml index e0d0c8cc..83fe0d4d 100644 --- a/tests/vars/rh_distros_vars.yml +++ b/tests/vars/rh_distros_vars.yml @@ -14,7 +14,7 @@ __logging_rh_distros: __logging_rh_distros_fedora: "{{ __logging_rh_distros + ['Fedora'] }}" # Use this in conditionals to check if distro is Red Hat or clone -__logging_is_rh_distro: "{{ ansible_distribution in __logging_rh_distros }}" +__logging_is_rh_distro: "{{ ansible_facts['distribution'] in __logging_rh_distros }}" # Use this in conditionals to check if distro is Red Hat or clone, or Fedora -__logging_is_rh_distro_fedora: "{{ ansible_distribution in __logging_rh_distros_fedora }}" +__logging_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __logging_rh_distros_fedora }}"