29 lines
1 KiB
YAML
29 lines
1 KiB
YAML
---
|
|
- name: RAID | Check whether array already exists
|
|
ansible.builtin.command: "mdadm --detail {{ gpu_model_storage_raid_device }}"
|
|
register: _md_detail
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: RAID | Create RAID1 array from partition 5 on each device
|
|
ansible.builtin.command: >
|
|
mdadm --create {{ gpu_model_storage_raid_device }}
|
|
--level=1 --raid-devices={{ gpu_model_storage_devices | length }}
|
|
--metadata=1.2 --run
|
|
{{ gpu_model_storage_devices | map('regex_replace', '$', '5') | join(' ') }}
|
|
when: _md_detail.rc != 0
|
|
|
|
- name: RAID | Read current mdadm scan output
|
|
ansible.builtin.command: mdadm --detail --scan
|
|
register: _mdadm_scan
|
|
changed_when: false
|
|
|
|
- name: RAID | Persist array definition in /etc/mdadm.conf
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/mdadm.conf
|
|
line: "{{ item }}"
|
|
regexp: "^ARRAY {{ gpu_model_storage_raid_device }} "
|
|
loop: "{{ _mdadm_scan.stdout_lines | select('search', gpu_model_storage_raid_device) | list }}"
|
|
loop_control:
|
|
label: "{{ gpu_model_storage_raid_device }}"
|