# create a new fedimg server
# NOTE: make sure there is room/space for this server on the vmhost

- import_playbook: "/srv/web/infra/ansible/playbooks/include/virt-create.yml"
  vars:
    myhosts: "fedimg:fedimg_stg"

- name: dole out the generic configuration
  hosts: fedimg:fedimg_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
  # The proxies don't actually need to talk to these hosts so we won't bother
  # putting them on the vpn.
  #- { role: openvpn/client,
  #    when: env != "staging" }
  - ipa/client
  - nagios_client
  - hosts
  - collectd/base
  - fedmsg/base
  - sudo

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

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

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

- name: dole out the service-specific config
  hosts: fedimg:fedimg_stg
  user: root
  gather_facts: True

  roles:
  - fedmsg/hub
  - role: fedimg
    aws_keyname: fedimg-dev
    aws_keypath: /etc/pki/fedimg/fedimg-dev
    aws_pubkeypath: /etc/pki/fedimg/fedimg-dev.pub
    when: env == 'staging'
  - role: fedimg
    aws_keyname: releng-ap-northeast-1
    aws_keypath: /etc/pki/fedimg/fedimg-prod
    aws_pubkeypath: /etc/pki/fedimg/fedimg-prod.pub
    when: env != 'staging'
  - role: collectd/fedmsg-service
    process: fedmsg-hub

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

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