- name: make the app be real
  hosts: os_control[0]:os_control_stg[0]
  user: root
  gather_facts: False
  vars:
    app: docstranslation
    ssh_key_path: "{{ private }}/files/docstranslation/id_rsa_docstrans_{{ env_short }}"
  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - "/srv/private/ansible/vars.yml"
    - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  tasks:
  - name: Define Project
    include_role:
      name: openshift/project
    vars:
      description: Documentation translation
      appowners:
      - asamalik
      - darknao
      - jibecfed
      - misc
    tags:
      - apply-appowners

  - name: Define imagestream
    include_role:
      name: openshift/imagestream
    vars:
      imagename: builder

  - name: Define buildconfig
    include_role:
      name: openshift/object
    vars:
      objectname: buildconfig.yml
      template: buildconfig.yml

  - name: Start build
    include_role:
      name: openshift/start-build
    vars:
      buildname: docstranslation-build

  - name: Define secrets
    include_role:
      name: openshift/object
    vars:
      objectname: secrets.yml
      template: secrets.yml
    tags:
      - deploy-secrets

  - name: Define configMap
    include_role:
      name: openshift/object
    vars:
      objectname: configmap.yml
      template: configmap.yml
    tags:
      - deploy-config

  - name: Define cron job
    include_role:
      name: openshift/object
    vars:
      template: cron.yml
      objectname: cron.yml
    tags:
      - deploy-cronjob

###############################################
# actions to delete the project from OpenShift
###############################################
# to run: sudo rbac-playbook -l os_masters_stg[0] -t delete openshift-apps/docstranslation.yml
  - name: Delete project
    include_role:
      name: openshift/object-delete
    vars:
      objecttype: project
      objectname: docstranslation
    tags:
    - never
    - delete
