Execution
Date 11 Sep 2025 13:57:17 +0100
Duration 00:00:03.54
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.3 / 1.7.3
Python 3.10.10
Summary
1 Hosts
5 Tasks
5 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/find_snowflakes_repos.yaml

---
- name: Check for Third-Party Yum/DNF Repositories
  hosts: all
  become: true
  gather_facts: false
  vars:
    # These are the standard, expected repository IDs for AlmaLinux 8 and EPEL.
    # The 'crb' repo is the new name for 'powertools' in later 8.x versions.
    # We include both to be safe.
    allowed_repos:
      - appstream
      - baseos
      - extras
      - ha
      - powertools
      - crb
      - epel
      - epel-modular

  tasks:
    - name: Get list of enabled repositories
      ansible.builtin.shell: |
        set -o pipefail
        dnf repolist --enabled | awk 'NR>1 {print $1}'
      args:
        executable: /bin/bash
      changed_when: false
      register: enabled_repos_raw
      check_mode: false

    - name: Create a list of enabled repo IDs
      ansible.builtin.set_fact:
        enabled_repos_list: "{{ enabled_repos_raw.stdout_lines }}"

    - name: Identify any non-standard repositories
      ansible.builtin.set_fact:
        third_party_repos: "{{ enabled_repos_list | difference(allowed_repos) }}"

    - name: Assemble report data
      ansible.builtin.set_fact:
        repo_report:
          hostname: "{{ inventory_hostname }}"
          status: "{% if third_party_repos | length > 0 %}non-compliant{% else %}compliant{% endif %}"
          third_party_repos: "{{ third_party_repos }}"
          all_enabled_repos: "{{ enabled_repos_list }}"
      check_mode: false

    - name: Output report in JSON format
      ansible.builtin.debug:
        msg: "{{ repo_report | to_json }}"