Browse Source

Updating oc_apply changed_when conditions, fixing filter usage for openshift_hosted_logging playbook

ewolinetz 8 years ago
parent
commit
64423cc6a7

+ 1 - 1
playbooks/common/openshift-cluster/openshift_hosted.yml

@@ -55,4 +55,4 @@
   - include_role:
       name: openshift_hosted_logging
       tasks_from: update_master_config
-    when: openshift_hosted_logging_deploy | default(false) | boola
+    when: openshift_hosted_logging_deploy | default(false) | bool

+ 14 - 13
roles/openshift_logging/tasks/oc_apply.yaml

@@ -18,6 +18,17 @@
   failed_when: "'error' in generation_apply.stderr"
   changed_when: no
 
+- name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
+  shell: >
+    {{ openshift.common.client_binary }} --config={{ kubeconfig }}
+    get {{file_content.kind}} {{file_content.metadata.name}}
+    -o jsonpath='{.metadata.resourceVersion}'
+    -n {{namespace}} || echo 0
+  register: generation_changed
+  changed_when: generation_changed.stdout | int  > generation_init.stdout | int
+  when:
+    - "'field is immutable' not in generation_apply.stderr"
+
 - name: Removing previous {{file_name}}
   command: >
     {{ openshift.common.client_binary }} --config={{ kubeconfig }}
@@ -25,25 +36,15 @@
     -n {{ namespace }}
   register: generation_delete
   failed_when: "'error' in generation_delete.stderr"
-  changed_when: no
+  changed_when: generation_delete.rc == 0
   when: "'field is immutable' in generation_apply.stderr"
 
-- name: Applying {{file_name}}
+- name: Recreating {{file_name}}
   command: >
     {{ openshift.common.client_binary }} --config={{ kubeconfig }}
     apply -f {{ file_name }}
     -n {{ namespace }}
   register: generation_apply
   failed_when: "'error' in generation_apply.stderr"
-  changed_when: no
+  changed_when: generation_apply.rc == 0
   when: "'field is immutable' in generation_apply.stderr"
-
-- name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
-  shell: >
-    {{ openshift.common.client_binary }} --config={{ kubeconfig }}
-    get {{file_content.kind}} {{file_content.metadata.name}}
-    -o jsonpath='{.metadata.resourceVersion}'
-    -n {{namespace}} || echo 0
-  register: generation_changed
-  failed_when: "'error' in generation_changed.stderr"
-  changed_when: generation_changed.stdout | int  > generation_init.stdout | int