summaryrefslogtreecommitdiffstats
path: root/roles/openshift_logging/tasks/label_node.yaml
blob: bd5073381e2670cd31ef7f63ada8f5a1e6be29ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
- 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_value.stdout != ""