raid-array: Add PB to create md arrays

The `raid-array.yml` playbook can create Linux *md* software RAID arrays
using the `mdadm` command.  Two variables are required: `md_name` and
`raid_disks`.  The former is a string name for the array.  The latter is
an array of paths of block devices to add to the array.
frigate-exporter
Dustin 2024-09-01 08:55:10 -05:00
parent b6cc83ad82
commit 459d58bfb6
1 changed files with 31 additions and 0 deletions

31
raid-array.yml Normal file
View File

@ -0,0 +1,31 @@
- hosts: minio-backups
gather_facts: true
tasks:
- name: ensure mdadm is installed
package:
name: mdadm
state: present
tags:
- install
- name: ensure usb hdd partitions are removed
command:
wipefs -fa {{ item }}
args:
removes: '{{ item }}-part1'
loop: '{{ raid_disks }}'
tags:
- wipefs
- name: ensure md raid array exists
command: >-
systemd-cat -t mdadm
mdadm --create --run
--name={{ md_name }}
--level=raid1
--raid-devices=2
/dev/md/{{ md_name }}
{{ raid_disks | join(' ') }}
args:
creates: /dev/disk/by-id/md-name-{{ md_name }}
tags:
- mdadm
- mdadm-create