Browse Source

fix 1519808. Only annotate ops projects when openshift_logging_use_ops=true

jcantrill 7 years ago
parent
commit
86a74a9b64

+ 11 - 8
roles/openshift_logging/tasks/annotate_ops_projects.yaml

@@ -1,17 +1,20 @@
 ---
-- oc_obj:
-    state: list
-    kind: project
-    name: "{{ item }}"
-  with_items: "{{ __default_logging_ops_projects }}"
+- command: >
+    {{ openshift.common.client_binary }}
+    --config={{ openshift.common.config_base }}/master/admin.kubeconfig
+    get namespaces -o jsonpath={.items[*].metadata.name} {{ __default_logging_ops_projects | join(' ') }}
   register: __logging_ops_projects
 
 - name: Annotate Operations Projects
   oc_edit:
     kind: ns
-    name: "{{ item.item }}"
+    name: "{{ project }}"
     separator: '#'
     content:
       metadata#annotations#openshift.io/logging.ui.hostname: "{{ openshift_logging_kibana_ops_hostname }}"
-  with_items: "{{ __logging_ops_projects.results }}"
-  when: item.results.stderr is not defined
+  with_items: "{{ __logging_ops_projects.stdout.split(' ') }}"
+  loop_control:
+    loop_var: project
+  when:
+  - __logging_ops_projects.stderr | length == 0
+  - openshift_logging_use_ops | default(false) | bool

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

@@ -107,6 +107,24 @@
     - logging-fluentd
     - logging-mux
 
+# remove annotations added by logging
+- command: >
+    {{ openshift.common.client_binary }}
+    --config={{ openshift.common.config_base }}/master/admin.kubeconfig
+    get namespaces -o name {{ __default_logging_ops_projects | join(' ') }}
+  register: __logging_ops_projects
+
+- name: Remove Annotation of Operations Projects
+  command: >
+    {{ openshift.common.client_binary }}
+    --config={{ openshift.common.config_base }}/master/admin.kubeconfig
+    annotate {{ project }} openshift.io/logging.ui.hostname-
+  with_items: "{{ __logging_ops_projects.stdout_lines }}"
+  loop_control:
+    loop_var: project
+  when:
+    - __logging_ops_projects.stderr | length == 0
+
 ## EventRouter
 - include_role:
     name: openshift_logging_eventrouter