XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Terraform wait_for_ip Flag Returning APIPA Address

    Scheduled Pinned Locked Moved Infrastructure as Code
    7 Posts 2 Posters 1.6k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      dan89
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • D Offline
        dan89
        last edited by

        @ddelnano is this something you may be able to help with?

        D 1 Reply Last reply Reply Quote 0
        • D Offline
          ddelnano Terraform Team @dan89
          last edited by

          @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, say expected_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.

          D 2 Replies Last reply Reply Quote 1
          • D Offline
            dan89 @ddelnano
            last edited by

            @ddelnano yes, having an expected CIDR field would cover this use case perfectly.

            1 Reply Last reply Reply Quote 1
            • D Offline
              dan89 @ddelnano
              last edited by

              @ddelnano do you need any additional information or is this enough to work off of?

              D 1 Reply Last reply Reply Quote 0
              • D Offline
                ddelnano Terraform Team @dan89
                last edited by ddelnano

                @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).

                D 1 Reply Last reply Reply Quote 0
                • D Offline
                  ddelnano Terraform Team @ddelnano
                  last edited by

                  @dan89 this is complete and available in v0.29.0 of the provider.

                  1 Reply Last reply Reply Quote 0
                  • nick.lloydN nick.lloyd referenced this topic on

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post