- name: make the app be real
  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

  vars:

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

  - role: openshift/project
    app: noggin-centos
    description: "Self-service account portal"
    appowners:
    - abompard
    - nils
    - ryanlerch
    tags:
      - apply-appowners
    when: env == "production"
  - role: openshift/project
    app: noggin-centos
    description: "Self-service account portal"
    appowners:
    - abompard
    - nils
    - ryanlerch
    tags:
      - apply-appowners
    when: env == "staging"

  - role: openshift/secret-file
    app: noggin-centos
    secret_name: fedora-messaging-ca
    key: cacert.pem
    privatefile: "rabbitmq/{{env}}/pki/ca.crt"
  - role: openshift/secret-file
    app: noggin-centos
    secret_name: fedora-messaging-crt
    key: noggin-cert.pem
    privatefile: "rabbitmq/{{env}}/pki/issued/noggin{{env_suffix}}.crt"
  - role: openshift/secret-file
    app: noggin-centos
    secret_name: fedora-messaging-key
    key: noggin-key.pem
    privatefile: "rabbitmq/{{env}}/pki/private/noggin{{env_suffix}}.key"

  - role: openshift/imagestream
    app: noggin-centos
    imagename: noggin

  - role: openshift/object
    app: noggin
    os_app: noggin-centos
    template: buildconfig.yml
    objectname: buildconfig.yml

  - role: openshift/object
    app: noggin
    os_app: noggin-centos
    template: configmap.yml
    objectname: configmap.yml
    noggin_theme: centos

  - role: openshift/ipa-client
    app: noggin-centos

  - role: openshift/object
    app: noggin
    os_app: noggin-centos
    template: service.yml
    objectname: service.yml

  - role: openshift/route
    app: noggin-centos
    routename: noggin
    host: "accounts{{ env_suffix }}.centos.org"
    serviceport: web
    servicename: noggin-web
    annotations:
      haproxy.router.openshift.io/timeout: 5m

  - role: openshift/object
    app: noggin
    os_app: noggin-centos
    template: secrets.yml
    objectname: secrets.yml

  - role: openshift/object
    app: noggin
    os_app: noggin-centos
    template: secret-webhook.yml
    objectname: secret-webhook.yml

  - role: openshift/object
    app: noggin
    os_app: noggin-centos
    template: deploymentconfig.yml
    objectname: deploymentconfig.yml

  - role: openshift/start-build
    app: noggin-centos
    buildname: noggin
    tags:
    - never
    - build

  - role: openshift/rollout
    app: noggin-centos
    dcname: noggin
    tags:
    - never
    - rollout
