- name: make the app be real
  hosts: os_control_stg[0]:os_control[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

  roles:
  - role: rabbit/user
    username: "mdapi{{ env_suffix }}"
    sent_topics:
    - ^org\.fedoraproject\.{{ env_short }}\.mdapi\..*

  - role: openshift/project
    app: mdapi
    description: mdapi is a small API exposing the metadata contained in different RPM repositories.
    appowners:
    - t0xic0der
    - kevin

  - role: openshift/object
    app: mdapi
    template: imagestream.yml
    objectname: imagestream.yml

  - role: openshift/object
    app: mdapi
    template: buildconfig.yml
    objectname: buildconfig.yml

  - role: openshift/object
    app: mdapi
    file: storage.yml
    objectname: storage.yml

  - role: openshift/object
    app: mdapi
    template: configmap.yml
    objectname: configmap.yml

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

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

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

  - role: openshift/object
    app: mdapi
    file: cron.yml
    objectname: cron.yml
    tags:
      - cron-job

  - role: openshift/start-build
    app: mdapi
    buildname: mdapi-build
    objectname: mdapi-build

  - role: openshift/object
    app: mdapi
    file: service.yml
    objectname: service.yml

  - role: openshift/route
    app: mdapi
    routename: mdapi
    host: "mdapi{{env_suffix}}.fedoraproject.org"
    serviceport: 8080-tcp
    servicename: mdapi

  - role: openshift/object
    app: mdapi
    file: deploymentconfig.yml
    objectname: deploymentconfig.yml

  - role: openshift/rollout
    app: mdapi
    dcname: mdapi
