I am currently using the netbox ansible module to pull interface information from Cisco devices into Netbox. So far I have managed to pull in the interfaces and basic information like their MAC addresses.
Is there a way that you can get the untagged and tagged VLANS on each port and push them into netbox too?
This is my current ansible playbook:
---
- name: "PLAY 1: ADD INTERFACES TO NETBOX AND CLEANUP TEMP"
connection: network_cli
hosts: platforms_ios
tags: [ ios ]
tasks:
- name: "TASK 1: IOS >> GET IOS FACTS"
ios_facts:
gather_subset: "!config"
when: "ansible_network_os == 'ios'"
- name: "TASK 2: NETBOX >> ADD INTERFACES TO NETBOX"
netbox.netbox.netbox_device_interface:
netbox_url: "<netbox url>"
netbox_token: "<netbox_token>"
data:
device: "{{ inventory_hostname }}"
name: "{{ item.key }}"
form_factor: "{{ item.key | get_interface_type }}"
mac_address: "{{ item.value.macaddress | convert_mac_address }}"
state: present
with_dict:
- "{{ ansible_facts['net_interfaces'] }}"
loop_control:
label: "{{ item.key }}"
netbox.netbox.netbox_device_interface
has options for untagged_vlan:
and tagged_vlans:
in their documentation. I am unsure if this information can be provided from ansible however.