feat(disks): add standardized multi-disk mount schema
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
partitioning_extra_disks: >-
|
||||
{{
|
||||
(system_cfg.disks | default([]))[1:]
|
||||
| selectattr('mount')
|
||||
| selectattr('mount.path')
|
||||
| list
|
||||
}}
|
||||
changed_when: false
|
||||
@@ -18,12 +18,12 @@
|
||||
- item.device != install_drive
|
||||
- item.partition is defined
|
||||
- item.partition | string | length > 0
|
||||
- item.fstype is defined
|
||||
- item.fstype in ['btrfs', 'ext4', 'xfs']
|
||||
- item.mount is defined
|
||||
- item.mount | string | length > 0
|
||||
- item.mount.startswith('/')
|
||||
- item.mount != '/'
|
||||
- item.mount.fstype is defined
|
||||
- item.mount.fstype in ['btrfs', 'ext4', 'xfs']
|
||||
- item.mount.path is defined
|
||||
- item.mount.path | string | length > 0
|
||||
- item.mount.path.startswith('/')
|
||||
- item.mount.path != '/'
|
||||
fail_msg: "Invalid additional disk definition: {{ item | to_json }}"
|
||||
quiet: true
|
||||
loop: "{{ partitioning_extra_disks }}"
|
||||
@@ -38,7 +38,7 @@
|
||||
number: 1
|
||||
part_start: "1MiB"
|
||||
part_end: "100%"
|
||||
name: "{{ (item.label | default('') | string | length > 0) | ternary(item.label, 'data') }}"
|
||||
name: "{{ (item.mount.label | default('') | string | length > 0) | ternary(item.mount.label, 'data') }}"
|
||||
state: present
|
||||
loop: "{{ partitioning_extra_disks }}"
|
||||
loop_control:
|
||||
@@ -53,8 +53,8 @@
|
||||
when: partitioning_extra_disks | length > 0
|
||||
community.general.filesystem:
|
||||
dev: "{{ item.partition }}"
|
||||
fstype: "{{ item.fstype }}"
|
||||
opts: "{{ ('-L ' ~ item.label) if (item.label | default('') | string | length) > 0 else omit }}"
|
||||
fstype: "{{ item.mount.fstype }}"
|
||||
opts: "{{ ('-L ' ~ item.mount.label) if (item.mount.label | default('') | string | length) > 0 else omit }}"
|
||||
force: true
|
||||
loop: "{{ partitioning_extra_disks }}"
|
||||
loop_control:
|
||||
@@ -63,23 +63,23 @@
|
||||
- name: Ensure mount directories exist for additional disks
|
||||
when: partitioning_extra_disks | length > 0
|
||||
ansible.builtin.file:
|
||||
path: "/mnt{{ item.mount }}"
|
||||
path: "/mnt{{ item.mount.path }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
loop: "{{ partitioning_extra_disks }}"
|
||||
loop_control:
|
||||
label: "{{ item.mount }}"
|
||||
label: "{{ item.mount.path }}"
|
||||
|
||||
- name: Mount additional disks for fstab generation
|
||||
when: partitioning_extra_disks | length > 0
|
||||
ansible.posix.mount:
|
||||
path: "/mnt{{ item.mount }}"
|
||||
path: "/mnt{{ item.mount.path }}"
|
||||
src: "{{ item.partition }}"
|
||||
fstype: "{{ item.fstype }}"
|
||||
opts: "{{ item.opts | default('defaults') }}"
|
||||
fstype: "{{ item.mount.fstype }}"
|
||||
opts: "{{ item.mount.opts | default('defaults') }}"
|
||||
state: mounted
|
||||
loop: "{{ partitioning_extra_disks }}"
|
||||
loop_control:
|
||||
label: "{{ item.mount }}"
|
||||
label: "{{ item.mount.path }}"
|
||||
|
||||
Reference in New Issue
Block a user