devon_mar.nblists.list lookup – Returns an array of IPs/prefixes
Note
This lookup plugin is part of the devon_mar.nblists collection (version 0.3.1).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install devon_mar.nblists.
To use it in a playbook, specify: devon_mar.nblists.list.
New in devon_mar.nblists 0.1.0
Synopsis
This lookup returns IPs/prefixes from the NetBox lists plugin for NetBox.
Terms
Parameter |
Comments |
|---|---|
The NetBox lists endpoint(s). For example, This is the part that comes after See the plugin section of the API documentation of your NetBox instance for all endpoints. |
Keyword parameters
This describes keyword parameters of the lookup. These are the values key1=value1, key2=value2 and so on in the following
examples: lookup('devon_mar.nblists.list', key1=value1, key2=value2, ...) and query('devon_mar.nblists.list', key1=value1, key2=value2, ...)
Parameter |
Comments |
|---|---|
If Choices:
Configuration:
|
|
Arbitrary key_value is not an actual option for this lookup plugin. Use a |
|
Path to the Netbox Lists API root. To be appended to url_. Default: Configuration:
|
|
The NetBox API token. Configuration:
|
|
The URL to the NetBox instance with the Lists plugin. Configuration:
|
Note
Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) 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. The entry types are also ordered by precedence from low to high priority order. For example, an ansible.cfg entry (further up in the list) is overwritten by an Ansible variable (further down in the list).
Notes
Note
When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters:
lookup('devon_mar.nblists.list', term1, term2, key1=value1, key2=value2)andquery('devon_mar.nblists.list', term1, term2, key1=value1, key2=value2)
Examples
- name: Get all NetBox IP addresses with the tag 'special'
ansible.builtin.debug:
msg: "{{ q('devon_mar.nblists.list', 'ip-addresses', tag='special') }}"
- name: Manually specify a token and URL.
ansible.builtin.debug:
msg: "{{ q('devon_mar.nblists.list', 'ip-addresses', tag='special', url_='https://netbox.example.com', token_='abc123') }}"
# Build an ACL using all NetBox prefixes with the role 'data'
- name: Build ACL 10
ansible.builtin.set_fact:
acl_10_aces: "{{ acl_10_aces | default([]) + ace }}"
vars:
ace:
- grant: permit
source:
address: "{{ item | ansible.utils.ipaddr('network') }}"
wildcard_bits: "{{ item | ansible.utils.ipaddr('wildcard') }}"
loop: "{{ q('devon_mar.nblists.list', 'prefixes', role='data') }}"
- name: Ensure ACLs are configured
cisco.ios.ios_acls:
config:
- afi: ipv4
acls:
- name: 10
aces: "{{ acl_10_aces }}"
Return Value
Key |
Description |
|---|---|
The list of IPs/prefixes. Returned: success |