Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL inventory plugin - using group_by can crash if there are empty values #151

Closed
joewesch opened this issue Jul 28, 2022 · 0 comments · Fixed by #153
Closed

GraphQL inventory plugin - using group_by can crash if there are empty values #151

joewesch opened this issue Jul 28, 2022 · 0 comments · Fixed by #153
Assignees

Comments

@joewesch
Copy link
Contributor

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
pynautobot

1.0.4

Ansible:

2.10.17

Nautobot:

1.3.9

Collection:

4.0.0

SUMMARY

When using the group_by option to automatically group items based on a specific value, if any of the values are not present in the return values you get an error and the inventory is not processed.

STEPS TO REPRODUCE
  • Create a platform that doesn't have a Napalm driver
  • Create a device with previously created platform
  • Create an inventory file as such:
---
plugin: networktocode.nautobot.gql_inventory
api_endpoint: https://demo.nautobot.com
token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
group_by:
  - platform.napalm_driver
EXPECTED RESULTS

It should return the inventory and all devices that have a platform with a Napalm driver defined are grouped by that driver's value - all other devices should be ungrouped.

ACTUAL RESULTS

The inventory fails to parse:

❯ ansible-inventory -i inventory.joe.yml --list     
[WARNING]:  * Failed to parse /root/nautobot-ansible/inventory.joe.yml with ansible_collections.networktocode.nautobot.plugins.inventory.inventory plugin: Incorrect plugin name in file: networktocode.nautobot.gql_inventory
[WARNING]:  * Failed to parse /root/nautobot-ansible/inventory.joe.yml with ansible_collections.networktocode.nautobot.plugins.inventory.gql_inventory plugin: Invalid empty/false group name provided:
[WARNING]:  * Failed to parse /root/nautobot-ansible/inventory.joe.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /root/nautobot-ansible/inventory.joe.yml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML file.
[WARNING]: Unable to parse /root/nautobot-ansible/inventory.joe.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant