---

- name: install dropbear-initramfs
  apt:
    name: "{{ physicals_packages_dropbear }}"
    state: present

- name: install admin ssh keys into initramfs
  authorized_key:
    user: root
    key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCvAISe8/nJhWT1CAe2uBUPqfLBxe44HhnSSWNbqh+97nYnMr+wUj7hj/uGswsrd0mkYAnXfWsCEQJdqwtRDRiq7WVNfG3sHnFasb7MB1+Ti04cPqWKhEtxhpJRy4GKoIs3cX/1SI+GB8r6QuxN4NnjOEi3zyRBE/abQGvRe+fuq2bDI4pU4Ldy0isEG12MgUOSyq69ED3uOGpfZmVqaq5Z+j9m8k49PTz5lcWcJ0M7gCqnVCaN7ONoptdUJTI7EjnnpoQvgfGBNgBBx4zBWTf10UUHT+GYD0Ok6che7TTv1ImQyYmIvMlc4sV3yUgHrTWc7SwpzYBXCzqhrWZyDmV chris@sol"
    path: /etc/dropbear-initramfs/authorized_keys
  notify: update initramfs

- name: add modules for initramfs
  copy:
    src: modules
    dest: /etc/initramfs-tools/modules
    owner: root
    group: root
    mode: 0644
  notify: update initramfs

- name: configure initramfs network options in kernel boot parameters
  lineinfile:
    backrefs: yes
    dest: /etc/default/grub
    regexp: '^GRUB_CMDLINE_LINUX_DEFAULT='
    line: 'GRUB_CMDLINE_LINUX_DEFAULT="ip={{ kernel_network_params.address }}::{{ kernel_network_params.gateway }}:{{ kernel_network_params.netmask }}::{{ kernel_network_params.device }}:{{ kernel_network_params.autoconf }} quiet apparmor=1 security=apparmor"'
  when: kernel_network_params|d()
  notify: update grub
