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

  ############################################
  # actions to create the project in OpenShift
  ############################################
  # to run: sudo rbac-playbook -l os_control_stg openshift-apps/coreos-koji-tagger.yml
  roles:
  - role: openshift/project
    app: coreos-koji-tagger
    description: Tags builds into koji tags within Fedora's Koji instance
    appowners:
    - dustymabe
    - jlebon
    - mizdebsk
    - walters

  # Create a keytab. The default username will be like:
  # coreos-koji-tagger/coreos-koji-tagger.fedoraproject.org@FEDORAPROJECT.ORG
  - role: openshift/keytab
    app: coreos-koji-tagger
    key: koji-keytab
    secret_name: coreos-koji-tagger-keytab
    service: coreos-koji-tagger
    host: "coreos-koji-tagger{{ env_suffix }}.fedoraproject.org"

  # Copy in a kerberos config that is unique to fedora infra
  - role: openshift/object
    app: coreos-koji-tagger
    template: configmap.yml
    objectname: configmap.yml

  - role: openshift/object
    app: coreos-koji-tagger
    template: imagestream.yml
    objectname: imagestream.yml

  - role: openshift/object
    app: coreos-koji-tagger
    template: buildconfig.yml
    objectname: buildconfig.yml

  - role: openshift/start-build
    app: coreos-koji-tagger
    buildname: coreos-koji-tagger-build
    objectname: coreos-koji-tagger-build

  - role: openshift/object
    app: coreos-koji-tagger
    template: deploymentconfig.yml
    objectname: deploymentconfig.yml

  ###############################################
  # actions to delete the project from OpenShift
  ###############################################
  # to run: sudo rbac-playbook -l os_control_stg -t delete openshift-apps/coreos-koji-tagger.yml
  - role: openshift/object-delete
    app: coreos-koji-tagger
    objecttype: project
    objectname: coreos-koji-tagger
    tags: [never, delete]
