# create a new releng system
# NOTE: should be used with --limit most of the time
# NOTE: make sure there is room/space for this instance on the buildvmhost
# NOTE: most of these vars_path come from group_vars/releng or from hostvars

- name: make releng systems
  hosts: composers;composers-stg
  user: root
  gather_facts: False

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

  tasks:
  - include: "{{ tasks }}/virt_instance_create.yml"

  handlers:
  - include: "{{ handlers }}/restart_services.yml"

# Once the instance exists, configure it. 

- name: make releng server system
  hosts: composers;composers-stg
  user: root
  gather_facts: True

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

  roles:
  - base
  - nagios_client
  - collectd/base
  - hosts
  - builder_repo
  - role: nfs/client
    mnt_dir: '/pub/fedora'
    nfs_src_dir: 'fedora_ftp/fedora.redhat.com/pub/fedora'
    when: datacenter != 'staging'
  - role: nfs/client
    mnt_dir: '/mnt/fedora_koji'
    nfs_src_dir: 'fedora_koji'
    when: datacenter != 'staging'
  - role: nfs/client
    mnt_dir: 'mnt/fedora_koji'
    nfs_src_dir: 'mnt/fedora_koji'
    when: datacenter == 'staging'
  - releng
  - fedmsg/base

  tasks:
  - include: "{{ tasks }}/yumrepos.yml"
  - include: "{{ tasks }}/motd.yml"

  handlers:
  - include: "{{ handlers }}/restart_services.yml"

- name: put fasClient and 2fa on the staging releng systems
  # Staging only, for debugging please.
  hosts: composers-stg
  user: root
  gather_facts: True

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

  roles:
  - fas_client
  - sudo

  tasks:
  - include: "{{ tasks }}/2fa_client.yml"

  handlers:
  - include: "{{ handlers }}/restart_services.yml"


- name: Install the fedmsg-atomic-composer
  # Staging only, for now.
  hosts: composers-stg
  user: root
  gather_facts: True

  roles:
  - atomic-composer
