label_node.yaml 1.0 KB

1234567891011121314151617181920212223242526272829
  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. changed_when: no
  9. - command: >
  10. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}={{value}} --overwrite
  11. register: label_result
  12. failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
  13. when:
  14. - value is defined
  15. - label_value.stdout is defined
  16. - label_value.stdout != value
  17. - unlabel is not defined or not unlabel
  18. - not ansible_check_mode
  19. - command: >
  20. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node {{host}} {{label}}-
  21. register: label_result
  22. failed_when: label_result.rc == 1 and 'exists' not in label_result.stderr
  23. when:
  24. - unlabel is defined
  25. - unlabel
  26. - not ansible_check_mode
  27. - label_value.stdout != ""