aabouzaid / netbox-as-ansible-inventory

Ansible dynamic inventory script for Netbox.
GNU General Public License v3.0
174 stars 54 forks source link

Feature Request : Device interfaces as host_vars #9

Open liorfranko opened 6 years ago

liorfranko commented 6 years ago

Can you add the device interfaces as host_vars?

marioland commented 6 years ago

I have the same requirement: get an inventory of all devices with all their interfaces.

You can run the script python netbox.py -c netbox.interfaces.yml --list and in the netbox.interfaces.yml you set api_url: 'http://netbox/api/dcim/interfaces/?device_id=1' But then you have only the interfaces of one device.

When trying to get all devices with all its interfaces I would get a naming conflict in the host_vars, because interfaces on different devices have the same name.

I could then call the script one time for all the devices and then again for per device for its interfaces. But this logic is a few lines of python code. I don't know how to do this purely in ansible.

Or is there a way to use this script in one shot( get an inventory of all devices with all their interfaces)?