From 459d58bfb6e7250df659f7d011d12d6c80284a70 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 1 Sep 2024 08:55:10 -0500 Subject: [PATCH] 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. --- raid-array.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 raid-array.yml diff --git a/raid-array.yml b/raid-array.yml new file mode 100644 index 0000000..c8317f4 --- /dev/null +++ b/raid-array.yml @@ -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