Hi,
i want to look in to the external ipam feature and extend it with an provider for NetBox
im not sure whats the right approach to contribute the code. should i extend the existing smart_proxy_ipam from @grizzthedj with the stuff for netbox?
Or should i create a new smart_proxy_ipam_netbox ?
The right approach is to extend the existing smart_proxy_ipam, however, there needs to be a refactoring of that implementation before additional providers can be added effectively. What sort of timeline were you looking to implement Netbox as a provider?
when i try this out, the smart proxy correctly sends a 404 if a ip is not allocated in external ipam
2020-07-31T16:05:00 0371b8ba [I] Finished GET /ipam/subnet/10.100.60.0/24/10.100.60.3 with 404 (413.5 ms)
but foreman throws an error
Creating IPv4 in External IPAM for norma-dolbin.whatever.internal task failed with the following error: ERF12-7024 [ProxyAPI::ProxyException]: Unable to obtain IP address for subnet_id 10.100.60.0/24 from External IPAM. ([RestClient::NotFound]: 404 Not Found) for proxy https://tfm-katello-t01.whatever.de:9090/ipam
it would be good to have the possibility to enrich the ipam system with more Information than it an ip is in use and its mac address.
the hosts fqdn or a link to the hosts page in foreman would be good.
if i got this correctly the ip cache feature relies on mac addresses
when creating a foreman host with vmware, the mac address is not available till the vm is deployed.
right now, if i create two host parallel without a mac address filled in the race condition still applies
The error handling needs a major overhaul, both on the Foreman and Smart Proxy side. It is full of layer violations. Quite often the error from the backend system is sent all the way to Foreman. The point you found is a good example of that.
This is very recent, there might be dragons. The plugin is not official yet.
Sure, work with @grizzthedj on extending it. Although Iād slightly prefer making everything more robust, creating 2nd implementation, settling down on the final API and moving this into theforeman github organization.
Interesting, yeah. Itās a bug. The API probably needs to be extended with some UUID flag and VMs would use VM UUID instead.
Managed to smart_proxy_ipam working as a plugin after some fiddling, only to find out the Netbox API has changed so the interaction is currently broken.
@dmgeurts Iām also interested in this, but as youāve already gone through the process of getting it up and running, maybe this plugin will do the trick:
Also, could you share your notes on how to make it actually work? I didnāt come further then the following:
I attempted it on a Satellite 6.11 system in my lab, which uses Foreman 3.1 underneath, but Foreman doesnāt want to start afterwards because (it seems) it canāt find certain files.
My prior suspicions about the Netbox API having changed are probably wrong. I now think the IPAM plugin wrongly tries to use the phpIPAM API when talking to Netbox.
Aug 15 00:04:46 fm smart-proxy[1273044]: 2022-08-15 00:04:46 - JSON::ParserError - 783: unexpected token at '<!DOCTYPE HTML>
[...]
Aug 15 00:04:47 fm smart-proxy[1273044]: #011/usr/local/share/gems/gems/smart_proxy_ipam-0.1.4/lib/smart_proxy_ipam/netbox/netbox_client.rb:48:in `get_ipam_subnet_by_cidr'
Aug 15 00:04:47 fm smart-proxy[1273044]: #011/usr/local/share/gems/gems/smart_proxy_ipam-0.1.4/lib/smart_proxy_ipam/netbox/netbox_client.rb:29:in `get_ipam_subnet'
Aug 15 00:04:47 fm smart-proxy[1273044]: #011/usr/local/share/gems/gems/smart_proxy_ipam-0.1.4/lib/smart_proxy_ipam/ipam_api.rb:100:in `block in <class:Api>'
[...]
Aug 15 00:04:47 fm smart-proxy[1273044]: 10.0.0.10 - - [15/Aug/2022:00:04:45 CEST] "GET /ipam/subnet/10.0.1.0/24?group= HTTP/1.1" 500 590509
Aug 15 00:04:47 fm smart-proxy[1273044]: - -> /ipam/subnet/10.0.1.0/24?group=
All Iāve been trying to do is add subnets known in Netbox to Foreman so that IPAM details can be kept in sync. We donāt register our hosts in Netbox but if Foreman can automate this then we may start doing so, but this is not an immediate need for us.
That said, itās good to know that thereās work on integrating the CMDB aspect of Netbox into Foreman.
Thanks for the details @dmgeurts - I have posted a response to get more specific info in the github issue you opened. We can continue the conversation there, then report the fix back here once resolved.
Has any thought been put into pushing the hostname of the machine being built to the IPAM solution? I have been working on adding support for Bluecat IPAM, but it requires the hostname to add a record.
Some other users have also requested this. I think there is some value in having hostname, and potentially some other fields passed over as well.
Since the IPAM plugin integration is on its way into Smart Proxy core(the PR is above in this thread), I think it would make sense to wait until this is merged before doing anything.