-
Notifications
You must be signed in to change notification settings - Fork 253
Open
Labels
Description
ISSUE TYPE
- Feature Idea
SOFTWARE VERSIONS
v3.1.1
Ansible:
2.10.12
Netbox:
NetBox v3.0-beta1
Collection:
SUMMARY
With graphQL read only API being integrated into NetBox, it only makes sense to create a lookup plugin.
SUGGESTED PARAMETERS
Following the standard Ansible module documentation:
Parameter | Choices/Defaults | Configuration | Comments |
---|---|---|---|
api_endpoint (string / required) | env:NETBOX_API / env:NETBOX_URL | ||
key_file (string) | |||
token (string) | env:NETBOX_TOKEN / env:NETBOX_API_TOKEN | ||
validate_certs (string) | Default: "yes" | Whether or not to validate SSL of the NetBox instance | |
query (string / required) | The GraphQL formatted query string | ||
variables (string) | Dictionary of keys/values to pass into the GraphQL query |
SUGGESTED RETURN VALUES
Key | Returned | Description |
---|---|---|
data (dictionary) | success | Data result from the GraphQL endpoint |
EXAMPLE USAGE
# Make API Query without variables
- name: SET FACT OF STRING
set_fact:
query_string: |
query {
site_list {
id
name
region {
name
}
}
}
# Make query to GraphQL Endpoint
- name: Obtain list of sites from NetBox
set_fact:
query_response: "{{ query('netbox.netbox.lookup_graphql', query=query, url='https://netbox.example.com', token='<redact>') }}"
# Example with variables
- name: Set Facts to send to graphQL endpoint
set_fact:
graph_variables:
site_name: NY
query_string: |
query ($site_name:String!) {
device_list(site: $site_name) {
id
name
}
}
# Get Response with variables
- name: Retrieve a list of devices from graphql
set_fact:
query_response: "{{ query('netbox.netbox.lookup_graphql', query_string, variables=graph_variables, url='https://netbox.example.com', token='<redact>') }}"
rvanmarkus, RyuuMasato, Len4i, madAndroid, gcotone and 7 more