#####################################
### someone's ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2025 by someone <someone@somenet.org>
#
# cryptsetup-helper
#
---
- name: install cryptsetup tools
  apt:
    pkg:
    - cryptsetup-bin
    - cryptsetup-initramfs
    - cryptsetup-run
    - systemd-cryptsetup
    state: present
    policy_rc_d: 101
  when: cryptsetup_crypttab_names is defined
  tags: "online"
  ignore_errors: "{{ignore_online_errors | bool}}"


- name: silence systemd for all crypt devices
  copy:
    src: "systemd-cryptsetup@DEVICE.service"
    dest: "/etc/systemd/system/systemd-cryptsetup@{{item}}.service"
    mode: 0644
    owner: "root"
    group: "root"
  with_items:
    - "{{cryptsetup_crypttab_names}}"
  when: cryptsetup_crypttab_names is defined


- name: copy cryptroot-initrd script with askpass fallback
  copy:
    src: "cryptroot"
    dest: "/etc/initramfs-tools/scripts/local-top/cryptroot"
    mode: 0755
    owner: "root"
    group: "root"
  when: cryptsetup_crypttab_names is defined
  notify: update-initramfs
