nutanix / nutanix.ansible

Official Nutanix Ansible collections
GNU General Public License v3.0
61 stars 34 forks source link

[Bug] Partial Subnet List Retrieval in module ntnx_subnets_info #466

Closed PPadgett closed 4 months ago

PPadgett commented 4 months ago

Describe the bug When utilizing the 'Nutanix.ncp' Ansible Collection, specifically with the 'ntnx_subnet_info' task, it only retrieves a partial list of Nutanix subnets instead of the full list that is confirmed to exist and be configured within our environment.

To Reproduce Steps to reproduce the behavior:

  1. Use the Ansible command to execute a playbook that includes the 'ntnx_subnets_info' task.
  2. Here is a sample of the playbook used:

    tasks:
    - name: List Nutanix subnets currently deployed
      ntnx_subnets_info:
        kind: subnet
      register: existing_cluster_subnets
      ignore_errors: false

Stack trace

ansible-playbook [core 2.14.9]
  config file = [REDACTED - User-specific directory path]
  configured module search path = [REDACTED - Default and user-defined module paths]
  ansible python module location = [REDACTED - Python library path]
  ansible collection location = [REDACTED - Ansible collections path]
  executable location = [REDACTED - Ansible executable path]
  python version = 3.9.14 (main, Jan  9 2023, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2.1.0.1)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
Using [REDACTED - Configuration file path] as config file
setting up inventory plugins
[REDACTED - Information about inventory parsing and setup]
Parsed [REDACTED - Inventory source path] inventory source with ini plugin
Loading collection nutanix.ncp from [REDACTED - Collection path]
[REDACTED - Module redirections and loading]

PLAYBOOK: info-nutanix-subnet-Location.yaml ***************************************
Positional arguments: info-nutanix-subnet-Location.yaml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ([REDACTED - Inventory path])
forks: 5
1 plays in info-nutanix-subnet-Location.yaml

PLAY [Location Nutanix cluster subnet info playbook] ******************************

TASK [List Nutanix subnets currently deployed] *********************************
task path: [REDACTED - Task path]
[WARNING]: Platform linux on host localhost is using the discovered Python
interpreter at /bin/python3.9, but future installation of another Python
interpreter could change the meaning of that path. See
[REDACTED - Link to Ansible documentation]
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
[REDACTED - Python interpreter discovery and module execution details]
ok: [localhost] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/bin/python3.9"
    },
    "changed": false,
    "error": null,
    "invocation": {
        "module_args": {
            "kind": "subnet",
            "nutanix_host": "[REDACTED - Server hostname]",
            "nutanix_password": "[REDACTED - Sensitive information]",
            "nutanix_port": "9440",
            "nutanix_username": "[REDACTED - Service account username]",
            "validate_certs": false
        }
    },
    "response": {
        "api_version": "3.1",

        "metadata": {
            "kind": "subnet",
            "length": 20,
            "offset": 0,
            "total_matches": 98
        }
    }
}

[REDACTED - Remaining tasks and outputs, including task details, debug information, and module execution, while ensuring sensitive information related to inventory paths, usernames, hostnames, and file paths are removed or replaced with generic placeholders.]

PLAY RECAP *********************************************************************
localhost                  : ok=11   changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Expected behavior The expectation is for the 'ntnx_subnets_info' task to retrieve a comprehensive list of all configured and existing Nutanix subnets, without omitting any subnets.

Additional context The issue persists regardless of the kind parameter setting, indicating it may not be related to the specific type of subnet being queried but potentially to how the collection interfaces with Nutanix API or processes the retrieved data.

bhati-pradeep commented 4 months ago

Hi @PPadgett , Have you tried length param ? I am trying length parameter and it is giving expected response from my lab setup. I have 48 subnets in my setup. Querying for 40 subnets.

Task:

  tasks:
    - name: subnets info
      ntnx_subnets_info:
        length: 40
      register: result
    - debug:
        var: result

Response: Screenshot 2024-03-01 at 6 46 28 PM

bhati-pradeep commented 4 months ago

@PPadgett If you have already tried length : 98 then can you once try some less number like 40-50 with two calls using offset ? Trying to check if its a processing issue or not due to large size of response from server

PPadgett commented 4 months ago

I wanted to express my heartfelt gratitude for your prompt and effective support in resolving the issue related to the ‘ntnx_subnet_info’ task within the Ansible Collection. Adding the length fixed the issue..