Execution
Date 11 Sep 2025 13:03:05 +0100
Duration 00:00:29.35
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
44 Hosts
7 Tasks
219 Results
1 Plays
1 Files
0 Records

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

---
- name: Check for 3rd-party enabled repositories via bash script
  hosts: all
  become: true

  tasks:
    - name: Create temp directory for script
      ansible.builtin.file:
        path: /tmp/snowflake_check
        state: directory
        mode: '0700'

    - name: Upload snowflake detection script
      ansible.builtin.copy:
        src: find_snowflakes_repos.sh
        dest: /tmp/snowflake_check/find_snowflakes_repos
        mode: '0755'

    - name: Run snowflake detection script
      ansible.builtin.command: /tmp/snowflake_check/find_snowflakes_repos
      register: script_output
      changed_when: false

    - name: Cleanup script
      ansible.builtin.file:
        path: /tmp/snowflake_check
        state: absent

    - name: Register output for reporting
      ansible.builtin.set_fact:
        snowflake_result: "{{ script_output.stdout }}"

    - name: Aggregate all results (run once on first host)
      ansible.builtin.set_fact:
        all_results: >-
          {{
            (all_results | default([])) + [hostvars[item].snowflake_result]
          }}
      delegate_to: localhost
      run_once: true
      when: ansible_play_hosts_all.index(inventory_hostname) == 0
      loop: "{{ ansible_play_hosts_all }}"

    - name: Parse and display tabular report
      ansible.builtin.debug:
        msg: |
          {% set lines = all_results %}
          {% set data = [] %}
          {% for line in lines %}
          {%   set parts = line.split(',') %}
          {%   set host = parts[0].split(':')[1] %}
          {%   set snow = parts[1].split(':')[1] %}
          {%   set _ = data.append({'host': host, 'snowflakes': snow}) %}
          {% endfor %}
          {% set max_host_len = (data | map(attribute='host') | map('length') | max) + 2 %}
          {% set header_host = 'HOST' | center(max_host_len) %}
          {% set header_snow = 'THIRD-PARTY REPOS' %}
          {{ '=' * (max_host_len + 40) }}
          {{ header_host }} | {{ header_snow }}
          {{ '-' * (max_host_len + 40) }}
          {% for item in data %}
          {{ item.host | center(max_host_len) }} | {{ item.snowflakes }}
          {% endfor %}
          {{ '=' * (max_host_len + 40) }}
      delegate_to: localhost
      run_once: true
      when: ansible_play_hosts_all.index(inventory_hostname) == 0