2019-03-16 22:51:50 +00:00
|
|
|
---
|
|
|
|
- name: install packages
|
2021-09-12 22:05:09 +00:00
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
2019-03-16 22:51:50 +00:00
|
|
|
- cryptsetup
|
|
|
|
- util-linux
|
|
|
|
register: result
|
|
|
|
retries: 3
|
|
|
|
delay: 1
|
|
|
|
until: result is success
|
|
|
|
tags: luks
|
|
|
|
|
|
|
|
- name: create luks device
|
|
|
|
luks_manage:
|
|
|
|
device: '{{ item.device }}'
|
|
|
|
cipher: '{{ item.cipher|default("aes-xts-plain") }}'
|
|
|
|
size: '{{ item.size|default(256) }}'
|
|
|
|
key: '{{ item.key }}'
|
|
|
|
loop: '{{ luks_devices }}'
|
2021-09-12 22:13:15 +00:00
|
|
|
loop_control:
|
|
|
|
label: '{{ item.name }} - {{ item.device }}'
|
2019-03-16 22:51:50 +00:00
|
|
|
tags: luks
|
|
|
|
|
|
|
|
- name: decrypt luks device
|
|
|
|
luks_decrypt:
|
|
|
|
device: '{{ item.device }}'
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
key: '{{ item.key }}'
|
|
|
|
loop: '{{ luks_devices }}'
|
2021-09-12 22:13:15 +00:00
|
|
|
loop_control:
|
|
|
|
label: '{{ item.name }} - {{ item.device }}'
|
2019-03-16 22:51:50 +00:00
|
|
|
tags: luks
|
|
|
|
|
|
|
|
- name: format partition
|
2021-09-12 22:05:09 +00:00
|
|
|
ansible.builtin.filesystem:
|
2019-03-16 22:51:50 +00:00
|
|
|
fstype: '{{ item.fstype }}'
|
|
|
|
dev: '/dev/mapper/{{ item.name }}'
|
|
|
|
loop: '{{ luks_devices }}'
|
2021-09-12 22:13:15 +00:00
|
|
|
loop_control:
|
|
|
|
label: '{{ item.name }} - {{ item.device }}'
|
2019-03-16 22:51:50 +00:00
|
|
|
tags: luks
|
|
|
|
|
|
|
|
- name: mount partition
|
2021-09-12 22:05:09 +00:00
|
|
|
ansible.builtin.mount:
|
2019-03-16 22:51:50 +00:00
|
|
|
src: '/dev/mapper/{{ item.name }}'
|
|
|
|
path: '{{ item.mount_point }}'
|
|
|
|
fstype: '{{ item.fstype }}'
|
|
|
|
opts: noauto
|
|
|
|
state: mounted
|
|
|
|
loop: '{{ luks_devices }}'
|
2021-09-12 22:13:15 +00:00
|
|
|
loop_control:
|
|
|
|
label: '{{ item.name }} - {{ item.device }}'
|
2019-03-16 22:51:50 +00:00
|
|
|
tags: luks
|