raid-array: Create udev rules to auto re-add disks

This udev rule will automatically re-add disks to the RAID array when
they are connected.  `mdadm --udev-rules` is supposed to be able to
generate such a rule based on the `POLICY` definitions in
`/etc/mdadm.conf`, but I was not able to get that to work; it always
printed an empty rule file, no matter what I put in `mdadm.conf`.
dynamic-inventory
Dustin 2024-11-05 06:52:20 -06:00
parent 168bfee911
commit abfd35a68e
1 changed files with 19 additions and 0 deletions

View File

@ -29,3 +29,22 @@
tags: tags:
- mdadm - mdadm
- mdadm-create - mdadm-create
- name: ensure raid auto re-add udev rule exists
copy:
content: >+
ENV{ID_FS_LABEL}=="{{ md_name }}",
ENV{ID_FS_TYPE}=="linux_raid_member",
ENV{ID_FS_USAGE}=="raid",
RUN+="/usr/sbin/mdadm --re-add /dev/disk/by-id/md-name-{{ md_name }} $devnode"
dest: /etc/udev/rules.d/80-{{ md_name }}.rules
mode: u=rw,go=r
owner: root
group: root
notify:
- reload udev
tags:
- udev
handlers:
- name: reload udev
command:
udevadm control --reload