label_node.yaml 1021 B

123456789101112131415161718192021222324252627
  1. ---
  2. - command: >
  3. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get node {{host}}
  4. -o jsonpath='{.metadata.labels.{{ label }}}'
  5. register: label_value
  6. failed_when: label_value.rc == 1 and 'exists' not in label_value.stderr
  7. when: not ansible_check_mode
  8. - command: >
  9. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}={{value}} --overwrite
  10. register: label_result
  11. failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
  12. when:
  13. - value is defined
  14. - label_value.stdout is defined
  15. - label_value.stdout != value
  16. - unlabel is not defined or not unlabel
  17. - not ansible_check_mode
  18. - command: >
  19. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}-
  20. register: label_result
  21. failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
  22. when:
  23. - unlabel is defined
  24. - unlabel
  25. - not ansible_check_mode