Timeout : No Ip address

When i run packer build -var-file=variables.pkrvar.pcl . i get

Waiting for IP…
==> vsphere-iso.linux-ubuntu: timeout waiting for IP address
==> vsphere-iso.linux-ubuntu: timeout waiting for IP address
==> vsphere-iso.linux-ubuntu: Step “StepWaitForIp” failed.
im seeing that the vm is at least created, and dhcp should be giving the ip address. do i need to explicitly state this somehow? the files are listed below

variables.pkvar.hcl
vsphere_endpoint = “”
vsphere_username = “”
vsphere_password = “”
vsphere_insecure_connection = true

vsphere_datacenter = “”
#vsphere_cluster= “”

vsphere_host= “”

vsphere_datastore = “”
vsphere_folder = “”
vsphere_resource_pool = “”
vsphere_set_host_for_datastore_uploads = false

vm_name = “Ubuntu Gold”
guest_os_type = “ubuntu64Guest”

cpu_count = 2
cpu_cores = 1
mem_size= 1024
disk_size = 10240 # 10GB
vsphere_network= “VM Network 10.105.5.0/24”
network_card = “vmxnet3”

firmware = “efi”
cdrom_type = “sata”
disk_controller_type = [“pvscsi”]

ip_wait_timeout = “3m”
ip_settle_timeout = “3m”

common_shutdown_timeout = “5m”

ssh_username = “nteladmin”
ssh_password = “packer”
ssh_port= 22
ssh_timeout= “5m”

boot_wait = “45s”
#boot_order = [“disk”, “cdrom”]

shutdown_timeout = “1m”

iso_datastore_path = “[newiso] Linux/ubuntu-24.04-desktop-amd64.iso”
iso_file = “ubuntu-24.04-desktop-amd64.iso”
common_data_source= “disk”

variables.pkr.hcl

Packer Variables Configuration

variable “vsphere_endpoint” {
type = string
description = “The endpoint for the vSphere server (e.g., https://vcenter.local)”
}

variable “vsphere_username” {
type = string
description = “The username to authenticate to vSphere”
}

variable “vsphere_password” {
type = string
description = “The password to authenticate to vSphere”
sensitive = true
}

variable “vsphere_insecure_connection” {
type = bool
description = “Whether to allow insecure SSL connections to vSphere”
default = false
}

variable “vsphere_datacenter” {
type = string
description = “The vSphere datacenter name”
}

#variable “vsphere_cluster” {

type = string

#description = “The vSphere cluster name”

}

variable “vsphere_host” {
type = string
description = “The vSphere host name”
}

variable “vsphere_datastore” {
type = string
description = “The vSphere datastore where the VM will reside”
}

variable “vsphere_folder” {
type = string
description = “The folder where the VM will be stored in vSphere”
}

variable “vsphere_resource_pool” {
type = string
description = “The resource pool where the VM will be allocated in vSphere”
}

variable “vsphere_set_host_for_datastore_uploads” {
type = bool
description = “Whether to set the vSphere host for datastore uploads”
default = false
}

variable “vm_name” {
type = string
description = “The name of the virtual machine”
}

variable “guest_os_type” {
type = string
description = “The guest OS type (e.g., ‘ubuntu64’)”
}

variable “firmware” {
type = string
description = “The firmware type (‘bios’ or ‘efi’)”
}

variable “cpu_count” {
type = number
description = “The number of CPUs for the virtual machine”
default = 1
}

variable “cpu_cores” {
type = number
description = “The number of CPU cores per virtual CPU”
default = 1
}

variable “mem_size” {
type = number
description = “The amount of memory (in MB) for the virtual machine”
default = 1024
}

variable “cdrom_type” {
type = string
description = “The type of CD-ROM (e.g., ‘cdrom’)”
}

variable “disk_controller_type” {
type = list(string)
description = “The type of disk controller (e.g., ‘scsi’)”
default = [“pvscsi”]
}

variable “disk_size” {
type = number
description = “The size of the virtual machine disk (in MB)”
default = 10240
}

variable “disk_thin_provisioned” {
type = bool
description = “Whether the virtual machine disk is thin-provisioned”
default = true
}

