I am trying to provision Ubuntu 20.04 through packer and I am trying to use packer's http server to provide the cloud-init configuration. On Ubuntu 18.04 I could do that by preseeding the ip using d-i (debian-installer), which in the mean time has become obsolete, it seems, but I don't know how I can do the same with Ubuntu 20. As far as I understand, Ubuntu 20.04 can use dhcp, but I'm interested in assigning a static IP, so that the VM can connect to the http server. Any ideas how I can achieve this? Or is the approach maybe wrong?
This is what what packer runs during the boot process (before the actual installer):
"/casper/vmlinuz/ ",
"initrd=/casper/initrd debug= ",
"autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ",
"--- <enter>"
The OS freezes at the "Host and Network Name Lookups" target (just before cloud-init is loaded/initialised). This is the content of cloud-init:
#cloud-config
autoinstall:
version: 1
locale: en_US
keyboard:
layout: fr
ssh:
install-server: true
allow-pw: true
packages:
- qemu-guest-agent
storage:
layout:
name: direct
swap:
size: 0
user-data:
package_upgrade: true
timezone: Europe/Paris
users:
- name: username
passwd: $6$xyz$1D0kz5pThgRWqxWw6JaZy.6FdkUCSRndc/PMtDr7hMK5mSw7ysChRdlbhkX83PBbNBpqXqef3sBkqGw3Rahs..
groups: [adm, cdrom, dip, plugdev, lxd, sudo]
lock-passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJEXrziuUOCpWPvwOsGuF4K+aq1ufToGMi4ra/1omOZb
(the password hash is found publicly on the internet, please don't discuss that:) )
This is not strictly related to packer, actually. I would simply like to know how I can make sure a Ubuntu 20.04 installation can connect remotely to a web server to retrieve the cloud-init configuration. That's basically it :)
Thanks! My setup is proxmox 6.4-9, packer 1.7.4 (running on apple m1) and Ubuntu 20.04.3
What I did afterwards was add this to the kernel cli:
ip=10.88.88.159:10.88.88.126:255.255.255.0::eth0:off autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/
I'm using eth0
, because this seems to be the name of the interface before being changed into ens18
. However, the installer keeps complaining saying that it doesn't recognize the device. Of course I've tried both names to no avail.
In the meantime I've switched to hcl and to ubuntu ova cloud images. Quite a different setup :)
– Lethargos Sep 08 '23 at 15:56