# vim: ts=2 sw=2 autoindent

- name: provision message-tagging-service
  hosts: os_control[0]:os_control_stg[0]
  user: root
  gather_facts: False

  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - /srv/private/ansible/vars.yml
    - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
    - /srv/web/infra/ansible/roles/openshift-apps/message-tagging-service/vars/main.yml
    - /srv/web/infra/ansible/roles/openshift-apps/message-tagging-service/vars/{{ env }}.yml

  roles:
  - role: openshift/project
    app: message-tagging-service
    description: A tagging service tagging builds in koji, used by modularity
    appowners:
    - julian8628
    - cqi
    tags:
      - appowners

  - role: openshift/keytab
    secret_name: keytab
    key: krb5.keytab
    service: message-tagging-service
    host: "message-tagging-service{{ env_suffix }}.fedoraproject.org"

  - role: openshift/route
    routename: mts
    host: "message-tagging-service{{ env_suffix }}.fedoraproject.org"
    serviceport: web
    servicename: mts

  # Setup for fedora-messaging

  - role: rabbit/queue
    username: "mts{{ env_suffix }}"
    queue_name: "mts{{ env_suffix }}"
    routing_keys:
      - "org.fedoraproject.*.mbs.module.state.change"
    thresholds:
      warning: 10
      critical: 100
    sent_topics: ^org\.fedoraproject\.{{ env_short }}\.build\.tag\..*

  # cacert, certificate and private key for fedora-messaging

  - role: openshift/secret-file
    app: message-tagging-service
    secret_name: mts-fedora-messaging-key
    key: mts.key
    privatefile: "rabbitmq/{{ env }}/pki/private/mts{{ env_suffix }}.key"

  - role: openshift/secret-file
    app: message-tagging-service
    secret_name: mts-fedora-messaging-crt
    key: mts.crt
    privatefile: "rabbitmq/{{ env }}/pki/issued/mts{{ env_suffix }}.crt"

  - role: openshift/secret-file
    app: message-tagging-service
    secret_name: mts-fedora-messaging-ca
    key: mts.ca
    privatefile: "rabbitmq/{{ env }}/pki/ca.crt"

  tasks:
    - name: Apply objects
      include_role: name=openshift/object
      vars:
        template: "{{ item }}.yml"
        objectname: "{{ item }}.yml"
      with_items:
        - configmap
        - imagestream
        - deploymentconfig
        - service
