Building a debian10 template without DHCP [vsphere-iso]

since yesterday i try to build a debian10 template on my vcenter.
i don’t have a dhcp on my server network so in the preseed.cfg i use a static ip but, it looks like the preseed.cfg is not taken.
I get a “waiting for IP” on packer and in the vsphere remote console the vm try to lease a dhcp IP.
the boot command seems to be fonctionnal.
and the packer http server to (http://X.X.X.X:XXXX/preseed.cfg OK)

do any of you have the same issue?

Hm, is the network interface/ card connected? Can you ping the vm at the time Packer is waiting for a connection?
Do you have a log file/ output and can you share your template for creating this image? Maybe the preseed.cfg, too. :slight_smile:

yes the network card is connected.
no, the vm is not pingable.

the template:
“builders”: [
“type”: “vsphere-iso”,
“vcenter_server”: “{{user vcenter-server}}”,
“username”: “{{user vcenter-username}}”,
“password”: “{{user vcenter-password}}”,
“insecure_connection”: “true”,
“datacenter”: “{{user datacenter}}”,
“vm_name”: “{{user vm-name}}”,
“datastore”: “{{user datastore}}”,
“folder”: “{{user folder}}”,
“host”: “{{user host}}”,
“cluster”: “{{user cluster}}”,
“convert_to_template”: “true”,
“network_adapters”: [
“network”: “{{user network}}”,
“network_card”: “vmxnet3”
“boot_order”: “disk,cdrom”,
“guest_os_type”: “debian10_64Guest”,
“ssh_username”: “{{user ssh-username}}”,
“ssh_password”: “{{user ssh-password}}”,
“CPUs”: “{{user vm-cpu-num}}”,
“CPU_hot_plug”: true,
“RAM”: “{{user vm-mem-size}}”,
“RAM_reserve_all”: true,
“RAM_hot_plug”: true,
“disk_controller_type”: “pvscsi”,
“storage”: [
“disk_size”: “{{user vm-disk-size}}”,
“disk_thin_provisioned”: true
“iso_checksum”: “sha256:{{user iso-checksum}}”,
“iso_urls”: “{{user iso-url}}”,
“shutdown_command”: “echo ‘shutdown’ | sudo -S shutdown -P now”,
“http_directory”: “http”,
“boot_command”: [
"install ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
"debian-installer=fr_FR.UTF-8 ",
"auto ",
"locale=fr_FR.UTF-8 ",
"kbd-chooser/method=fr ",
"keyboard-configuration/xkb-keymap=fr ",
"netcfg/get_hostname={{ .Name }} ",
"netcfg/get_domain=domaine.local ",
"fb=false ",
"debconf/frontend=noninteractive ",
"console-setup/ask_detect=false ",
"console-keymaps-at/keymap=fr ",
"grub-installer/bootdev=/dev/sda ",
“provisioners”: [
“environment_vars”: [
“http_proxy={{user http-proxy}}”,
“https_proxy={{user https-proxy}}”,
“no_proxy={{user no-proxy}}”
“inline”: [
“echo ‘Packer Template Build – Complete’”
“type”: “shell”
the preseed:

Setting the locales, country

Supported locales available in /usr/share/i18n/SUPPORTED

d-i debian-installer/language string fr
d-i debian-installer/country string fr
d-i debian-installer/locale string fr_FR.UTF-8

Keyboard setting

d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string fr
d-i keyboard-configuration/xkb-keymap fr
d-i keyboard-configuration/modelcode string pc105

#network settings
#d-i netcfg/enable boolean false
d-i netcfg/choose_interface select auto
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string
d-i netcfg/get_netmask string
d-i netcfg/get_gateway string
d-i netcfg/get_nameservers string
d-i netcfg/confirm_static boolean true
d-i netcfg/get_ipaddress seen true
d-i netcfg/get_netmask seen true

User creation

d-i passwd/user-fullname string xxxx
d-i passwd/username string precom
d-i passwd/user-password password xxxxx
d-i passwd/user-password-again password xxxx
d-i user-setup/allow-password-weak boolean true

Disk and Partitioning setup

d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true*

Set mirror

apt-mirror-setup apt-setup/use_mirror boolean true
choose-mirror-bin mirror/http/proxy string
d-i mirror/country string manual
d-i mirror/http/directory string /debian
d-i mirror/http/hostname string
d-i mirror/http/proxy string

Set root password

d-i passwd/root-login boolean false
d-i passwd/root-password-again password xxxx
d-i passwd/root-password password xxxxx
d-i passwd/user-fullname string xxxxx
d-i passwd/user-uid string 1000
d-i passwd/user-password password xxxxx
d-i passwd/user-password-again password xxxxx
d-i passwd/username string XXXX

Package installations

popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect standard, ssh-server
d-i pkgsel/include string openssh-serv
d-i pkgsel/include string sudo wget curl open-vm-tools
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i finish-install/reboot_in_progress note

is anyone have an idea?

hi antonin,

think about it: on one hand your vm has no IP address, since there is no active dhcp server to assign one to it. On the other hand, you are expecting the vm to connect to a network host (the packer host) to retrieve the preseed file, and it can’t do that for obvious reasons.

The solution is to pass the netcfg preseed parameters with the kernel command (“boot command” in packer templates), e.g.:

"boot_command": [
    "auto <wait>",
    "netcfg/disable_autoconfig=true ",
    "netcfg/use_autoconfig=false ",
    "netcfg/get_ipaddress= ",
    "netcfg/get_netmask= ",
    "netcfg/get_gateway= ",
    "netcfg/get_nameservers= ",
    "netcfg/confirm_static=true <wait>",
    "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",

Note disable_autoconfig and enable_autoconfig which seem to have both been necessary to kill the attempts to configure via dhcp. The above will pass through the netcfg step and configure the supplied settings.

for future reference, here is a list of “comprehensive preseed files” for buster, with all (documented and some undocumented) preseed options that you may use, either in the boot command or in the preseed file: Index of /debian-preseed/buster


1 Like

indeed, sometimes i just feel …
it seems to work
thanks a lot