Browse Source

delete idempotent

ewolinetz 8 years ago
parent
commit
427d4c235c

+ 21 - 0
roles/openshift_logging/tasks/delete_logging.yaml

@@ -14,17 +14,24 @@
     - routes
     - templates
     - daemonset
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
+
 
 # delete the oauthclient
 - name: delete oauthclient kibana-proxy
   command: >
     {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig delete oauthclient kibana-proxy --ignore-not-found=true
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete any image streams that we may have created
 - name: delete logging is
   command: >
     {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
     delete is -l logging-infra=support -n {{ openshift_logging_namespace }} --ignore-not-found=true
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete our old secrets
 - name: delete logging secrets
@@ -38,6 +45,8 @@
     - logging-kibana-proxy
     - logging-curator
   ignore_errors: yes
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete role bindings
 - name: delete rolebindings
@@ -46,6 +55,8 @@
     delete rolebinding {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
   with_items:
     - logging-elasticsearch-view-role
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete cluster role bindings
 - name: delete cluster role bindings
@@ -54,6 +65,8 @@
     delete clusterrolebindings {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
   with_items:
     - rolebinding-reader
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete cluster roles
 - name: delete cluster roles
@@ -62,6 +75,8 @@
     delete clusterroles {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
   with_items:
     - rolebinding-reader
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete our service accounts
 - name: delete service accounts
@@ -73,6 +88,8 @@
     - aggregated-logging-kibana
     - aggregated-logging-curator
     - aggregated-logging-fluentd
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete our roles
 - name: delete roles
@@ -81,6 +98,8 @@
     delete clusterrole {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
   with_items:
     - daemonset-admin
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
 
 # delete our configmaps
 - name: delete configmaps
@@ -91,3 +110,5 @@
     - logging-curator
     - logging-elasticsearch
     - logging-fluentd
+  register: delete_result
+  changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0

+ 1 - 0
roles/openshift_logging/tasks/label_node.yaml

@@ -26,3 +26,4 @@
   - unlabel is defined
   - unlabel
   - not ansible_check_mode
+  - label_value.stdout != ""