We have moved this collection to a different namespace and collection name on Ansible Galaxy. The new versions will be at netbox.netbox.
To keep the code simple, we only officially support the two latest releases of NetBox and don't guarantee backwards compatibility beyond that. We do try and keep these breaking changes to a minimum, but sometimes changes to NetBox's API cause us to have to make breaking changes.
- NetBox 2.5+ or the two latest NetBox releases
- pynetbox 4.2.5+
- Python 3.6+
- Ansible 2.9+
- netbox_aggregate
- netbox_circuit
- netbox_circuit_termination
- netbox_circuit_type
- netbox_cluster
- netbox_cluster_group
- netbox_cluster_type
- netbox_device_bay
- netbox_device_interface
- netbox_device_role
- netbox_device_type
- netbox_device
- netbox_inventory_item
- netbox_ip_address
- netbox_ipam_role
- netbox_manufacturer
- netbox_platform
- netbox_prefix
- netbox_provider
- netbox_rack_group
- netbox_rack_role
- netbox_rack
- netbox_region
- netbox_rir
- netbox_site
- netbox_service
- netbox_tenant_group
- netbox_tenant
- netbox_virtual_machine
- netbox_vm_interface
- netbox_vlan_group
- netbox_vlan
- netbox_vrf
- netbox lookup plugin
- netbox inventory plugin (0.1.5)
- Install via Galaxy
ansible-galaxy collection install netbox.netbox
- Install via source
git clone git@github.com:netbox-community/ansible_modules.gitcd ansible_modulesansible-galaxy collection build .ansible-galaxy collection install netbox-netbox-X.X.X.tar.gz- Can add
-pto provide a different path other than the default path, but it must be within youransible.cfgor provided via an environment variable.
- Can add
Using the collections at the play level
- name: "Test NetBox modules"
connection: local
hosts: localhost
gather_facts: False
collections:
- netbox.netbox
tasks:
- name: Create device within NetBox with only required information
netbox_device:
netbox_url: http://netbox-demo.org:32768
netbox_token: 0123456789abcdef0123456789abcdef01234567
data:
name: Test66
device_type: Cisco Test
device_role: Core Switch
site: Test Site
status: Staged
state: presentUsing the collections at the task level
- name: "Test NetBox modules"
connection: local
hosts: localhost
gather_facts: False
tasks:
- name: Create device within NetBox with only required information
netbox.netbox.netbox_device:
netbox_url: http://netbox-demo.org:32768
netbox_token: 0123456789abcdef0123456789abcdef01234567
data:
name: Test66
device_type: Cisco Test
device_role: Core Switch
site: Test Site
status: Staged
state: presentUsing the collections in a role's task files
---
- name: Create device within NetBox with only required information
netbox.netbox.netbox_device:
netbox_url: http://netbox-demo.org:32768
netbox_token: 0123456789abcdef0123456789abcdef01234567
data:
name: Test66
device_type: Cisco Test
device_role: Core Switch
site: Test Site
status: Staged
state: present
OR
---
- name: Create device within NetBox with only required information
collections:
- netbox.netbox
netbox_device:
netbox_url: http://netbox-demo.org:32768
netbox_token: 0123456789abcdef0123456789abcdef01234567
data:
name: Test66
device_type: Cisco Test
device_role: Core Switch
site: Test Site
status: Staged
state: presentUsing the collections lookup plugin at the task level
- name: "TEST NETBOX_LOOKUP"
connection: local
hosts: localhost
gather_facts: False
tasks:
- name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites"
assert:
that: "{{ query_result|count }} == 3"
vars:
query_result: "{{ query('nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}"