-
Notifications
You must be signed in to change notification settings - Fork 138
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
Duplicate IPs when creating multiple netbox_available_ip_address resources #59
Comments
My first guess would also be a race condition. I'll add a testcase and see if I can reproduce the error. |
Ok I also checked the code for the available IP resource. It basically uses the api to get ALL available IPs in the prefix, then picks the first one and creates that. To verify this, you could try two workarounds: Both these workarounds are not ideal and might not scale well. With the way the resource is implemented right now, I do not see any other options. |
On a side-note, this netbox-community/netbox#1246 discusses (and links the implementation) the endpoint that I actually expected to exist: One where you can just grab the next available IP from netbox and netbox handles the rest. Maybe we can rework the resource to use that instead. |
We can live with |
Hi, Same issue here. -parallelism=1 : not really an option for us, a lot of dependencies and resource to deploy, considerately increase the execution. Any other workaround in mind ? I don't find another one by myself. thanks! |
This should be reimplemented with more suitable API calls (already mentioned /api/ipam/prefixes/[prefix id]/available-ips/). In the mean time, my workaround was to use generic REST Terraform provider (e.g. Mastercard's restapi) to "get-and-reserve" one free IP. But this is far from optimal. |
…) and can now be created in netbox_ip_ranges (e-breuninger#105)
…) and can now be created in netbox_ip_ranges (e-breuninger#105)
…) and can now be created in netbox_ip_ranges (e-breuninger#105)
…) and can now be created in netbox_ip_ranges (e-breuninger#105)
@fbreckle was this ever tested after
|
@stanier, I've tried eight and 12, and can't reproduce in my v1.5.2. No duplicates when creating in either a prefix or range. Pls can you type |
@holmesb I am using v1.5.2. Could it be dependent on the version of Netbox? I'll see if I can find the code that was producing duplicates, but I actually just got done rewriting the functionality as a python heredoc, which solves the issue:
|
@holmesb here are the resources I had issues with
|
... That code works fine for me on v1.5.2 & Netbox v3.1.4. I also tried v1.6.1 & Netbox v3.1.9. |
Thanks, I'll look into experimenting with it some in the near future. The python script fix, though hacky, seems to be keeping things working for the moment. |
Terraform Version
terraform v0.13.2
provider v0.2.0
netbox: v2.11.7
Affected Resource(s)
netbox_available_ip
Terraform Configuration Files
Expected Behavior
Two distinct IP addresses created. 10.0.0.1/24 & 10.0.0.2/24
Actual Behavior
2 x 10.0.0.1/24
Important Factoids
If I delete
netbox_available_ip_address.main2
(comment it out and apply), then recreate it, it will correctly create a fresh IP: 10.0.0.2/24. So I suspect a race-condition when multiple are created in the same execution.Might be of interest to @pezhore
The text was updated successfully, but these errors were encountered: