---
- name: Retrieve list of schedulable nodes matching selector
  oc_obj:
    state: list
    kind: node
    selector: "{{ openshift_master_ensure_nodes_selector }}"
    field_selector: "spec.unschedulable!=true"
  register: __schedulable_nodes_matching_selector

- name: "Ensure that {{ openshift_master_ensure_nodes_service }} has nodes to run on"
  assert:
    that: "{{ __schedulable_nodes_matching_selector['module_results']['results'][0]['items'] | default([]) | length != 0 }}"
    msg: |-
      No schedulable nodes found matching node selector for {{ openshift_master_ensure_nodes_service }} - '{{ openshift_master_ensure_nodes_selector }}'
