# create a new virthost server system
# NOTE: should be used with --limit most of the time
# NOTE: most of these vars_path come from group_vars/backup_server or from hostvars

- import_playbook: "/srv/web/infra/ansible/playbooks/include/happy_birthday.yml"
  vars:
    myhosts: "virthost:bvirthost:buildvmhost:virthost_comm:colo_virt:virthost_communishift:!buildvmhost-s390x-01.s390.fedoraproject.org"

- name: make virthost server system
  hosts: virthost:bvirthost:buildvmhost:virthost_comm:colo_virt:virthost_communishift
  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:
  - include_vars: dir=/srv/web/infra/ansible/vars/all/ ignore_files=README
  - import_tasks: "{{ tasks_path }}/yumrepos.yml"

  - name: override nbde_client-network-flush to work around bug
    copy:
      src: "{{ files }}/common/nbde_client-network-flush"
      dest: /usr/bin/nbde_client-network-flush
      owner: root
      group: root
      mode: 755 

  - name: tell NetworkManager we don't want any auto connections
    copy:
      src: "{{ files }}/common/noautodefault.conf"
      dest: /etc/NetworkManager/conf.d/noautodefault.conf
      owner: root
      group: root
      mode: 644 

  roles:
  - base
  - { role: rkhunter }
  - { role: nagios_client }
  - hosts
  - { role: openvpn/client, when: vpn|bool }
  - ipa/client
  - { role: collectd/base }
  - { role: iscsi_client, when: "inventory_hostname.startswith(('bvmhost-x86-06', 'bvmhost-x86-07')) and datacenter == 'iad2'" }
  - sudo
  - virthost
  - { role: linux-system-roles.nbde_client, tags: ['nbde_client'], when: datacenter == 'iad2' and nbde|bool }
  - { role: serial-console, when: datacenter == 'iad2' and not inventory_hostname.startswith('buildvmhost-s390x') }

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

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