Browse Source

Check rc for commands with openshift_client_binary and failed_when

This might mask some failures and continue instead of a failure
Vadim Rutkovsky 7 years ago
parent
commit
edc4a03f14

+ 1 - 1
roles/calico_master/tasks/main.yml

@@ -23,7 +23,7 @@
     -f {{ mktemp.stdout }}/calico-policy-controller.yml
     --config={{ openshift.common.config_base }}/master/admin.kubeconfig
   register: calico_create_output
-  failed_when: ('already exists' not in calico_create_output.stderr) and ('created' not in calico_create_output.stdout)
+  failed_when: "('already exists' not in calico_create_output.stderr) and ('created' not in calico_create_output.stdout) and calico_create_output.rc != 0"
   changed_when: ('created' in calico_create_output.stdout)
 
 - name: Calico Master | Delete temp directory

+ 6 - 2
roles/openshift_metrics/tasks/oc_apply.yaml

@@ -16,7 +16,9 @@
     apply -f {{ file_name }}
     -n {{namespace}}
   register: generation_apply
-  failed_when: "'error' in generation_apply.stderr"
+  failed_when:
+    - "'error' in generation_apply.stderr"
+    - "generation_apply.rc != 0"
   changed_when: no
 
 - name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
@@ -28,5 +30,7 @@
   register: version_changed
   vars:
     init_version: "{{ (generation_init is defined) | ternary(generation_init.stdout, '0') }}"
-  failed_when: "'error' in version_changed.stderr"
+  failed_when:
+    - "'error' in version_changed.stderr"
+    - "version_changed.rc != 0"
   changed_when: version_changed.stdout | int  > init_version | int

+ 1 - 1
roles/openshift_persistent_volumes/tasks/pv.yml

@@ -13,5 +13,5 @@
     --config={{ mktemp.stdout }}/admin.kubeconfig
   register: pv_create_output
   when: persistent_volumes | length > 0
-  failed_when: ('already exists' not in pv_create_output.stderr) and ('created' not in pv_create_output.stdout)
+  failed_when: "('already exists' not in pv_create_output.stderr) and ('created' not in pv_create_output.stdout) and pv_create_output.rc != 0"
   changed_when: ('created' in pv_create_output.stdout)

+ 1 - 1
roles/openshift_persistent_volumes/tasks/pvc.yml

@@ -13,5 +13,5 @@
     --config={{ mktemp.stdout }}/admin.kubeconfig
   register: pvc_create_output
   when: persistent_volume_claims | length > 0
-  failed_when: ('already exists' not in pvc_create_output.stderr) and ('created' not in pvc_create_output.stdout)
+  failed_when: "('already exists' not in pvc_create_output.stderr) and ('created' not in pvc_create_output.stdout) and pvc_create_output.rc != 0"
   changed_when: ('created' in pvc_create_output.stdout)

+ 9 - 3
roles/openshift_provisioners/tasks/oc_apply.yaml

@@ -15,7 +15,9 @@
     apply -f {{ file_name }}
     -n {{ namespace }}
   register: generation_apply
-  failed_when: "'error' in generation_apply.stderr"
+  failed_when:
+    - "'error' in generation_apply.stderr"
+    - "generation_apply.rc != 0"
   changed_when: no
 
 - name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
@@ -36,7 +38,9 @@
     delete -f {{ file_name }}
     -n {{ namespace }}
   register: generation_delete
-  failed_when: "'error' in generation_delete.stderr"
+  failed_when:
+    - "'error' in generation_delete.stderr"
+    - "generation_delete.rc != 0"
   changed_when: generation_delete.rc == 0
   when: generation_apply.rc != 0
 
@@ -46,6 +50,8 @@
     apply -f {{ file_name }}
     -n {{ namespace }}
   register: generation_apply
-  failed_when: "'error' in generation_apply.stderr"
+  failed_when:
+    - "'error' in generation_apply.stderr"
+    - "generation_apply.rc != 0"
   changed_when: generation_apply.rc == 0
   when: generation_apply.rc != 0