Ansible collection for Nutanix length issue?

  • 24 November 2023
  • 2 replies

From my playbook using admin/password from vault to connect to PC and then list vms. From that result I select data and use in set_fact. When using length up to like 30 it seems to work, but I have like 200 VMs and I cannot see why thats is failiing, I would like to get all vms and not need to state length..


- name: List VMS
    nutanix_host: "{{ nutanix_host }}"
    nutanix_username: "{{ admin_secret.username }}"
    nutanix_password: "{{ admin_secret.secret }}"
    validate_certs: False
      cluster_name: D2SEELM-NXC001   #testing only to select one cluster
      #vm_name: D2SEELM-LX0266
    kind: vm    #integer and default value in API
  #  sort_attribute: string
  #  sort_order: ASCENDING
    length: 30  #string
    offset: 0
  register: result
  no_log: "{{ ansible_debug }}"



- name: Collect VM values from file
    all_vms: "{{ all_vms | default([]) + [{ 'Name' :, 'SUBNET_name': item.status.resources.nic_list[0], 'NIC_UUID': item.status.resources.nic_list[0].uuid }] }}"
  with_items: "{{ result.response.entities }}" 

This topic has been closed for comments

2 replies

So found out that I get to much data like for 20VMs its 6000 rows, so when doing length like 100 → to much data for the module-ish. So, If I were to go length 1 and from the values below, loop through all vms?

metadata": {
            "filter": "cluster_name==NXC001",
            "total_matches": 111,
            "kind": "vm",
            "length": 1,
            "offset": 0

How would such a loop look like?

Found the issue why the PB did fail, we had one VM without network nic, so with:
'SUBNET_name': item.status.resources.nic_list[0]|default([])

we got passed that error at least.