orphan: |
---|
Note
This lookup plugin is part of the netbox.netbox collection (version 3.12.0).
To install it, use: ansible-galaxy collection install netbox.netbox
.
You need further requirements to be able to use this lookup plugin,
see :ref:`Requirements <ansible_collections.netbox.netbox.nb_lookup_lookup_requirements>` for details.
To use it in a playbook, specify: netbox.netbox.nb_lookup
.
.. rst-class:: ansible-version-added
New in netbox.netbox 0.1.0
- Queries NetBox via its API to return virtually any information capable of being held in NetBox.
The below requirements are needed on the local controller node that executes this lookup.
- pynetbox
.. rst-class:: ansible-option-table
Parameter | Comments |
---|---|
The NetBox object type to query |
.. rst-class:: ansible-option-table
Parameter | Comments |
---|---|
The URL to the NetBox instance to query .. rst-class:: ansible-option-line Configuration:
|
|
The api_filter to use. Filters should be key value pairs separated by a space. |
|
(DEPRECATED) - NetBox 2.11 and earlier only The location of the private key tied to user account. Mutually exclusive with private_key. |
|
The NetBox plugin to query |
|
(DEPRECATED) - NetBox 2.11 and earlier only The private key as a string. Mutually exclusive with key_file. |
|
Whether to return raw API data with the lookup/query or whether to return a key/value dict .. rst-class:: ansible-option-line Choices: |
|
The API token created through NetBox This may not be required depending on the NetBox setup. .. rst-class:: ansible-option-line Configuration:
|
|
Whether or not to validate SSL of the NetBox instance .. rst-class:: ansible-option-line Default: :ansible-option-default:`true` |
tasks:
# query a list of devices
- name: Obtain list of devices from NetBox
debug:
msg: >
"Device {{ item.value.display_name }} (ID: {{ item.key }}) was
manufactured by {{ item.value.device_type.manufacturer.name }}"
loop: "{{ query('netbox.netbox.nb_lookup', 'devices',
api_endpoint='http://localhost/',
token='<redacted>') }}"
# This example uses an API Filter
tasks:
# query a list of devices
- name: Obtain list of devices from NetBox
debug:
msg: >
"Device {{ item.value.display_name }} (ID: {{ item.key }}) was
manufactured by {{ item.value.device_type.manufacturer.name }}"
loop: "{{ query('netbox.netbox.nb_lookup', 'devices',
api_endpoint='http://localhost/',
api_filter='role=management tag=Dell'),
token='<redacted>') }}"
.. rst-class:: ansible-option-table
Key | Description |
---|---|
list of composed dictionaries with key and value .. rst-class:: ansible-option-line Returned: success |
- Chris Mills (@cpmills1975)
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.