Terraform wait_for_ip Flag Returning APIPA Address
-
When using Terraform to deploy a Windows VM I need to be able to connect to the host to finalize OS configuration settings. To connect to the host I am using an inline provisioner that is connecting via WinRM with the host connection using the output of the network ipv4 address.
connection { type = "winrm" user = var.username password = var.password host = element(xenorchestra_vm.qa-vm1.network[0].ipv4_addresses, 0) }
I set the wait_for_ip flag to true so I could use the returned IP address
resource "xenorchestra_vm" "qa-vm1" { cpus = var.cpu memory_max = var.memMax name_label = var.vmDesc name_description = var.vmName hvm_boot_firmware = "uefi" wait_for_ip = true template = data.xenorchestra_template.vm_template.id
but it returns a 169.254.126.62 address and attempts to connect via that address until the apply times out or is cancelled
Still creating... [1m10s elapsed] Still creating... [1m20s elapsed] (remote-exec): Connecting to remote host via WinRM... (remote-exec): Host: 169.254.126.62 (remote-exec): Port: 5985 (remote-exec): User: jsmith (remote-exec): Password: true (remote-exec): HTTPS: false (remote-exec): Insecure: false (remote-exec): NTLM: false (remote-exec): CACert: false
XCP-NG tools are installed on this host and I can see it reporting the IP address correctly in Xen Orchestra.
Is there a setting I can use to refresh this address so it updates to use the proper DHCP IP of this host or possibly a way to use a sleep timer to wait for the IP to be assigned and show through the XCP-NG tools?
-
@ddelnano is this something you may be able to help with?
-
@dan89 yep, I'm the right person for terraform-provider-xenorchestra features or issues
There aren't any settings to accomplish what you are trying to do, but I think that's feasible and would be a nice addition. The current
wait_for_ip
logic exits once the Xen Orchestra api returns a ip address field. If the vm resource had additional information, sayexpected_ip_cidr = 10.0.0.0/16
, then the provider could continue polling until the DHCP assignment completes.resource "xenorchestra_vm" "qa-vm1" { cpus = var.cpu memory_max = var.memMax name_label = var.vmDesc name_description = var.vmName hvm_boot_firmware = "uefi" wait_for_ip = true expected_ip_cidr = "10.0.0.0/16" # wait_for_ip will continue to poll until the XO api shows that the VM has an IP in that range }
Please let me know if this would satisfy your use case and I can probably investigate implementing that over the next few weeks. I'll be creating a GitHub issue for this and linking it here once it's created.
-
@ddelnano yes, having an expected CIDR field would cover this use case perfectly.
-
@ddelnano do you need any additional information or is this enough to work off of?
-
@dan89 this is enough to work off and I appreciate your review. Here is the GitHub issue where I'll be tracking the implementation (vatesfr/terraform-provider-xenorchestra#300).
-
@dan89 this is complete and available in v0.29.0 of the provider.