diff options
Diffstat (limited to 'roles/storage/mdadm/device')
-rw-r--r-- | roles/storage/mdadm/device/defaults/main.yml | 9 | ||||
-rw-r--r-- | roles/storage/mdadm/device/handlers/main.yml | 3 | ||||
-rw-r--r-- | roles/storage/mdadm/device/tasks/main.yml | 23 |
3 files changed, 35 insertions, 0 deletions
diff --git a/roles/storage/mdadm/device/defaults/main.yml b/roles/storage/mdadm/device/defaults/main.yml new file mode 100644 index 00000000..d2672a8b --- /dev/null +++ b/roles/storage/mdadm/device/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# mdadm_volume: +# name: mdfoobar +# level: 1 +# devices: +# - /dev/disk/by-id/foo +# - /dev/disk/by-id/bar + +mdadm_device: "{{ storage_device }}" diff --git a/roles/storage/mdadm/device/handlers/main.yml b/roles/storage/mdadm/device/handlers/main.yml new file mode 100644 index 00000000..f967fa86 --- /dev/null +++ b/roles/storage/mdadm/device/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: rebuild initramfs + command: update-initramfs -u diff --git a/roles/storage/mdadm/device/tasks/main.yml b/roles/storage/mdadm/device/tasks/main.yml new file mode 100644 index 00000000..338f26f7 --- /dev/null +++ b/roles/storage/mdadm/device/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: create array + command: "mdadm --create /dev/md/{{ mdadm_device.name }} --metadata default --level {{ mdadm_device.level }} --raid-devices {{ mdadm_device.devices | length }} {{ mdadm_device.devices | join(' ') }}" + args: + creates: "/dev/md/{{ mdadm_device.name }}" + +- name: fetch UUID of array + command: "mdadm --detail --scan /dev/md/{{ mdadm_device.name }}" + changed_when: false + check_mode: no + register: mdadm_device_uuid + +- name: udpate mdadm.conf + lineinfile: + path: /etc/mdadm/mdadm.conf + regexp: '^ARRAY /dev/md/{{ mdadm_device.name }} ' + line: "{{ mdadm_device_uuid.stdout_lines | first }}" + insertafter: "# definitions of existing MD arrays" + notify: rebuild initramfs + +- name: export device path + set_fact: + storage_device_path: "/dev/md/{{ mdadm_device.name }}" |