Playbook de Ansible para configurar Initramfs Dropbear para desencriptación LUKS por SSH

Aplicar este playbook instala Dropbear en Initramfs.

Asegúrate de tener una o múltiples claves RSA en luks-dropbear-authorized_keys.pub en el mismo directorio que este playbook.. Las claves Ed25519 no son soportadas por Dropbear en este momento.

initramfs_dropbear_playbook.yml
---
- name: Configure remote LUKS unlocking with Dropbear
  hosts: all
  become: true
  vars:
    dropbear_auth_keys_path: /etc/dropbear/initramfs/authorized_keys

  tasks:
    - name: Install required packages
      apt:
        name:
          - cryptsetup
          - dropbear
          - dropbear-initramfs
          - dropbear-bin
        state: present
        update_cache: yes
      register: apt_install_result

    - name: Ensure the Dropbear initramfs directory exists
      file:
        path: /etc/dropbear/initramfs
        state: directory
        mode: '0755'

    - name: Copy SSH public key to Dropbear authorized_keys
      copy:
        src: luks-dropbear-authorized_keys.pub
        dest: "{{ dropbear_auth_keys_path }}"
        mode: '0600'
      register: auth_keys_result

    - name: Reconfigure Dropbear initramfs
      shell: dpkg-reconfigure dropbear-initramfs
      when: apt_install_result.changed or auth_keys_result.changed

    - name: Update initramfs
      shell: update-initramfs -u
      when: apt_install_result.changed or auth_keys_result.changed

Echa un vistazo a artículos similares por categoría: Ansible Linux Criptografía