ansible-role-luks/tasks/main.yml

50 lines
1.2 KiB
YAML

---
- name: Install packages
ansible.builtin.package:
name:
- cryptsetup
- util-linux
tags: luks
- name: Create luks device
community.crypto.luks_device:
device: "{{ item.device }}"
cipher: "{{ item.cipher | default(omit) }}"
hash: "{{ item.hash | default(omit) }}"
passphrase: "{{ item.passphrase }}"
loop: "{{ luks_devices }}"
loop_control:
label: "{{ item.name }} - {{ item.device }}"
tags: luks
- name: Opened luks device
community.crypto.luks_device:
device: "{{ item.device }}"
name: "{{ item.name }}"
passphrase: "{{ item.passphrase }}"
state: opened
loop: "{{ luks_devices }}"
loop_control:
label: "{{ item.name }} - {{ item.device }}"
tags: luks
- name: Format partition
community.general.filesystem:
fstype: "{{ item.fstype }}"
dev: "/dev/mapper/{{ item.name }}"
loop: "{{ luks_devices }}"
loop_control:
label: "{{ item.name }} - {{ item.device }}"
tags: luks
- name: Mount partition
ansible.posix.mount:
src: "/dev/mapper/{{ item.name }}"
path: "{{ item.mount_point }}"
fstype: "{{ item.fstype }}"
opts: defaults,noauto
state: mounted
loop: "{{ luks_devices }}"
loop_control:
label: "{{ item.name }} - {{ item.device }}"
tags: luks