- name: make secondary download virt
  hosts: download-ibiblio
  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"


- name: Download servers
  hosts: download
  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:

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


- name: post-initial-steps
  hosts: download
  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
  - rkhunter
  - { role: denyhosts, when: ansible_distribution_major_version != '7' }
  - nagios_client
  - hosts
  - fas_client
  - collectd/base
  - download
  - { role: mod_limitipconn, when: ansible_distribution_major_version != '7'}
  - rsyncd
  - { role: nfs/client, when: datacenter == "phx2", mnt_dir: '/srv/pub',  nfs_src_dir: 'fedora_ftp/fedora.redhat.com/pub' }
  - { role: nfs/client, when: datacenter == "rdu", mnt_dir: '/srv/pub',  nfs_src_dir: 'fedora_ftp/fedora.redhat.com/pub' }
  - sudo
  - { role: openvpn/client, when: datacenter != "phx2" }

  tasks:
  - include: "{{ tasks }}/yumrepos.yml"
  - include: "{{ tasks }}/2fa_client.yml"
  - include: "{{ tasks }}/motd.yml"
    when: env != "staging"
  - include: "{{ tasks }}/apache.yml"
  - name: put in script for syncing
    action: copy src="{{ files }}/download/sync-up-downloads.sh"  dest=/usr/local/bin/sync-up-downloads owner=root group=root mode=755
    when: datacenter == 'ibiblio'
  - name: put in cron job for syncing
    action: copy src="{{ files }}/download/download-sync.cron"  dest=/etc/cron.d/download-sync owner=root group=root mode=644
    when: datacenter == 'ibiblio'

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

