Simplify disks.yml

This commit is contained in:
Sam A. 2022-12-25 18:46:53 +01:00
parent 05359186d8
commit 2d66d08cc3
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA

View file

@ -15,21 +15,17 @@
- name: Get list of mounted devices
shell: mount
register: blk_list
- name: Create var mounted_devices
set_fact:
mounted_devices: "{{ blk_list.stdout_lines }}"
register: mounted_devices
- name: Create filesystems if they do not exist
filesystem:
dev: "{{ item }}"
fstype: ext4
state: present
when: mounted_devices | select('search', item) | list | length == 0
loop:
- "/dev/mapper/{{ hdd_name }}"
- "/dev/mapper/{{ ssd_name }}"
when: mounted_devices.stdout_lines | select('search', item) | list | length == 0
- name: Mount filesystems
mount:
@ -38,12 +34,12 @@
fstype: ext4
fstab: /tmp/fstab.ansible
state: mounted
when: mounted_devices | select('search', item.dev) | list | length == 0
loop:
- dev: "/dev/mapper/{{ hdd_name }}"
path: "{{ hdd_mount_point }}"
- dev: "/dev/mapper/{{ ssd_name }}"
path: "{{ ssd_mount_point }}"
when: mounted_devices.stdout_lines | select('search', item) | list | length == 0
- name: Check if swapfile is mounted
shell: "swapon | grep -q '{{ ssd_mount_point }}/swapfile'"