- import_playbook: "/srv/web/infra/ansible/playbooks/include/virt-create.yml myhosts=openqa:openqa-stg"

- name: setup base openqa host
  hosts: openqa:openqa-stg
  user: root
  gather_facts: True

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  pre_tasks:
  - import_tasks: "{{ tasks_path }}/yumrepos.yml"

  roles:
   - { role: base, tags: ['base'] }
   - { role: rkhunter, tags: ['rkhunter'] }
   - { role: nagios_client, tags: ['nagios_client'] }
   - { role: hosts, tags: ['hosts']}
   - { role: fas_client, tags: ['fas_client'] }
   - { role: collectd/base, tags: ['collectd_base'] }
   - { role: sudo, tags: ['sudo'] }
   - { role: openvpn/client,
       when: deployment_type == "prod", tags: ['openvpn_client'] }
   - apache

  tasks:
  - import_tasks: "{{ tasks_path }}/2fa_client.yml"
  - import_tasks: "{{ tasks_path }}/motd.yml"

  handlers:
   - import_tasks: "{{ handlers_path }}/restart_services.yml"

- name: configure openQA
  hosts: openqa:openqa-stg
  user: root
  gather_facts: True

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

# relvalconsumer and autocloudreporter aren't particularly related
# to openQA in any way, we just put those role on these boxes. There's
# nowhere more obviously correct for rvc and acr should be on an
# Autocloud box but I don't know if they're authed for RDB.
  roles:
   - { role: openqa/server, tags: ['openqa_server'] }
   - { role: openqa/dispatcher, tags: ['openqa_dispatcher'] }
   - { role: check-compose, tags: ['check-compose'] }
   - { role: fedmsg/base, tags: ['fedmsg_base', 'fedmsg'] }
   - { role: fedmsg/hub, tags: ['fedmsg_hub', 'fedmsg'] }
   - { role: relvalconsumer, tags: ['relvalconsumer'] }
   - { role: autocloudreporter, tags: ['autocloudreporter'] }

  handlers:
   - import_tasks: "{{ handlers_path }}/restart_services.yml"

- name: set up openQA server data NFS mounts (staging)
  hosts: openqa-stg

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - role: nfs/client
    mnt_dir: '/var/lib/openqa/testresults'
    nfs_src_dir: 'fedora_openqa_stg/testresults'
    nfs_mount_opts: 'rw,bg,nfsvers=3'
    tags: ['nfs_client']
  - role: nfs/client
    mnt_dir: '/var/lib/openqa/images'
    nfs_src_dir: 'fedora_openqa_stg/images'
    nfs_mount_opts: 'rw,bg,nfsvers=3'
    tags: ['nfs_client']

  handlers:
   - import_tasks: "{{ handlers_path }}/restart_services.yml"

- name: set up openQA server data NFS mounts (prod)
  hosts: openqa

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - role: nfs/client
    mnt_dir: '/var/lib/openqa/testresults'
    nfs_src_dir: 'fedora_openqa/testresults'
    nfs_mount_opts: 'rw,bg,nfsvers=3'
    tags: ['nfs_client']
  - role: nfs/client
    mnt_dir: '/var/lib/openqa/images'
    nfs_src_dir: 'fedora_openqa/images'
    nfs_mount_opts: 'rw,bg,nfsvers=3'
    tags: ['nfs_client']

  handlers:
   - import_tasks: "{{ handlers_path }}/restart_services.yml"
