summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/intersight/playbooks
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cisco/intersight/playbooks')
-rw-r--r--ansible_collections/cisco/intersight/playbooks/count_vms.yml26
1 files changed, 26 insertions, 0 deletions
diff --git a/ansible_collections/cisco/intersight/playbooks/count_vms.yml b/ansible_collections/cisco/intersight/playbooks/count_vms.yml
new file mode 100644
index 000000000..9590a4804
--- /dev/null
+++ b/ansible_collections/cisco/intersight/playbooks/count_vms.yml
@@ -0,0 +1,26 @@
+---
+- name: Get count
+ hosts: localhost
+ connection: local
+ gather_facts: false
+ vars:
+ # Create an anchor for api_info that can be used throughout the file
+ api_info: &api_info
+ # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
+ # and INTERSIGHT_API_URI environment variables used for API key data
+ api_private_key: "{{ api_private_key | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
+ api_uri: "{{ api_uri | default(omit) }}"
+ validate_certs: "{{ validate_certs | default(omit) }}"
+ tasks:
+ # Get a count of the VM hosts
+ - name: "Get VM Count"
+ cisco.intersight.intersight_rest_api:
+ <<: *api_info
+ resource_path: /virtualization/VirtualMachines
+ query_params:
+ $count: true
+ register: resp
+ - name: "Print VM count"
+ ansible.builtin.debug:
+ msg: "VM count {{ resp.count }}"