Simplify disks.yml
This commit is contained in:
parent
05359186d8
commit
2d66d08cc3
|
@ -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'"
|
||||
|
|
Reference in a new issue