- 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

  roles:
  - role: openshift/project
    app: languages
    description: Localization measurement and tooling
    appowners:
    - darknao
    - jibecfed

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

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

  - role: openshift/start-build
    app: languages
    buildname: build-latest

  - role: openshift/object
    app: languages
    template: service.yml
    objectname: service.yml

  - role: openshift/route
    app: languages
    routename: languages
    host: "languages{{ env_suffix }}.fedoraproject.org"
    serviceport: web
    servicename: web

  - role: openshift/object
    app: languages
    template: pvc.yml
    objectname: pvc.yml

  - role: openshift/object
    app: languages
    template: deploymentconfig.yml
    objectname: deploymentconfig.yml

  - role: openshift/object
    app: languages
    template: cron.yml
    objectname: cron.yml

###############################################
# actions to delete the project from OpenShift
###############################################
# to run: sudo rbac-playbook -l os_masters_stg[0] -t delete openshift-apps/languages.yml
  - role: openshift/object-delete
    app: languages
    objecttype: project
    objectname: languages
    tags:
    - never
    - delete

  post_tasks:
  - name: run initial f.10 import
    command: "oc -n languages create job stats-10-{{ lookup('pipe','date +%s') }}-init --from=cronjob/stats-10"
    tags:
    - never
    - init
    - f10
 
  - name: run initial f.20 import
    command: "oc -n languages create job stats-20-{{ lookup('pipe','date +%s') }}-init --from=cronjob/stats-20"
    tags:
    - never
    - init
    - f20

  - name: run initial f.30 import
    command: "oc -n languages create job stats-30-{{ lookup('pipe','date +%s') }}-init --from=cronjob/stats-30"
    tags:
    - never
    - init
    - f30

  - name: run initial f.latest import
    command: "oc -n languages create job stats-latest-{{ lookup('pipe','date +%s') }}-init --from=cronjob/stats-latest"
    tags:
    - never
    - init
    - latest

