Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ansible facts to populate data? #25

Closed
gardar opened this issue Oct 13, 2019 · 9 comments
Closed

Use ansible facts to populate data? #25

gardar opened this issue Oct 13, 2019 · 9 comments
Labels
question Further information is requested

Comments

@gardar
Copy link

gardar commented Oct 13, 2019

Are there any plans to have the option to gather data about a device with ansible facts and then use the facts to populate device/inventory data in netbox?

I'm sorry if this has already been discussed or if it's perhaps already possible, I only took a quick glance and it didn't seem like it's possible currently.

@FragmentedPacket
Copy link
Contributor

This should already be possible as you would just pass the necessary data into the Netbox modules that are obtained from whatever fact gathering is done. There might have to be some data normalization that needs to happen to work with the modules, though.

@gardar
Copy link
Author

gardar commented Oct 14, 2019

Yes I understand that I can technically put what ever data I need into the netbox modules and use that, I was more curious if there would be an "official" way so to speak on the roadmap.

@FragmentedPacket
Copy link
Contributor

Not at the moment. One of my colleagues is working on using Batfish to import data into Netbox using these modules, but nothing on the roadmap to be included within this repo.

Not sure when that project will be open sourced as it's still be developed, but you can watch the demonstration from NFD. NFD21 - Look at the Network to Code Network Automation Journey – Part 1.

If i'm off base on what you're asking, please provide an example!

@FragmentedPacket FragmentedPacket added the question Further information is requested label Oct 14, 2019
@gardar
Copy link
Author

gardar commented Oct 14, 2019

Well not sure if you are off base but I'll explain what I'm asking a little better anyways.

What I'm trying to achieve is to use ansible to provide details about devices in netbox automatically, the way I see it is that at first ansible would connect to the device I want to add to netbox and gather facts about the device, then it would use those facts to create or update the device and the inventory items of the device.
I'm looking into this from the point of view of servers, but I see networking devices would benefit from it too.
In most cases the facts from ansible should be able to provide details about the name of the device, the operating system, cpu, ram, disk usage, network interfaces and ips, etc.

This would basically be the same thing ansible-cmdb does but it would populate the information in netbox rather than ansible-cmdb ( https://github.com/fboender/ansible-cmdb )
Another project to take a look at would be the netbox_agent ( https://github.com/Solvik/netbox_agent ) which does provide the data into netbox, but does require the agent set up on the servers, and as such won't be useful for networking devices.

@FragmentedPacket
Copy link
Contributor

Thanks for the explanation and examples.

That is definitely not something this collection is looking to accomplish. It's just a way to use Ansible to populate Netbox via Ansible. It can definitely be used as an interface for such projects.

The furthest this collection will go away from that is inventory/lookup plugins.

@cpmills1975
Copy link
Contributor

Reading through the blog article on the new network features coming in Ansible 2.9, it might be worth looking in to whether these modules could take the, now standard, data structures that the Ansible network modules will produce/consume and record the details against a named device in Netbox.

@remyd1
Copy link

remyd1 commented Sep 16, 2022

This thread is a bit old, but I would need exactly the same kind of playbook using this module. It seems that there is no official way to do it even if it seems to be possible (I saw some stuff using this module with network device to gather device informations and import it using the netbox API).

Any news about it ?

@gardar
Copy link
Author

gardar commented Sep 16, 2022

This thread is a bit old, but I would need exactly the same kind of playbook using this module. It seems that there is no official way to do it even if it seems to be possible (I saw some stuff using this module with network device to gather device informations and import it using the netbox API).

Any news about it ?

I actually created my own Ansible role for this, but I have not made it public (yet).
While the idea for the role sounds simple it turned out to be quite involved and I've still got a few things to iron out until I feel comfortable publishing it.

@remyd1
Copy link

remyd1 commented Sep 16, 2022

Ok. Please keep us inform about it. In the meantime, I created a basic python script to create a csv file for interfaces, but it is not really helpful...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants