我试图在 vSphere 中使用下面的 HCL 自动构建 Ubuntu Desktop 21.04 的 Packer。我后来发现这只会从 21.10开始用于桌面图像。
看:
https://discourse.ubuntu.com/t/refreshing-the-ubuntu-desktop-installer/20659/76?u=nathanto
下面的原始问题是为了帮助其他人。
关键部分是引导命令定义seedfrom
. user-data
从从未加载的意义上说,这似乎不起作用。VM 启动,并net.ifnames=0
应用来自 boot 命令的参数(接口名为eth0
)。
开机命令的逻辑是按下c
进入grub>
提示符,然后输入命令boot_command
如下图。
我看到/proc/cmdline
引导命令已正确应用。
我看不到任何迹象表明user-data
已加载。如果我查看启动命令中显示的 Web 服务器,使用已启动 VM 中的 Firefox,则user-data
和meta-data
文件在那里并且可以访问。
请问有人对如何调试有任何想法吗?
source "vsphere-iso" "dev_vm" {
username = var.vcenter_username
password = var.vcenter_password
vcenter_server = var.vcenter_server
cluster = var.vcenter_cluster
datacenter = var.vcenter_datacenter
datastore = var.vcenter_vm_datastore
guest_os_type = "ubuntu64Guest"
insecure_connection = "true"
iso_checksum = "sha256:fa95fb748b34d470a7cfa5e3c1c8fa1163e2dc340cd5a60f7ece9dc963ecdf88"
iso_urls = ["https://releases.ubuntu.com/21.04/ubuntu-21.04-desktop-amd64.iso"]
http_directory = "./http"
vm_name = "dev_vm"
CPUs = 2
RAM = 2048
RAM_reserve_all = true
boot_wait = "3s"
convert_to_template = false
boot_command = [
"c",
"linux /casper/vmlinuz --- autoinstall ds='nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/' net.ifnames=0 ",
"<enter><wait>",
"initrd /casper/initrd<enter><wait>",
"boot<enter>"
]
network_adapters {
network = "xxx"
network_card = "e1000"
}
storage {
disk_size = 40960
disk_thin_provisioned = true
}
ssh_username = "xx"
ssh_password = "xx"
ssh_timeout = "60m"
}
build {
sources = [
"source.vsphere-iso.dev_vm"
]
...
}