- name: anna
  hosts: anna.fi.muni.cz
  vars:
    postgres_server_root: /srv/postgres
    postgres_server: true
    nftables:
      pds_local: true
      nfs: true
      snmp: false
    run_surveyor: false

  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: /srv/crs dir
        file:
          state: directory
          path: /srv/crs

      - name: crs-pv264 group
        group:
          name: crs-pv264
          gid: 751

      - name: crs-pv264 user
        user:
          name: crs-pv264
          group: crs-pv264
          home: /srv/crs/pv264
          shell: /bin/bash
          uid: 751

      - name: quickpoll group
        group:
          name: quickpoll
          gid: 752

      - name: quickpoll user
        user:
          name: quickpoll
          group: quickpoll
          uid: 752
          home: /srv/crs/quickpoll
          shell: /bin/bash

      - name: PostgreSQL user for Surveyor
        postgresql_user:
          login_unix_socket: "/var/run/postgresql/"
          name: '{{item}}'
          role_attr_flags: CREATEDB,NOSUPERUSER
        loop:
          - surveyor
          - surveyor-web

      - name: Grant surveyor to surveyor-web
        postgresql_privs:
          login_unix_socket: "/var/run/postgresql/"
          type: group
          obj: surveyor
          role: surveyor-web
          admin_option: false
          db: postgres  # not actually used

      - import_role:
          name: surveyor
