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