set_default_node_role.yml 843 B

123456789101112131415161718192021
  1. ---
  2. - delegate_to: '{{ openshift_master_host }}'
  3. run_once: true
  4. block:
  5. - name: Retrieve non-infra, non-master nodes that are not yet labeled compute
  6. oc_obj:
  7. state: list
  8. kind: Node
  9. selector: '{{ (openshift_hosted_infra_selector | default("node-role.kubernetes.io/infra=true")) | regex_replace("=", "!=") }},node-role.kubernetes.io/master!=true,node-role.kubernetes.io/compute!=true'
  10. register: non_master_non_infra_nodes_result
  11. - name: label non-master non-infra nodes compute
  12. oc_label:
  13. name: '{{ item }}'
  14. kind: node
  15. state: add
  16. labels:
  17. - key: node-role.kubernetes.io/compute
  18. value: 'true'
  19. with_items: "{{ non_master_non_infra_nodes_result.results.results.0['items'] | map(attribute='metadata') | map(attribute='name') | list }}"