--- - 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 }}"