diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2020-01-26 02:48:45 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2020-01-26 02:48:45 +0100 |
commit | ff3cbb6ee9aeac44a329c8eee505f60144d44b48 (patch) | |
tree | 1adf23b583fee2d7bd5aae400774c6ccf8085b19 /roles/openshift_resource | |
parent | 1e8153c2af051ce48d5aa08d3dbdc0d0970ea532 (diff) | |
download | ands-ff3cbb6ee9aeac44a329c8eee505f60144d44b48.tar.gz ands-ff3cbb6ee9aeac44a329c8eee505f60144d44b48.tar.bz2 ands-ff3cbb6ee9aeac44a329c8eee505f60144d44b48.tar.xz ands-ff3cbb6ee9aeac44a329c8eee505f60144d44b48.zip |
Create missing OpenShift resources when policy is 'replace'. Due to the bug previously, previously only existing resources were replaced, but no new resource was created without reporting a error (for instance the new StatefulSet were not created).
Diffstat (limited to 'roles/openshift_resource')
-rw-r--r-- | roles/openshift_resource/tasks/resource.yml | 2 | ||||
-rw-r--r-- | roles/openshift_resource/tasks/template.yml | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/roles/openshift_resource/tasks/resource.yml b/roles/openshift_resource/tasks/resource.yml index b07f645..416f485 100644 --- a/roles/openshift_resource/tasks/resource.yml +++ b/roles/openshift_resource/tasks/resource.yml @@ -17,6 +17,6 @@ when: (recreate|default(false)) - name: "Populate resources defined in {{ template }} to {{project}} ({{ replace | default(false) | ternary('replace', 'create') }})" - command: "oc {{ replace | default(false) | ternary('replace', 'create') }} -n {{project}} -f '{{ template_path }}/{{ template }}' {{ create_args | default('') }}" + command: "oc {{ replace | default(false) | ternary((find_result.rc == 0) | ternary('replace', 'create'), 'create') }} -n {{project}} -f '{{ template_path }}/{{ template }}' {{ create_args | default('') }}" when: (recreate|default(false)) or (replace | default(false)) or (find_result.rc != 0) run_once: true diff --git a/roles/openshift_resource/tasks/template.yml b/roles/openshift_resource/tasks/template.yml index f43b0f2..f593544 100644 --- a/roles/openshift_resource/tasks/template.yml +++ b/roles/openshift_resource/tasks/template.yml @@ -30,4 +30,12 @@ - (recreate | default(false)) or (replace | default(false)) or (results | changed) - resources | length > 0 +# Replace will not create missing resources. We need to create here. + - name: "{{ template }}: Populate missing resources to {{project}} ({{ replace | default(false) | ternary('replace', 'create') }})" + shell: "oc process -n {{project}} -f '{{ template_path }}/{{template}}' {{ template_args | default('') }} | oc create -n {{project}} -f - {{ create_args | default('') }}" + when: + - (replace | default(false)) and (results | changed) + - resources | length > 0 + + run_once: true |