--- - name: Configure disk partitions and mounts hosts: all become: true gather_facts: true tasks: #################################################################### # /dev/vdb — always create 1500MB partition mounted at /devmount #################################################################### - name: Create 1500MB partition on /dev/vdb community.general.parted: device: /dev/vdb number: 1 state: present part_end: 1500MiB - name: Create XFS filesystem on /dev/vdb1 ansible.builtin.filesystem: fstype: xfs dev: /dev/vdb1 - name: Mount /dev/vdb1 at /devmount ansible.builtin.mount: path: /devmount src: /dev/vdb1 fstype: xfs state: mounted #################################################################### # /dev/vdc — size-based logic (1500MB or 800MB) #################################################################### - name: Determine size of /dev/vdc partition ansible.builtin.set_fact: vdc_part_size: >- {{ '1500MiB' if (ansible_facts.devices.vdc.sectors | int * ansible_facts.devices.vdc.sectorsize | int) >= (1500 * 1024 * 1024) else '800MiB' }} when: "'vdc' in ansible_facts.devices" - name: Create partition on /dev/vdc community.general.parted: device: /dev/vdc number: 1 state: present part_end: "{{ vdc_part_size }}" when: "'vdc' in ansible_facts.devices" - name: Create XFS filesystem on /dev/vdc1 ansible.builtin.filesystem: fstype: xfs dev: /dev/vdc1 when: "'vdc' in ansible_facts.devices" - name: Mount /dev/vdc1 ansible.builtin.mount: path: >- {{ '/devmount1' if vdc_part_size == '1500MiB' else '/dev/mount' }} src: /dev/vdc1 fstype: xfs state: mounted when: "'vdc' in ansible_facts.devices" #################################################################### # /dev/vde presence check #################################################################### - name: Warn if /dev/vde is not present ansible.builtin.debug: msg: "Disk /dev/vde is not present" when: "'vde' not in ansible_facts.devices"