variable “vsphere_network” {
type = string
description = “The network to which the virtual machine should be connected”
}

variable “network_card” {
type = string
description = “The type of network card to be used (e.g., ‘vmxnet3’)”
}

variable “boot_order” {
type = string
description = “The boot order for the virtual machine”
default = “disk,cdrom”
}

variable “boot_wait” {
type = string
description = “The wait time before booting the VM”
default = “45s”
}

variable “ip_wait_timeout” {
type = string
description = “The timeout for waiting for an IP address”
default = “5m”
}

variable “ip_settle_timeout” {
type = string
description = “The timeout for IP address settlement”
default = “5m”
}

variable “common_shutdown_timeout” {
type = string
description = “The timeout for shutting down the virtual machine”
default = “5m”
}

variable “ssh_username” {
type = string
description = “The SSH username to use for provisioning the VM”
}

variable “ssh_password” {
type = string
description = “The SSH password to use for provisioning the VM”
sensitive = true
}

variable “ssh_port” {
type = number
description = “The SSH port for communication”
default = 22
}

variable “ssh_timeout” {
type = string
description = “The timeout for SSH connections”
default = “5m”
}

variable “iso_datastore_path” {
type = string
description = “The path to the ISO file in the datastore”
}

variable “common_data_source” {
type = string
description = “The data source for common settings (‘disk’ or other)”
default = “disk”
}

ubuntu-24.04.pkr.hcl
packer {
required_version = “>= 1.12.0”
required_plugins {
vsphere = {
source = “github.com/hashicorp/vsphere
version = “>= 1.4.2”
}
}
}

Define the builder configuration block

source “vsphere-iso” “linux-ubuntu” {

vCenter Server Endpoint Settings and Credentials

vcenter_server = var.vsphere_endpoint
username = var.vsphere_username
password = var.vsphere_password
insecure_connection = var.vsphere_insecure_connection

vSphere Settings

datacenter = var.vsphere_datacenter
#cluster = var.vsphere_cluster
host = var.vsphere_host
datastore = var.vsphere_datastore
folder = var.vsphere_folder

resource_pool = var.vsphere_resource_pool

set_host_for_datastore_uploads = var.vsphere_set_host_for_datastore_uploads

Virtual Machine Settings

vm_name = var.vm_name
guest_os_type = var.guest_os_type
firmware = var.firmware
CPUs = var.cpu_count
cpu_cores = var.cpu_cores
RAM = var.mem_size
cdrom_type = var.cdrom_type
disk_controller_type = var.disk_controller_type

Storage Configuration

storage {
disk_size = var.disk_size
disk_thin_provisioned = var.disk_thin_provisioned
}

Network Configuration

network_adapters {
network = var.vsphere_network
network_card = var.network_card
}

Boot Order and Provisioning

#boot_order = var.vm_boot_order
boot_wait = var.boot_wait

boot_command = [“e”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “linux /casper/vmlinuz — autoinstall ds="nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"”, “initrd /casper/initrd”, “boot”, “”]

ip_wait_timeout = var.ip_wait_timeout
ip_settle_timeout = var.ip_settle_timeout
shutdown_command = “echo ‘${var.ssh_password}’ | sudo -S -E shutdown -P now”
shutdown_timeout = var.common_shutdown_timeout

Communicator Settings

communicator = “ssh”
ssh_username = var.ssh_username
ssh_password = var.ssh_password
ssh_port = var.ssh_port
ssh_timeout = var.ssh_timeout

ISO Configuration

#iso_urls = [ubuntu-24.04-desktop-amd64.iso]
iso_paths = [var.iso_datastore_path]
#cd_content = var.common_data_source == “disk” ? local.data_source_content : null

Clean-up CDROM after install

remove_cdrom = true
}

Define the build block to use the defined source

build {
sources = [“vsphere-iso.linux-ubuntu”]
}

Hi,
Assuming you’re on VMware, have you looked at your VM while it’s being built? I assume you’re installing the VMware-Tools at some stage, right? Without them, the vCenter won’t get the IP address of your VM anyhow, hence Packer will continue waiting.
Cheers,
Régis