nutanix / nutanix.ansible

Official Nutanix Ansible collections
GNU General Public License v3.0
64 stars 36 forks source link

[Bug] fail to get dynamic inventory for more > 50/90 VMs in module ntnx_prism_vms_inventory #483

Closed nahsiy closed 1 month ago

nahsiy commented 3 months ago

Following the migration of our central prism from pc.2022.6.7 to 2024.1, our ntnx_prism_vms_inventory plugin no longer works without an explicit error, as soon as we set a lenght of more than 50/90.

Via curl or postman, it works for 500 VMs, which seems to be the limit.

our inventory code :


plugin: nutanix.ncp.ntnx_prism_vm_inventory
strict: false
nutanix_hostname: "{{cluster}}""
nutanix_port: "" # Make sure the port is correct
validate_certs: false
data: {"offset": 0, "length": 1000}
groups:
  vm_OFF: "'OFF' in power_state"
  vm_NGT: "'INSTALLED' in guest_tools.nutanix_guest_tools.ngt_state"
keyed_groups:
  - prefix: "vm_ZONE"
    separator: ':'
    key: "ntnx_categories.ZONE"
  - prefix: "vm_SITE"
    separator: ':'
    key: "ntnx_categories.SITE"
  - prefix: "vm_OS"
    separator: ':'
    key: "ntnx_categories.OS"
  - prefix: "vm_MCO"
    separator: ':'
    key: "ntnx_categories.MCO"

before this migration, we had no problem recovering all the VMs in our cluster (554VMS) with this configuration

bhati-pradeep commented 2 months ago

@nahsiy Can you share error log which you are facing ?

nahsiy commented 2 months ago

Hello,

inventory

(For lengh = 1000)

ansible-inventory -i 00-nutanix.yaml --list

[WARNING]: * Failed to parse /home/cmassieu/Documents/gitlab/fr-ansible/00-nutanix.yaml with auto plugin: 'Mock_Module' object has no attribute 'fail_json' [WARNING]: * Failed to parse /home/cmassieu/Documents/gitlab/fr-ansible/00-nutanix.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory [WARNING]: * Failed to parse /home/cmassieu/Documents/gitlab/fr-ansible/00-nutanix.yaml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML file. [WARNING]: Unable to parse /home/cmassieu/Documents/gitlab/fr-ansible/00-nutanix.yaml as an inventory source [WARNING]: No inventory was parsed, only implicit localhost is available { "_meta": { "hostvars": {} }, "all": { "children": [ "ungrouped" ] } }

Regards

Yishan

stahnjones commented 2 months ago

500 entities appears to be the internal hard-coded limit for a single API call in V3 API

bhati-pradeep commented 2 months ago

Hi @stahnjones, for length > 500 in vms, it internally takes care of it by doing multiple api calls to fetch give number of vms.

For this ticket, issue was pc slowness causing timeout while doing list calls. We have a ticket open for override timeout : https://github.com/nutanix/nutanix.ansible/issues/409

@nahsiy can we close this ticket for now and track capability of increasing timeout in above mentioned ticket ?

nahsiy commented 1 month ago

Hello @bhati-pradeep,

Yes, thanks a lot !