summaryrefslogtreecommitdiff
path: root/roles/storage/luks/device/tasks/main.yml
blob: 7b84b8cccf991e2e23e52a3d0debbdac9abcd706 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
- name: Create temporary build directory
  check_mode: False
  tempfile:
    state: directory
  changed_when: False
  register: luks_keyfile_dir

- name: create luks device
  block:
  - name: write passphrase into temporary keyfile
    check_mode: False
    copy:
      dest: "{{ luks_keyfile_dir.path }}/{{ luks_device.name }}"
      content: "{{ luks_device.passphrase }}"
      mode: 0400
    changed_when: False

  - name: create/open luks device
    luks_device:
      name: "{{ luks_device.name }}"
      device: "{{ luks_device.device }}"
      keyfile: "{{ luks_keyfile_dir.path }}/{{ luks_device.name }}"
      state: opened

  always:
  - name: remove base-directory for keyfiles
    check_mode: False
    file:
      path: "{{ luks_keyfile_dir.path }}"
      state: absent
    changed_when: False

- name: export device path
  set_fact:
    storage_device_path: "/dev/mapper/{{ luks_device.name }}"