list_cluster_uuids.yml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ---
  2. # Calls Prism Central to obtain a list of clusters
  3. # Returns a list of dictionaries containing the name and uuid of the clusters
  4. # Example output:
  5. # [
  6. # {'name': 'ntx-web', 'uuid': '00053e3-0255-d94a-457a-ecf4bdfgfb8g0'},
  7. # {'name': 'ntx-app', 'uuid': '00522e15-0234-d94a-457a-ecf4bbdfb8g1'}
  8. # ]
  9. - name: Get clusters list
  10. uri:
  11. url: "{{ pc_api_url }}/clusters/list"
  12. body:
  13. kind: cluster
  14. sort_order: ASCENDING
  15. offset: 0
  16. length: 10
  17. sort_attribute: ''
  18. method: POST
  19. validate_certs: no
  20. body_format: json
  21. status_code: 200
  22. headers:
  23. Cookie: "{{ pc_session_cookie }}"
  24. register: json_clusters_result
  25. ignore_errors: yes
  26. - name: Store the cluster names/UUIDs
  27. set_fact:
  28. cluster_uuids: "{{ cluster_uuids|default([]) + [ {'name': item.spec.name, 'uuid': item.metadata.uuid } ] }}"
  29. with_items: "{{ json_clusters_result.json.entities }}"
  30. - name: Debug | Print cluster name/UUIDs
  31. debug:
  32. msg: "Cluster names/uuids : {{ cluster_uuids }}"
  33. when: global_debug|bool