2022-12-22 22:34:09 +00:00
|
|
|
# vim: ft=yaml.ansible
|
|
|
|
---
|
|
|
|
- name: (Create and) open LUKS containers
|
|
|
|
luks_device:
|
|
|
|
uuid: "{{ item.disk.uuid }}"
|
|
|
|
passphrase: "{{ item.disk.luks_pw }}"
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
type: luks2
|
|
|
|
state: opened
|
|
|
|
loop:
|
|
|
|
- disk: "{{ secrets.hdd }}"
|
|
|
|
name: "{{ hdd_name }}"
|
|
|
|
- disk: "{{ secrets.ssd }}"
|
|
|
|
name: "{{ ssd_name }}"
|
|
|
|
|
|
|
|
- name: Create filesystems if they do not exist
|
|
|
|
filesystem:
|
2022-12-23 17:28:01 +00:00
|
|
|
dev: "{{ item }}"
|
2022-12-22 22:34:09 +00:00
|
|
|
fstype: ext4
|
|
|
|
state: present
|
|
|
|
loop:
|
2023-01-03 21:30:22 +00:00
|
|
|
- /dev/mapper/{{ hdd_name }}
|
|
|
|
- /dev/mapper/{{ ssd_name }}
|
2022-12-25 23:53:10 +00:00
|
|
|
when: ansible_mounts | selectattr('device', 'eq', item) | length == 0
|
2022-12-22 22:34:09 +00:00
|
|
|
|
|
|
|
- name: Mount filesystems
|
|
|
|
mount:
|
2022-12-23 17:28:01 +00:00
|
|
|
src: "{{ item.dev }}"
|
2022-12-22 22:34:09 +00:00
|
|
|
path: "{{ item.path }}"
|
|
|
|
fstype: ext4
|
2022-12-23 17:28:01 +00:00
|
|
|
fstab: /tmp/fstab.ansible
|
2022-12-23 16:15:48 +00:00
|
|
|
state: mounted
|
2022-12-22 22:34:09 +00:00
|
|
|
loop:
|
2023-01-03 21:30:22 +00:00
|
|
|
- dev: /dev/mapper/{{ hdd_name }}
|
2022-12-22 22:34:09 +00:00
|
|
|
path: "{{ hdd_mount_point }}"
|
2023-01-03 21:30:22 +00:00
|
|
|
- dev: /dev/mapper/{{ ssd_name }}
|
2022-12-22 22:34:09 +00:00
|
|
|
path: "{{ ssd_mount_point }}"
|
2022-12-25 23:53:10 +00:00
|
|
|
when: ansible_mounts | selectattr('device', 'eq', item.dev) | length == 0
|
2022-12-23 15:57:37 +00:00
|
|
|
|
2022-12-22 22:34:09 +00:00
|
|
|
- name: Create swapfile
|
|
|
|
community.general.filesize:
|
|
|
|
path: "{{ ssd_mount_point }}/swapfile"
|
2022-12-23 15:57:37 +00:00
|
|
|
size: 2G
|
|
|
|
blocksize: 512B
|
2022-12-23 14:54:29 +00:00
|
|
|
owner: root
|
2022-12-23 15:57:37 +00:00
|
|
|
mode: u=rw,go=
|
2022-12-25 23:53:10 +00:00
|
|
|
when: ansible_swaptotal_mb == 0
|
2022-12-22 22:34:09 +00:00
|
|
|
|
|
|
|
- name: Mount swapfile
|
|
|
|
shell: |
|
|
|
|
mkswap {{ ssd_mount_point }}/swapfile
|
|
|
|
swapon {{ ssd_mount_point }}/swapfile
|
2022-12-25 23:53:10 +00:00
|
|
|
when: ansible_swaptotal_mb == 0
|