# 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_distribution == 'CentOS'
    - ansible_distribution_major_version == '6'
