summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/intersight/playbooks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:18:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:18:34 +0000
commit3667197efb7b18ec842efd504785965911f8ac4b (patch)
tree0b986a4bc6879d080b100666a97cdabbc9ca1f28 /ansible_collections/cisco/intersight/playbooks
parentAdding upstream version 9.5.1+dfsg. (diff)
downloadansible-3667197efb7b18ec842efd504785965911f8ac4b.tar.xz
ansible-3667197efb7b18ec842efd504785965911f8ac4b.zip
Adding upstream version 10.0.0+dfsg.upstream/10.0.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 }}"