repos

Role Documentation

Welcome to the “repos” role documentation.

Role Variables: main.yml

metadata:
  description: 'Detect whether the repositories listed in `yum repolist` can be connected
    to and that there is at least one repo configured.

    Detect if there are any unwanted repositories (such as EPEL) enabled.

    '
  groups:
  - pre-upgrade
  name: Check correctness of current repositories

Molecule Scenarios

Molecule is being used to test the “repos” role. The following section highlights the drivers in service and provides an example playbook showing how the role is leveraged.

Scenario: default

Example default configuration
driver:
  name: podman
log: true
platforms:
- dockerfile: ../../../../.config/molecule/Dockerfile
  environment:
    http_proxy: '{{ lookup(''env'', ''http_proxy'') }}'
    https_proxy: '{{ lookup(''env'', ''https_proxy'') }}'
  hostname: centos
  image: centos/centos:stream8
  name: centos
  pkg_extras: python*-setuptools python*-pyyaml
  privileged: true
  registry:
    url: quay.io
  ulimits:
  - host
  volumes:
  - /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
provisioner:
  env:
    ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}
    ANSIBLE_ROLES_PATH: ${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles
    ANSIBLE_STDOUT_CALLBACK: yaml
  inventory:
    hosts:
      all:
        hosts:
          centos:
            ansible_python_interpreter: /usr/bin/python3
  log: true
  name: ansible
  options:
    vvv: true
scenario:
  test_sequence:
  - destroy
  - create
  - prepare
  - converge
  - verify
  - destroy
verifier:
  name: ansible
Molecule Inventory
hosts:
  all:
    hosts:
      centos:
        ansible_python_interpreter: /usr/bin/python3
Example default playbook
- hosts: all
  name: Converge
  tasks:
  - include_role:
      name: repos
    name: test role without failure
  - block:
    - name: inject faulty repository
      yum_repository:
        baseurl: http://this.repository.do-not.exists/like-not-at-all
        description: really faulty repository
        enabled: true
        name: faulty
    - include_role:
        name: repos
      name: execute role
    name: run with failure
    rescue:
    - meta: clear_host_errors
      name: clean host error
    - debug:
        msg: Successfully detected first broken repository
      name: Molecule output
  - block:
    - name: remove faulty repository
      yum_repository:
        name: faulty
        state: absent
    - name: push another faulty repository with working DNS
      yum_repository:
        baseurl: http://download.fedoraproject.org/pub/fedora/blah
        description: faulty repository with working DNS
        enabled: true
        name: faulty-bis
    - include_role:
        name: repos
      name: execute role
    name: run with another failure
    rescue:
    - meta: clear_host_errors
      name: clean host error
    - debug:
        msg: Successfully detected second faulty repository. Exiting!
      name: Molecule output
    - meta: end_play
      name: End play
  - fail:
      msg: 'The repos validation failed detecting broken/non-working repository

        '
    name: Fail the test