/
/
/
1---
2# ============================================================================
3# Storage Management - Manual RAID5 Assumed
4# ============================================================================
5# This task assumes you have manually configured mdadm RAID5 and mounted it
6# at /mnt/rstorage. It only handles subdirectory creation and verification.
7# ============================================================================
8
9- name: Verify base storage mount point exists and is accessible
10 stat:
11 path: "{{ nas_storage_base | default('/mnt/rstorage') }}"
12 register: storage_base_check
13
14- name: Fail if base storage mount is not accessible
15 fail:
16 msg: |
17 Base storage directory {{ nas_storage_base | default('/mnt/rstorage') }} is not accessible!
18
19 Please ensure your mdadm RAID5 array is:
20 1. Properly assembled: mdadm --assemble --scan
21 2. Mounted at: {{ nas_storage_base | default('/mnt/rstorage') }}
22 3. Accessible by root
23
24 Check with:
25 cat /proc/mdstat
26 df -h {{ nas_storage_base | default('/mnt/rstorage') }}
27 when: not storage_base_check.stat.exists
28
29- name: Verify base storage is mounted (not just a directory)
30 shell: "mountpoint {{ nas_storage_base | default('/mnt/rstorage') }}"
31 register: storage_mount_check
32 changed_when: false
33 failed_when: false
34
35- name: Warning if storage base is not a mount point
36 debug:
37 msg: |
38 â ï¸ WARNING: {{ nas_storage_base | default('/mnt/rstorage') }} exists but is not a mount point!
39 This might be just a directory instead of your RAID5 mount.
40
41 Verify your RAID5 is properly mounted:
42 cat /proc/mdstat
43 lsblk
44 mount | grep rstorage
45 when: storage_mount_check.rc != 0
46
47- name: Display storage mount information
48 shell: |
49 echo "=== Storage Mount Information ==="
50 df -h {{ nas_storage_base | default('/mnt/rstorage') }}
51 echo ""
52 echo "=== RAID Status ==="
53 cat /proc/mdstat
54 echo ""
55 echo "=== Mount Point Status ==="
56 mountpoint {{ nas_storage_base | default('/mnt/rstorage') }} && echo "â
Properly mounted" || echo "â ï¸ Not a mount point"
57 register: storage_info
58 changed_when: false
59 failed_when: false
60
61- name: Show storage information
62 debug:
63 msg: "{{ storage_info.stdout_lines }}"
64
65- name: Create NAS storage subdirectories
66 file:
67 path: "{{ item }}"
68 state: directory
69 mode: '0755'
70 owner: root
71 group: root
72 loop: "{{ nas_storage_directories | default([]) }}"
73 become: true
74 when:
75 - nas_storage_directories is defined
76 - nas_storage_directories | length > 0
77
78- name: Display storage directory status
79 debug:
80 msg: |
81 {% if nas_storage_directories | default([]) | length > 0 %}
82 â
Created storage directories: {{ nas_storage_directories | join(', ') }}
83 {% else %}
84 â¹ï¸ No predefined storage directories configured.
85 You can create directories manually or add them to nas_storage_directories in host_vars/storage.yml
86 {% endif %}