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

Wait for VM startup using guest agent exec and cloud-init status --wait #1576

Open
bpg opened this issue Oct 5, 2024 Discussed in #389 · 1 comment
Open

Wait for VM startup using guest agent exec and cloud-init status --wait #1576

bpg opened this issue Oct 5, 2024 Discussed in #389 · 1 comment
Labels
✨ enhancement New feature or request

Comments

@bpg
Copy link
Owner

bpg commented Oct 5, 2024

Discussed in #389

Originally posted by satwell June 25, 2023
The PVE API exposes QEMU Guest Agent's "exec" support, which lets you execute a command on the guest as root. Is there some sensible way that support for this could be added to the provider?

Here's my use case. I'm using cloud-init for initial VM setup, but I'd like Terraform to wait until cloud-init has completed before considering creation complete. Cloud-init conveniently provides a cloud-init status --wait command that will run until cloud-init is done.

I could just use a remote-exec provisioner to connect to the VM and run that command. But that requires setting up an ssh connection to it. Which means the ssh port needs to be reachable, keys are set up, the the username matches what the cloud-init image uses, etc. It would be a lot cleaner if I could just use the guest agent for this.

In an ideal world, the proxmox provider would be able to define a new provisioner for VM resources that would use the guest agent to run commands. But from my quick investigation, it doesn't sound like there's any way in Terraform to create new provisioner types.

Are there other ways that would make sense to add support for the exec API? LIke an additional option in the vm resource type, or a new resource type? Or should I just find or write an external tool that uses the exec API and call it with a local-exec provisioner?

@bpg bpg added the ✨ enhancement New feature or request label Oct 5, 2024
@bpg
Copy link
Owner Author

bpg commented Oct 5, 2024

I think we can extend the agent block and add something like

agent {
  wait = "cloud-init"
}

Currently the provider implicitly waits on the network interfaces to be available, which may not work reliably for all possible configurations. We might be able to consolidate this checks in one place and configure them through this new wait attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
Status: ☑️ Todo
Development

No branches or pull requests

1 participant