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

Unable to get device config_context using the the gql_inventory plugin #122

Closed
ubajze opened this issue Mar 3, 2022 · 1 comment · Fixed by #123
Closed

Unable to get device config_context using the the gql_inventory plugin #122

ubajze opened this issue Mar 3, 2022 · 1 comment · Fixed by #123
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation

Comments

@ubajze
Copy link
Contributor

ubajze commented Mar 3, 2022

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
pynautobot

1.0.4

Ansible:

2.9

Nautobot:

1.2.5

Collection:

v3.3.0

SUMMARY

I try to include config contexts in Ansible hosts using Nautobot dynamic inventory. I am using gql inventory plugin, but there is no way to include scalar values like config_context.

Here is a sample query that works using the in-browser gql tool.

query {
  devices {
  name
  platform {
    napalm_driver
  }
  status {
    name
  }
  primary_ip4 {
    address
  }
  device_role {
    name
  }
  site {
    name
  }
  interfaces {
    name
  }
 	config_context      <----- NO OPTION TO SPECIFY PARAMETERS LIKE THIS
}
}
STEPS TO REPRODUCE

I have the following inventory config:

# nautobot-inventory.yaml

plugin: networktocode.nautobot.gql_inventory
api_endpoint: http://172.20.0.6:8080
token: "xxxxxxx"
validate_certs: True
filters:
  site: mysite
additional_variables:
  - "config_context"
query:
  config_context: null

I run this command:

ansible-inventory -v --list -i nautobot-inventory.yaml

I also tried:

query:
  - config_context
query:
  config_context:

But none of these options work.

I think the problem is here in this template:
https://github.com/nautobot/nautobot-ansible/blob/develop/plugins/templates/graphql_additional_query.j2
It explicitly wants to have key:value pairs, which I cannot specify for config_context.

EXPECTED RESULTS

I want to see config_context under the device output, similar to what I can see in the in-browser gql tool.

            "mydevice": {
                "ansible_host": "mydevice",
                "ansible_network_os": "cisco.nxos.nxos",
                "device_role": {
                    "name": "spine"
                }
            },
ACTUAL RESULTS

I get an error or a config context is not present.

@jvanderaa
Copy link
Contributor

  1. Context data probably should not be included in an inventory. The goal of the inventory is to provide the specific connection information of the device. How to connect to it, and get connected. The gathering of the config_context should be done in the first tasks of the playbook.

  2. This would require an update to the GraphQL inventory plugin to support more. I thought we had an issue on this already, but do not. So this is an enhancement.

@jvanderaa jvanderaa added status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation labels Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation
Projects
None yet
2 participants