Przeglądaj źródła

Modify playbooks to use oc_label module

Russell Teague 8 lat temu
rodzic
commit
1e0ec746a7

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

@@ -1,52 +0,0 @@
----
-- command: >
-    {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get node {{host}}
-    -o jsonpath='{.metadata.labels}'
-  register: node_labels
-  when: not ansible_check_mode
-  changed_when: no
-
-- command: >
-    {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}={{value}}
-  register: label_result
-  failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
-  when:
-  - value is defined
-  - node_labels.stdout is defined
-  - label not in node_labels.stdout
-  - unlabel is not defined or not unlabel
-  - not ansible_check_mode
-
-- command: >
-    {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get node {{host}}
-    -o jsonpath='{.metadata.labels.{{ label }}}'
-  register: label_value
-  ignore_errors: yes
-  changed_when: no
-  when:
-  - value is defined
-  - node_labels.stdout is defined
-  - label in node_labels.stdout
-  - unlabel is not defined or not unlabel
-  - not ansible_check_mode
-
-- command: >
-    {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}={{value}} --overwrite
-  register: label_result
-  failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
-  when:
-  - value is defined
-  - label_value.stdout is defined
-  - label_value.stdout != value
-  - unlabel is not defined or not unlabel
-  - not ansible_check_mode
-
-- command: >
-    {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}-
-  register: label_result
-  failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
-  when:
-  - unlabel is defined
-  - unlabel
-  - not ansible_check_mode
-  - label in node_labels.stdout

+ 5 - 11
roles/openshift_logging/tasks/start_cluster.yaml

@@ -10,11 +10,11 @@
   when: "'--all' in openshift_logging_fluentd_hosts"
 
 - name: start fluentd
-  include: label_node.yaml
-  vars:
-    host: "{{fluentd_host}}"
-    label: "{{openshift_logging_fluentd_nodeselector.keys()[0]}}"
-    value: "{{openshift_logging_fluentd_nodeselector.values()[0]}}"
+  oc_label:
+    name: "{{ fluentd_host }}"
+    kind: node
+    state: add
+    label: "{{ openshift_logging_fluentd_nodeselector | oo_dict_to_list_of_dict }}"
   with_items: "{{ openshift_logging_fluentd_hosts }}"
   loop_control:
     loop_var: fluentd_host
@@ -30,7 +30,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 1
   with_items: "{{es_dc.stdout_lines}}"
   loop_control:
@@ -47,7 +46,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: "{{ openshift_logging_kibana_replica_count | default (1) }}"
   with_items: "{{kibana_dc.stdout_lines}}"
   loop_control:
@@ -64,7 +62,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 1
   with_items: "{{curator_dc.stdout_lines}}"
   loop_control:
@@ -81,7 +78,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 1
   with_items: "{{es_dc.stdout_lines}}"
   loop_control:
@@ -99,7 +95,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: "{{ openshift_logging_kibana_ops_replica_count | default (1) }}"
   with_items: "{{kibana_dc.stdout_lines}}"
   loop_control:
@@ -117,7 +112,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 1
   with_items: "{{curator_dc.stdout_lines}}"
   loop_control:

+ 5 - 11
roles/openshift_logging/tasks/stop_cluster.yaml

@@ -9,11 +9,11 @@
   when: "'--all' in openshift_logging_fluentd_hosts"
 
 - name: stop fluentd
-  include: label_node.yaml
-  vars:
-    host: "{{fluentd_host}}"
-    label: "{{openshift_logging_fluentd_nodeselector.keys()[0]}}"
-    unlabel: True
+  oc_label:
+    name: "{{ fluentd_host }}"
+    kind: node
+    state: absent
+    label: "{{ openshift_logging_fluentd_nodeselector | oo_dict_to_list_of_dict }}"
   with_items: "{{ openshift_logging_fluentd_hosts }}"
   loop_control:
     loop_var: fluentd_host
@@ -28,7 +28,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 0
   with_items: "{{es_dc.stdout_lines}}"
   loop_control:
@@ -44,7 +43,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 0
   with_items: "{{kibana_dc.stdout_lines}}"
   loop_control:
@@ -60,7 +58,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 0
   with_items: "{{curator_dc.stdout_lines}}"
   loop_control:
@@ -76,7 +73,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 0
   with_items: "{{es_dc.stdout_lines}}"
   loop_control:
@@ -93,7 +89,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 0
   with_items: "{{kibana_dc.stdout_lines}}"
   loop_control:
@@ -110,7 +105,6 @@
     kind: dc
     name: "{{object.split('/')[1]}}"
     namespace: "{{openshift_logging_namespace}}"
-    kubeconfig: "{{mktemp.stdout}}/admin.kubeconfig"
     replicas: 0
   with_items: "{{curator_dc.stdout_lines}}"
   loop_control:

+ 0 - 3
roles/openshift_manage_node/tasks/main.yml

@@ -31,7 +31,6 @@
     name: "{{ openshift.node.nodename }}"
     kind: node
     state: list
-    kubeconfig: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
   register: get_node
   until: "'metadata' in get_node.results.results[0]"
   retries: 50
@@ -43,7 +42,6 @@
   oadm_manage_node:
     node: "{{ openshift.node.nodename | lower }}"
     schedulable: "{{ 'true' if openshift.node.schedulable | bool else 'false' }}"
-    kubeconfig: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
   retries: 10
   delay: 5
   register: node_schedulable
@@ -57,7 +55,6 @@
     kind: node
     state: add
     labels: "{{ openshift.node.labels | oo_dict_to_list_of_dict }}"
-    kubeconfig: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
     namespace: default
   when:
     - "'nodename' in openshift.node"