Ansible collection for Nutanix length issue? | Nutanix Community
Skip to main content

Hi
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.ncp.ntnx_vms_info:
    nutanix_host: "{{ nutanix_host }}"
    nutanix_username: "{{ admin_secret.username }}"
    nutanix_password: "{{ admin_secret.secret }}"
    validate_certs: False
    filter:
      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
  set_fact:
    all_vms: "{{ all_vms | default( ]) + Â{ 'Name' : item.status.name, 'SUBNET_name': item.status.resources.nic_listE0].subnet_reference.name, 'NIC_UUID': item.status.resources.nic_listI0].uuid }] }}"
  with_items: "{{ result.response.entities }}" 

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].subnet_reference.name|default([])

we got passed that error at least.