Execution
Date 18 Mar 2026 11:19:21 +0000
Duration 00:00:02.86
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.13
ara 1.7.4 / 1.7.4
Python 3.10.10
Summary
1 Hosts
4 Tasks
4 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/zz-check-if-software-raid.yaml

---
- name: Check for Software RAID (mdadm) Status
  hosts: all
  gather_facts: false

  tasks:
    - name: Read /proc/mdstat content
      ansible.builtin.command: cat /proc/mdstat
      register: mdstat_result
      changed_when: false
      failed_when: false
    - name: Display RAID Status (Active Arrays Found)
      ansible.builtin.debug:
        msg:
          - "✅ Software RAID Detected on {{ inventory_hostname }}"
          - "--------------------------------------------------"
          - "{{ mdstat_result.stdout }}"
          - "--------------------------------------------------"
      when: "'md' in mdstat_result.stdout and 'Personalities' in mdstat_result.stdout"
    - name: Display No RAID Found
      ansible.builtin.debug:
        msg: "ℹ️  No active Software RAID arrays found on {{ inventory_hostname }}."
      when: "'md' not in mdstat_result.stdout or 'Personalities' not in mdstat_result.stdout"
    - name: Save RAID report locally
      ansible.builtin.copy:
        content: |
          Host: {{ inventory_hostname }}
          Timestamp: {{ ansible_date_time.iso8601 | default('N/A') }}
          {{ mdstat_result.stdout }}
        dest: "mdstat_{{ inventory_hostname }}.txt"
        mode: '0644'
      delegate_to: localhost
      when: "'md' in mdstat_result.stdout and 'Personalities' in mdstat_result.stdout"
      run_once: false