# create a new datagrepper server

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

- name: make the box be real
  hosts: datagrepper:datagrepper-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

  roles:
  - base
  - rkhunter
  - nagios_client
  - hosts
  - fas_client
  - collectd/base
  - fedmsg/base
  - rsyncd
  - sudo
  - { role: openvpn/client,
      when: env != "staging" }
  - mod_wsgi

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

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

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

- name: dole out the service-specific config
  hosts: datagrepper:datagrepper-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

  roles:
  - datagrepper
  - role: collectd/web-service
    site: datagrepper
    url: "http://localhost/datagrepper/raw?delta=86400"
    interval: 15

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

# The gluster work here can be omitted for now.  It is used by a feature of
# datagrepper that is partially in place, but not yet functional.
#
#- name: set up gluster server on prod
#  hosts: datagrepper:datagrepper-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
#
#  roles:
#  - role: gluster/server
#    name: gluster
#    username: "{{ datagrepperglusterusername }}"
#    password: "{{ datagrepperglusterpassword }}"
#    owner: root
#    group: root
#    datadir: /srv/glusterfs/datagrepper
#
#  handlers:
#  - import_tasks: "{{ handlers_path }}/restart_services.yml"
#
#- name: set up gluster client on prod
#  hosts: datagrepper:datagrepper-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
#
#  roles:
#  - role: gluster/client
#    name: gluster
#    servers:
#    - datagrepper01.phx2.fedoraproject.org
#    - datagrepper02.phx2.fedoraproject.org
#    username: "{{ datagrepperglusterusername }}"
#    password: "{{ datagrepperglusterpassword }}"
#    owner: apache
#    group: apache
#    mountdir: /var/cache/datagrepper
#
#  handlers:
#  - import_tasks: "{{ handlers_path }}/restart_services.yml"
