Error Inventory Dynamic Script

Latest response

Folks,

I'm having trouble trying to get the hosts through a python script.

With the same script I am able to obtain data from two other hosts.

NOTE: The provider are nutanix clusters.

the script link is at: https://github.com/zanoniluiz/ansible-nutanix-inventory

The nutanix cluster in question is in the same version as the other two clusters.

When I run the script I get the following result:

[root @ srv-ansible-app-prd test-nutanix] # ansible-inventory -i nutanix.py --list
[WARNING]: * Failed to parse /root/test-nutanix/nutanix.py with script plugin: failed to parse executable inventory script results from / root / test-
nutanix / nutanix.py: Syntax Error while loading YAML. found unexpected ':' The error appears to be in '': line 1, column 36617, but may be elsewhere in the
file depending on the exact syntax problem.
[WARNING]: * Failed to parse /root/test-nutanix/nutanix.py with ini plugin: /root/test-nutanix/nutanix.py:3: Expected key = value host variable assignment, got: os
[WARNING]: Unable to parse /root/test-nutanix/nutanix.py as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_goal": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}

attached I am putting the result of the script with the two hosts that I have not reported the error

Responses

[root@srv-ansible-app-prd inventory-nutanix]# ansible-inventory -i hosts --list
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user
configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
{
    "_meta": {
        "hostvars": {
            "debian test": {
                "acropolisVm": true,
                "clusterUuid": "0005874a-cfbc-da86-0000-000000027d23",
                "consistencyGroupName": "Debian Test",
                "containerIds": [
                    "0005874a-cfbc-da86-0000-000000027d23::7664"
                ],
                "containerUuids": [
                    "6b1e0ef0-98ec-4cbc-9248-0bd7df8130cb"
                ],.................

I managed to solve the problem.

The script generates an error JSON result.

By editing the script so that the --pretty option is the default, the problem has been solved.