-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Adding second NIC with ip_config hangs cloud_init / terraform ( tofu ) #1592
Comments
Some additional findings. It seems the network is configured by netplan and cloud-init puts the configuration in :
The snippet : results in something like: When the second snippet is added in the main.tf file as described above, the cloud-init file gets the correct info in it for the second network and everything works fine after boot. So the problem only occurs at first creation, not when adding it later. https://github.com/bpg/terraform-provider-proxmox/blob/main/proxmoxtf/provider/provider.go#L251 I'm suspecting it may be there where the issue starts. Did anyone else see and have this or better yet, can someone with Go knowledge see if the issue may start there ? I could start by looking at what the nodeAddress is, can someone point to instructions on how to deploy the provider with updated code ? Thank you |
I have been investigating further. Since the creation with terraform never finished and the settings I put in cloud-init did not give me access to the VM, I modified an image to have a root account so I can login at creation time. The terraform process is actually waiting for qemu-tools to reply. When I fix the network by using dhcpcd and install the package and start it, terraform continues and all looks good and as expected. This seems to indicate that cloud-init somehow is not able to get routing proper when using 2 NICS but also that if that can be fixed in the cloud init script, it may be solvable. The best solution would be to be able to find why cloud-init has an issue completing properly and perhaps even fix it there but as linked above, some people say that it is not supposed to provide access for automation. I tend to disagree because my automation may be run from another net and the VM needs the internet ( which is what I have now and why I encountered this behavior ). So far I have tried netplan apply and to add ipv6 = false without consistent success. Another workaround I used before is to get the 2nd interface from terraform and then run Ansible to run dhcpcd on the interface, but that doesn´t 'stick' either.
ad then in script that runs Ansible : which sets an Ansbile var that is used like :
I am gonna look a bit further into the best way to have the network configured properly and post, in the mean while, help and tips are appreciated :) |
Based on info on netplan and some reading I found an acceptable work around. In the cloud-config snippet, write to a file with netplan config:
Then at the top of runcmd add:
Creation takes a bit longer and for some reason the apt update command too, but this configures both interfaces the same as with the double snippet, but with working internet and thus qemu-tools. Perhaps good to add this to docs. This relies on the name of the interface, I am not aware of a way to get the mac or name before so it can used dynamically, but it's good enough for me. Any improvements are welcome and I can make a PR for the docs if that's appreciated. |
turns out there is something more needed because a route is added by default.
Now when I use a snippet like:
I also get a route set as default and as a consequence the same problem as with 2 dhcp snippets. If the use-routes: false option can be made part of the resource: As the documentation says, and probably better is to omit the gateway, then it does not add a route and everything works as expected. |
Describe the bug
When two networks are configured and the second has for example dhcp set, terraform doesn´t finish
To Reproduce
Steps to reproduce the behavior:
Add second snippet for 2nd interface:
Please also provide a minimal Terraform configuration that reproduces the issue.
and the output of
terraform|tofu apply
.Expected behavior
I would expect tofu to continue, even though the IP may not be fetched.
Additional context
Add any other context about the problem here.
This may be related to cloud-init:
https://forum.proxmox.com/threads/assign-multiple-ip-to-vm-using-cloud-init.116259/
And the other provider may have something similar and a solution:
Telmate/terraform-provider-proxmox#1015
Idealy the IP gets given but when this is not possible because of how cloud-init works, it just continuing and showing the issue seems like a good solution
TF_LOG=DEBUG terraform apply
):The text was updated successfully, but these errors were encountered: