Open rsjorslev opened 6 years ago
Looks like the provider is using find_first_free instead of reserve_first_free. Since find_first_free doesn't mark the addresses, it returns the same IP for all calls.
Hi, I'm surprised that only one person is requesting this feature. Has anybody find a way to use "count" to get X free different IPs? Is this the desired beaviour when you are using "phpipam_first_free_address" ?
Thanks!
Hi, I tried to develop a new datasource cloning "data_source_phpipam_first_free_address". What I do in this datasource is the same but executing "CreateAddress" at the end to make sure IP is allocated. Then, I add "count=N" in tf file, calling datasource cloned.
Problem: "count" terraform process are executed in parallel, so N procs request IP at the same time.
If I executed:
terraform apply -parallelism=1
I can get and "reserve" N ips, but is not a solution.
Problem here (as @pinacoelho said) is that IPAM has no method to get and reserve free IP in the same API Call.
Hi @jordips ,
A couple of years back, I had to fork the terraform provider and the go sdk to be able to run parallel tasks. I haven't kept up with terraform, nor PHPIPAM, but maybe you'll get enough there.
TL;DR - Added a ReserveFirstFree to the terraform plugin and the sdk.
https://github.com/pinacoelho/terraform-provider-phpipam https://github.com/pinacoelho/phpipam-sdk-go
Oohh god...I didn't realized POST method "addresses/first_free/{subnetid}" in https://phpipam.net/api/api_documentation 👎
Many thanks @pinacoelho, that's the way I wanted to do it.
How would I use this to get first free address for a resource im provisioning eg. 5 times?
My use case is provisioning 5 vSphere VMs cloned from a template and get 5 free addresses.
Im currently doing this:
and I have tried:
but that results in 3 resources with the same IP from phpIPAM.
thanks