--- - name: Determine additional disks to auto-mount ansible.builtin.set_fact: partitioning_extra_disks: >- {{ (system_cfg.disks | default([]))[1:] | selectattr('mount.path') | list }} - name: Validate additional disks do not target install_drive when: partitioning_extra_disks | length > 0 ansible.builtin.assert: that: - item.device is defined - item.device | string | length > 0 - item.device != install_drive - item.partition is defined - item.partition | string | length > 0 - 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 }}" loop_control: label: "{{ item | to_json }}" - name: Partition additional disks when: partitioning_extra_disks | length > 0 community.general.parted: device: "{{ item.device }}" label: gpt number: 1 part_start: "1MiB" part_end: "100%" name: "{{ (item.mount.label | default('') | string | length > 0) | ternary(item.mount.label, 'data') }}" state: present loop: "{{ partitioning_extra_disks }}" loop_control: label: "{{ item.device }}" - name: Settle partition tables for additional disks when: partitioning_extra_disks | length > 0 ansible.builtin.command: udevadm settle changed_when: false - name: Create filesystems on additional disks when: partitioning_extra_disks | length > 0 vars: _label_opt: "{{ ('-L ' ~ item.mount.label) if (item.mount.label | default('') | string | length) > 0 else '' }}" _compat_opt: "{{ '-m bigtime=0 -i nrext64=0,exchange=0 -n parent=0' if (is_rhel | bool and item.mount.fstype == 'xfs') else '' }}" _all_opts: "{{ ([_label_opt, _compat_opt] | select | join(' ')) or omit }}" community.general.filesystem: dev: "{{ item.partition }}" fstype: "{{ item.mount.fstype }}" opts: "{{ _all_opts }}" loop: "{{ partitioning_extra_disks }}" loop_control: label: "{{ item.partition }}" - name: Collect extra disk UUIDs when: partitioning_extra_disks | length > 0 ansible.builtin.command: "blkid -s UUID -o value {{ item.partition }}" register: partitioning_extra_disk_uuids changed_when: false loop: "{{ partitioning_extra_disks }}" loop_control: label: "{{ item.partition }}" - name: Ensure mount directories exist for additional disks when: partitioning_extra_disks | length > 0 ansible.builtin.file: path: "/mnt{{ item.mount.path }}" state: directory owner: root group: root mode: "0755" loop: "{{ partitioning_extra_disks }}" loop_control: label: "{{ item.mount.path }}" - name: Mount additional disks for fstab generation when: partitioning_extra_disks | length > 0 ansible.posix.mount: path: "/mnt{{ item.0.mount.path }}" src: "UUID={{ item.1.stdout }}" fstype: "{{ item.0.mount.fstype }}" opts: "{{ item.0.mount.opts | default('defaults') }}" state: mounted loop: "{{ partitioning_extra_disks | zip(partitioning_extra_disk_uuids.results) | list }}" loop_control: label: "{{ item.0.mount.path }}"