network/tests/tasks/el_repo_setup.yml
Rich Megginson 39ac91d9af refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead
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>
2026-01-07 18:43:15 -05:00

52 lines
1.5 KiB
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
- name: Gather the minimum subset of ansible_facts required by the network
role test
setup:
gather_subset: min
when: not ansible_facts.keys() | list |
intersect(network_test_required_facts) == network_test_required_facts
vars:
network_test_required_facts:
- distribution
- distribution_major_version
- distribution_version
- os_family
- name: Determine if system is ostree and set flag
when: not __network_is_ostree is defined
block:
- name: Check if system is ostree
stat:
path: /run/ostree-booted
register: __ostree_booted_stat
- name: Set flag to indicate system is ostree
set_fact:
__network_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
- name: Fix CentOS6 Base repo
copy:
dest: /etc/yum.repos.d/CentOS-Base.repo
content: |
[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
mode: "0644"
when:
- ansible_facts['distribution'] == 'CentOS'
- ansible_facts['distribution_major_version'] == '6'