hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
96 stars 93 forks source link

`vsphere-iso`: `ip_settle_timeout` does not honor values beyond 25m/1500s #362

Closed usmcguy closed 5 months ago

usmcguy commented 8 months ago

When filing a bug please include the following headings, if possible.

packer version 1.10.0 vsphere plugin version 1.2.4

Overview of the Issue

I have a builder configured to install Windows Server. I am using a script that sets a static IP. Before set, it has a 169.#.#.# address. An IP isnt available for packer until about 35m mark. To prevent using 169.x IP, I have tried using the ip_settle_timeout. Since it takes longer than 30m, I also set the ip_wait_timeout to be a bit longer, 37m. When I set the ip_settle_timeout to 25m or lower, it works as expected, but since I havent set the static IP at that point, it tries to use the 169.X address. But any value beyond 25m, packer is stuck waiting for an IP, before it ultimately times out at 37m. I have tried using seconds vs defining as minutes, but it makes no difference.

Simplified Packer Buildfile

packer { required_version = "1.10.0" required_plugins { vsphere = { version = ">= 1.2.4" source = "github.com/hashicorp/vsphere"
}
} } source "vsphere-iso" "VM01" { vcenter_server = var.vsphere_server username = var.vsphere_user password = var.vsphere_password datacenter = var.datacenter cluster = var.cluster insecure_connection = true vm_name = "VM01" folder = "/MDT" guest_os_type = "windows2019srv_64Guest"
firmware = "efi"
CPUs = 1 cpu_cores = 1 CPU_hot_plug = true RAM = 16384 disk_controller_type = ["lsilogic-sas"] datastore = var.datastore storage { disk_size = 104800 disk_thin_provisioned = true } iso_paths = [ "[myDataStore] ISO/Server2019.iso", "[myDataStore] ISO/VMware-tools-windows-12.3.5-22544099.iso", "[myDataStore] ISO/Baseline_2024_01_31.iso" ] network_adapters { network = var.network_name network_card = "vmxnet3" } communicator = "winrm" winrm_username = "${var.winrm_username}" winrm_password = "${var.winrm_password}" winrm_timeout = "${var.winrm_timeout}" winrm_use_ssl = true winrm_insecure = true winrm_use_ntlm = true
boot_command = [""]
floppy_files = [ "answerFiles/2019/autounattend.xml", "scripts/installVMwareTools.cmd" ] ip_wait_timeout = "37m" ip_settle_timeout = "35m"
disable_shutdown = true shutdown_timeout = "1h15m" } build { sources = [ "source.vsphere-iso.VM01" ] provisioner "windows-restart" { restart_timeout = "5m" } }

Packer Version

1.10.0

Plugin Version and Builders

1.2.4

Please select the builder.

vsphere-iso

VMware vSphere Version

8.0.2

Guest Operating System

Windows Server 2019

Log Fragments and crash.log Files

https://gist.github.com/usmcguy/ee53101f52bbef3c37424d42170e3d58

tenthirtyam commented 8 months ago

Out of curiosity, is there a reason that the IP would take such a long time to be applied to the OS?

One method you can use it's to apply the configuration to the autoattend.xml file but pass in the desired configuration by using a pkptpl.hcl file to generate it "on the fly" and apply the IP configuration early.

tenthirtyam commented 8 months ago

If you want to see how you can do a portion of this, take a look at my project here - of course you'd need to add the IP configuration variables and then pass them into the template for the .xml.

usmcguy commented 8 months ago

When the OS comes up after install, its finishing a MDT Task Sequence. We are trying to avoid having to replace MDT all together. So thats the reason it takes that amount of time. The last step is setting the IP.

tenthirtyam commented 5 months ago

Hi @usmcguy 👋🏻 -

Have you tried setting ip_wait_address to an range that you'd want wait for an IP in that range?

By default it's 0.0.0.0/0" and the APIPA169.254.0.0-169.254.255.255` range wouild be included?

...

variable "vsphere_ip_wait_address" {
  type    = string
  default = "172.16.11.0/24"
}

...

source "vsphere-iso" "windows" {
  ...
  ip_wait_address     = var.vsphere_ip_wait_address
  ...
}

Ryan

tenthirtyam commented 5 months ago

Hello! 👋

This issue has not received any update from the OP in the last 7 days.

Please review the provided suggestion for use of ip_wait_address and feel free to comment and/or reopen this issue if the issue persists.