- name: pontos
  hosts: pontos
  vars:
    llvm9_state: absent
    llvm10_state: absent
    llvm11_state: present
    llvm12_state: present
    postgres_client: true
    nftables:
      pds_local: true
      nfs: true
      snmp: false
    smartd:
      ssd:
        - '/dev/nvme0n1'
        - '/dev/nvme1n1'

  tasks:
      - fail:
          msg: possibly wrong server?
        when: ansible_distribution != 'Debian'

      - import_role:
          name: common_deb

      - import_role:
          name: pds_mount

#      - import_role:
#          name: ghc_deb

      - import_role:
          name: llvm_deb

      - import_role:
          name: pds_deb

      - import_role:
          name: postgres_deb

      - name: Surveryor setup
        block:
          - import_role:
              name: podman_deb

          - import_role:
              name: surveyor

        when: inventory_hostname == "pontos08.fi.muni.cz" or inventory_hostname == "pontos05.fi.muni.cz"

      - name: "cgroups v1"
        lineinfile:
          path: /etc/default/grub
          insertafter: 'GRUB_CMDLINE_LINUX_DEFAULT='
          regex: 'GRUB_CMDLINE_LINUX_DEFAULT="[$]GRUB_CMDLINE_LINUX_DEFAULT systemd[.]unified_cgroup_hierarchy=0"'
          line: 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT systemd.unified_cgroup_hierarchy=0 systemd.legacy_systemd_cgroup_controller=0"'
        register: grub_cgroups
        when: inventory_hostname == "pontos06.fi.muni.cz" or inventory_hostname == "pontos07.fi.muni.cz"

      - command: update-grub
        when: grub_cgroups.changed

      - apt:
          pkg:
          - libbz2-dev
          - libreadline-dev
          - libsqlite3-dev
          - libncursesw5-dev
          - xz-utils
          - tk-dev
          - libxml2-dev
          - libxmlsec1-dev
          - libffi-dev
          - liblzma-dev

      - apt:
          pkg:
            - ipmitool
