---
- name: Sanity checks
  hosts: all
  gather_facts: yes
  tags: always
  tasks:
    - name: Check whether the current user is 'root'
      fail:
        msg: This playbook should only be run as 'root'
      when: ansible_real_user_id != 0
    - name: Check seat manager name
      fail:
        msg: seat_manager needs to be 'elogind' or 'seatd'
      when: not seat_manager in ['elogind', 'seatd']
    - name: Check device manager name
      fail:
        msg: device_manager needs to be 'mdev', 'mdevd' or 'udev'
      when: not device_manager in ['mdev', 'mdevd', 'udev']
    - name: Check DNS resolver name
      fail:
        msg: dns_resolver needs to be 'dnscrypt-proxy' or 'unbound'
      when: not dns_resolver in ['dnscrypt-proxy', 'unbound']
    - name: Check rootless container CLI application
      fail:
        msg: rootless_container_cli needs to be 'podman' or 'nerdctl'
      when: not rootless_container_cli in ['podman', 'nerdctl']

- name: Setup the system
  hosts: all
  roles:
    - role: essential
      tags: essential
    - role: devd
      tags: devd
    - role: acpi
      tags: acpi
    - role: seat
      tags: seat
    - role: fstab
      tags: fstab
    - role: nftables
      tags: nftables
    - role: apparmor
      tags: apparmor
    - role: cron
      tags: cron
    - role: grub
      tags: grub
    - role: iwd
      tags: [laptop, iwd]
    - role: libvirt
      tags: libvirt
    - role: tlp
      tags: [laptop, tlp]
    - role: dns
      tags: dns
    - role: usbguard
      tags: usbguard
    - role: zram
      tags: zram
    - role: user
      tags: user
    - role: container
      tags: container
    - role: waydroid
      tags: waydroid
