summaryrefslogtreecommitdiffstats
path: root/roles/openshift_resource
diff options
context:
space:
mode:
Diffstat (limited to 'roles/openshift_resource')
-rw-r--r--roles/openshift_resource/tasks/template.yml11
1 files changed, 8 insertions, 3 deletions
diff --git a/roles/openshift_resource/tasks/template.yml b/roles/openshift_resource/tasks/template.yml
index 7e74de4..188599f 100644
--- a/roles/openshift_resource/tasks/template.yml
+++ b/roles/openshift_resource/tasks/template.yml
@@ -4,14 +4,16 @@
set_fact: resources="{{ tmpl | json_query(query) }}"
vars:
query: "objects[*].{kind: kind, name: metadata.name}"
-
+
+ - set_fact: resources="{{ [] }}"
+ when: resources == ""
+
- name: "{{ template }}: Lookup the specified resource in {{project}}"
command: "oc get -n {{project}} {{item.kind}}/{{item.name}}"
register: results
failed_when: false
changed_when: (results | failed)
with_items: "{{ resources | default([]) }}"
-# when: not (recreate|default(false))
- name: "{{ template }}: Detroy existing resources in {{project}}"
command: "oc delete -n {{project}} {{resources[item|int].kind}}/{{resources[item|int].name}}"
@@ -21,5 +23,8 @@
- name: "{{ template }}: Populate resources to {{project}}"
shell: "oc process -n {{project}} -f '{{ template_path }}/{{template}}' {{ template_args | default('') }} | oc create -n {{project}} -f - {{ create_args | default('') }}"
- when: (recreate|default(false)) or (results | changed)
+ when:
+ - (recreate|default(false)) or (results | changed)
+ - resources | length > 0
+
run_once: true