Problem
TLDR: I've got this doing most of the AutoInstall (I think?) but it keeps bringing up the GUI install after it goes through the AutoInstall. Looking for any input into why it keeps bringing up the GUI. /TLDR
Longer Version: I am trying to figure out how to deploy ubuntu (and eventually other distros) to Proxmox by using Hashicorp Packer. I've got most of the configs setup and working... sort of? It's successfully "deploying" but it can't finish the initial setup, it keeps going through the AutoInstall, but then still brings up the GUI install. From stepping through the GUI manually, after it finishes the AutoInstall portion, it seems everything is already filled out (minus the user identity portion, ie FullName/Username/etc). It doesn't seem to even need to find an IP addr, like when you step through just the GUI, so I think DHCP is working fine?
I've tried looking at a few other similar-ish questions, but their solutions haven't worked for me (yet).
Theories
I've got a few theories, but none seem to work out quite right, or I'm not sure how to test them.
- I'm forgetting something in the
user-data
(yaml), and its trying to bring up the GUI because of this.
- I'm missing some config parameter in the
.pkr.hcl
file that is necessary for proxmox to set up the vm correctly?
- Something is weird with the Ubuntu version I'm using, maybe I need a different ISO? But the stuff I've read just says that the Cloud-init feature just swaps out the legacy
preseed.cfg
for the user-data
(yaml) file, so I'm doubtful about this theory.
- I need to set some kernel feature? Honestly not sure where to start here, I'm also pretty sure if this was the case I would have seen something about it somewhere else. But hey, maybe I just looked in the wrong places?
- The
user-data
file isn't being loaded into Ubuntu properly?
Hopeful outcomes
- If you know the magic sauce, please grace me with it :)
- If you know how to get Ubuntu 20.04 to redirect some of its logs during install, so I can take a deeper look, that'd be appreciated! Same for better packer logging (aside from
-debug
, I've already tried that). I've tried /var/log/installer
, but I don't think I have a firm grasp of whats going on. But I don't see any failures, aside from an SSH Key error, and I can't see any indication of user-data
download or failures to download.
- If you have any ideas on how to test some of my theories, or any other theories I'd love to hear them!
- If you can see what I'm doing wrong in the below config files please point them out! I've been trying to do this in a SILO for a few days now and am up against a wall I don't know how to get over
Updates (ongoing)
- found
seed from http://192.168.0.144:80/user-data not supported by DataSourceNoCloud [seed=None][dsmode=net]
in /var/log/cloud-init.log
looking into why that came back, any advice would be appreciated :)
- Ok so I figured out why the above error occurred, seems it wasn't in proper YAML format. I just dumped the file into a YAML formatter and then copy pasted it back into my target file.
- Now the error is that the loaded YAML file is blank
/var/lib/cloud/seed/nocloud/user-data
, again I'd appreciate any advice :)
Hint
If you're cool enough to try replicating this stuff, or if you've stumbled into this after its (hopefully) been answered, make your life easier by using a example.auto.pkrvars.hcl
file.
Versions
Proxmox: Proxmox VE 7.1-4
Windows: Windows 10 Pro : 10.0.19043.0
Packer: 1.7.10
Example.pkr.hcl
packer {
required_plugins {
proxmox = {
version = " >= 1.0.1"
source = "github.com/hashicorp/proxmox"
}
}
}
source "proxmox-iso" "proxmox-ubuntu-20" {
proxmox_url = "https://proxmox.lan:8006/api2/json"
vm_name = "packer-ubuntu-20"
iso_url = "http://iso.repo.lan/ubuntu-20.04.3-live-server-amd64.iso"
iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
username = "${var.pm_user}"
password = "${var.pm_pass}"
token = "${var.pm_token}"
node = "proxmox"
iso_storage_pool = "local"
ssh_username = "${var.ssh_user}"
ssh_password = "${var.ssh_pass}"
ssh_timeout = "20m"
ssh_pty = true
ssh_handshake_attempts = 20
boot_wait = "5s"
http_directory = "http" # Starts a local http server, serves Preseed file
boot_command = [
"<esc><wait><esc><wait><f6><wait><esc><wait>",
"<bs><bs><bs><bs><bs>",
"ip=${cidrhost("192.168.0.0/24", 9)}::${cidrhost("192.168.0.0/24", 1)}:${cidrnetmask("192.168.0.0/24")}::::${cidrhost("192.168.0.0/24", 1)} ",
"autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"--- <enter>"
]
insecure_skip_tls_verify = true
template_name = "packer-ubuntu-20"
template_description = "packer generated ubuntu-20.04.3-server-amd64"
unmount_iso = true
pool = "packer"
memory = 4096
cores = 1
sockets = 1
os = "l26"
qemu_agent = true
cloud_init = true
# scsi_controller = "virtio-scsi-pci"
disks {
type = "scsi"
disk_size = "30G"
storage_pool = "local-lvm"
storage_pool_type = "lvm"
format = "raw"
}
network_adapters {
bridge = "vmbr0"
model = "virtio"
firewall = true
# vlan_tag = 1
}
}
build {
sources = ["source.proxmox-iso.proxmox-ubuntu-20"]
provisioner "shell" {
inline = [
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"ls /"
]
}
}
vars.pkr.hcl
variable "pm_user" {
type = string
description = "Proxmox User Name"
default = "packer@pam!<api-tag>"
}
variable "pm_pass" {
type = string
description = "Proxmox User Password"
default = "packer"
}
variable "pm_token" {
type = string
description = "Proxmox API Token"
}
variable "ssh_user" {
type = string
description = "SSH User"
default = "packer"
}
variable "ssh_pass" {
type = string
description = "SSH Password"
default = "packer"
}
variable "vm_name" {
type = string
description = "VM Name"
default = "packer_hostname"
}
http/user-data
autoinstall:
version: 1
locale: en_US.UTF-8
keyboard:
layout: en
variant: us
identity:
hostname: packer-ubuntu-20
password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0" #ubuntu
username: ubuntu
realname: ubuntu
refresh-installer:
update: false
ssh:
install-server: yes
allow-pw: yes
packages:
- qemu-guest-agent
storage:
layout:
name: direct
swap:
size: 0
Sources
https://www.aerialls.eu/posts/ubuntu-server-2004-image-packer-subiquity-for-proxmox/
https://ubuntu.com/server/docs/install/autoinstall-reference
https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
https://cloudinit.readthedocs.io/en/latest/topics/modules.html#write-files
https://cloudalbania.com/posts/2022-01-homelab-with-proxmox-and-packer/