summaryrefslogtreecommitdiff
path: root/roles/storage/mdadm/device/tasks/main.yml
blob: 338f26f79a5eb606984246cd5ff5ca5c39e0108f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 }}"