From e5cc6f8990e82b92bc489c701f849120ec23f2fa Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 22 Feb 2021 16:56:05 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables See https://github.com/ansible/ansible/issues/73654 Change-Id: I5a83a7f237e4b7d86e8d7ee08b0e8c6b4f8a44f8 --- defaults/main.yml | 2 +- tasks/main.yml | 12 ++++++------ tasks/systemd_install.yml | 6 +++--- tests/test-create-nfs-dev.yml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index a87acdd..6175699 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,7 +15,7 @@ # EPEL repo is required for s3fs package. It won't be added in case s3fs is not required. systemd_centos_epel_mirror: "{{ centos_epel_mirror | default('http://download.fedoraproject.org/pub/epel') }}" -systemd_centos_epel_key: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_distribution_major_version) }}" +systemd_centos_epel_key: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_facts['distribution_major_version']) }}" # Any optioned required to make the mount point work. If no options are # provided the default will be used. This list is comma separted. diff --git a/tasks/main.yml b/tasks/main.yml index e5c333d..3ea0172 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,12 +16,12 @@ - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" tags: - always diff --git a/tasks/systemd_install.yml b/tasks/systemd_install.yml index 8a3ae9a..4ddd926 100644 --- a/tasks/systemd_install.yml +++ b/tasks/systemd_install.yml @@ -16,7 +16,7 @@ - name: Install EPEL when: - "'s3fs' in systemd_mount_types" - - ansible_os_family | lower == 'redhat' + - ansible_facts['os_family'] | lower == 'redhat' block: - name: Download EPEL gpg keys get_url: @@ -35,8 +35,8 @@ - name: Install the EPEL repository yum_repository: name: epel-systemd_mounts - baseurl: "{{ systemd_centos_epel_mirror ~ '/' ~ ansible_distribution_major_version ~ (ansible_distribution_major_version is version('8', '>=')) | ternary('/Everything/', '/') ~ ansible_architecture }}" - description: 'Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - $basearch' + baseurl: "{{ systemd_centos_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ (ansible_facts['distribution_major_version'] is version('8', '>=')) | ternary('/Everything/', '/') ~ ansible_facts['architecture'] }}" + description: "Extra Packages for Enterprise Linux {{ ansible_facts['distribution_major_version'] }} - $basearch" gpgcheck: yes enabled: yes state: present diff --git a/tests/test-create-nfs-dev.yml b/tests/test-create-nfs-dev.yml index 93ba305..9de4805 100644 --- a/tests/test-create-nfs-dev.yml +++ b/tests/test-create-nfs-dev.yml @@ -21,7 +21,7 @@ tasks: - name: Install NFS packages package: - name: "{{ nfs_package[ansible_distribution.split()[0] | lower] }}" + name: "{{ nfs_package[ansible_facts['distribution'].split()[0] | lower] }}" state: present - name: create the system group for nfs