54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
# vim: ft=yaml.ansible
|
|
---
|
|
- name: (Create and) open LUKS containers
|
|
community.crypto.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
|
|
community.general.filesystem:
|
|
dev: "{{ item }}"
|
|
fstype: ext4
|
|
state: present
|
|
loop:
|
|
- /dev/mapper/{{ hdd_name }}
|
|
- /dev/mapper/{{ ssd_name }}
|
|
when: ansible_mounts | selectattr('device', 'eq', item) | length == 0
|
|
|
|
- name: Mount filesystems
|
|
ansible.posix.mount:
|
|
src: "{{ item.dev }}"
|
|
path: "{{ item.path }}"
|
|
fstype: ext4
|
|
fstab: /tmp/fstab.ansible
|
|
state: mounted
|
|
loop:
|
|
- dev: /dev/mapper/{{ hdd_name }}
|
|
path: "{{ hdd_mount_point }}"
|
|
- dev: /dev/mapper/{{ ssd_name }}
|
|
path: "{{ ssd_mount_point }}"
|
|
when: ansible_mounts | selectattr('device', 'eq', item.dev) | length == 0
|
|
|
|
- name: Create swapfile
|
|
community.general.filesize:
|
|
path: "{{ ssd_mount_point }}/swapfile"
|
|
size: 2G
|
|
blocksize: 512B
|
|
owner: root
|
|
mode: u=rw,go=
|
|
when: ansible_swaptotal_mb == 0
|
|
|
|
- name: Mount swapfile
|
|
ansible.builtin.shell: |
|
|
mkswap {{ ssd_mount_point }}/swapfile
|
|
swapon {{ ssd_mount_point }}/swapfile
|
|
when: ansible_swaptotal_mb == 0
|