---
- name: RPi netboot special | Hold kernels
  dpkg_selections:
    name: "{{ item }}"
    selection: hold
  loop:
    - linux-headers-raspi
    - linux-image-raspi
    - linux-raspi

- name: RPi netboot special | NFS dependencies
  apt:
    pkg:
      - nfs-common
      - open-iscsi
      - v4l2loopback-dkms
    state: present

- name: RPi netboot special | Add v4l2loopback module
  lineinfile:
    dest: /etc/modules
    regexp: "^v4l2loopback"
    line: "v4l2loopback"

- name: RPi netboot special | Mask unwanted services
  systemd:
    name: "{{ item }}"
    masked: true
  loop:
    - lvm2-lvmpolld.socket
    - lvm2-monitor.service
    - multipathd.service
    - unattended-upgrades.service
    - firewalld.service
    - ufw.service
    - fwupd.service
    - fwupd-refresh.timer

---
- name: RPi netboot special | Hold kernels
  dpkg_selections:
    name: "{{ item }}"
    selection: hold
  loop:
    - linux-headers-raspi
    - linux-image-raspi
    - linux-raspi

- name: RPi netboot special | NFS dependencies
  apt:
    pkg:
      - nfs-common
      - open-iscsi
      - v4l2loopback-dkms
    state: present

# https://github.com/open-iscsi/open-iscsi/blob/a8fcb3737cabcf79a3a3663f43930a158d606782/README#L1557
- name: RPi netboot special | Set iSCSI timeouts
  lineinfile:
    path: /etc/iscsi/iscsid.conf
    regexp: "^{{ item.key }}"
    line: "{{ item.key }} = {{ item.value }}"
    backrefs: true
  loop:
    - key: node.conn[0].timeo.noop_out_interval
      value: 0
    - key: node.conn[0].timeo.noop_out_timeout
      value: 0
    - key: node.session.timeo.replacement_timeout
      value: 86400

- name: RPi netboot special | Add v4l2loopback module
  lineinfile:
    dest: /etc/modules
    regexp: "^v4l2loopback"
    line: "v4l2loopback"

- name: RPi netboot special | Mask unwanted services
  systemd:
    name: "{{ item }}"
    masked: true
  loop:
    - lvm2-lvmpolld.socket
    - lvm2-monitor.service
    - multipathd.service
    - unattended-upgrades.service
    - firewalld.service
    - ufw.service
    - fwupd.service
    - fwupd-refresh.timer

Set iscsi timeouts for root rpi disks
Set iscsi timeouts for root rpi disks
