# create a new koji builder on raw hw
# NOTE: should be used with --limit most of the time
# NOTE: most of these vars_path come from group_vars/buildhw or from hostvars

- name: make koji builder(s) on raw hw
  hosts: buildhw:buildppc:buildarm:buildaarch64:buildppc64:bkernel
  remote_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

  roles:
  - base
  - { role: nfs/client, when: inventory_hostname.startswith('build') , mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_koji' }
  - { role: nfs/client, when: inventory_hostname.startswith('arm04-builder00') , mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_koji' }
  - { role: nfs/client, when: inventory_hostname.startswith('arm04-builder01') , mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_koji' }
  - { role: nfs/client, when: inventory_hostname.startswith('aarch64') , mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_arm/data' }
  - { role: nfs/client, when: inventory_hostname.startswith('ppc8') , mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_ppc/data' }
  - koji_builder
  - { role: bkernel, when: inventory_hostname.startswith('bkernel') }
  - hosts
  - { role: fas_client, when: not inventory_hostname.startswith('bkernel') }
  - { role: sudo, when: not inventory_hostname.startswith('bkernel') }

  tasks:
  - include: "{{ tasks }}/2fa_client.yml"
    when: not inventory_hostname.startswith('bkernel')
  - include: "{{ tasks }}/motd.yml"
    when: not inventory_hostname.startswith('bkernel')
  - include: "{{ tasks }}/yumrepos.yml"

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