summaryrefslogtreecommitdiffstats
path: root/roles/openshift_resource/tasks/resource.yml
blob: 326abbb735be5af9eb4f208c80cca39f13dcfc16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
- block:
  - name: Find out which resources we are going to configure
    set_fact: rkind="{{ tmpl.kind }}" rname="{{ tmpl.metadata.name }}"

  - name: Lookup the specified resource
    command: "oc get -n {{project}} {{rkind}}/{{rname}}"
    register: result
    failed_when: false
    changed_when: (result | failed)

  - name: Detroy existing resources
    command: "oc delete -n {{project}} {{rkind}}/{{rname}}"
    failed_when: false
    when: (recreate|default(false)) 

  - name: Create resources defined in template
    command: "oc create -n {{project}} -f '{{ template_path }}/{{ template }}' {{ create_args | default('') }}"
    when: (recreate|default(false)) or (result | changed)
  run_once: true