netbox-as-ansible-inventory icon indicating copy to clipboard operation
netbox-as-ansible-inventory copied to clipboard

Feature Request : Device interfaces as host_vars

Open liorfranko opened this issue 6 years ago • 1 comments

Can you add the device interfaces as host_vars?

liorfranko avatar Nov 27 '17 07:11 liorfranko

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)?

marioland avatar Feb 28 '18 15:02 marioland