- name: install dropbear-initramfs
  apt:
    pkg: dropbear-initramfs
 
- name: write config file for dropbear-initramfs
  notify: update initramfs
  template:
    src: config.j2
    dest: "{{ dropbear_initramfs_config_path }}"
    mode: 0644
    owner: root
    group: root

- name: write authorized_keys file for dropbear-initramfs
  when: not ssh_initramfs.copy_from_root
  notify: update initramfs
  template:
    src: authorized_keys.j2
    dest: "{{ dropbear_initramfs_path }}/authorized_keys"
    mode: 0644
    owner: root
    group: root

- name: copy authorized_keys file from root user to dropbear-initramfs
  when: ssh_initramfs.copy_from_root
  notify: update initramfs
  copy:
    src: /root/.ssh/authorized_keys
    dest: "{{ dropbear_initramfs_path }}/authorized_keys"
    remote_src: true
    mode: 0644
    owner: root
    group: root
