Closed s0uky closed 11 months ago
@s0uky have you tried using cd_files?
cd_files = [
"source/packer/preseed/ubuntuserver22/user-data",
"source/packer/preseed/ubuntuserver22/meta-data"
]
This does work, look into subiquity: https://ubuntu.com/server/docs/install/autoinstall-reference This is how ubuntu handles their auto unattend, make a folder specifically called cidata and put your user-data file in that, you can use boot command or http server to grab it and load it into memory using initramd in your boot command and it will work. I went through all of the work to get it working then swapped to debian a month later cause server stability issues with Ubuntu. Point is, it will work, you just have to use Ubuntu's new process to get it to work as expected.
This is the boot command you want
http_directory = "./cidata"
boot_command = [
"c<wait3s>",
"set gfxpayload=keep<enter>",
"linux /casper/vmlinuz autoinstall \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" ",
"hostname={{.Name}} boot=casper fsck.mode=skip auto=true noprompt noeject<enter>",
"initrd /casper/initrd<enter>",
"boot<enter>"
]
This is the basic user-data
:
#cloud-config
autoinstall:
version: 1
early-commands:
- systemctl stop ssh
identity:
hostname: ubuntu2204
realname: ubuntu2204
username: -----secret-----
password: '$6$9-----secret-----'
keyboard:
layout: en
variant: us
late-commands:
- ssh-import-id-gh -----secret-----
- "echo 'packer ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/-----secret-----"
- curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/-----secret-----
locale: en_US
reporting:
builtin:
type: print
ssh:
install-server: true
allow-pw: true
authorized-keys:
- ssh-rsa -----secret-----
user-data:
disable_root: false
timezone: America/New_York
For some reason there also needs to be a mete-data file in the cidata folder, even if its empty, dont know why:
# meta-data
Hope this helps!
you can also load up the user-data
/meta-data
files onto a cdrom if you cant get an IP, youll need to update the boot_command
to use cdrom:/
instead of nocloud-net
This can easily be done for Ubuntu and Debian with both cd_files and iso_paths without issue using the vsphere-iso builder.
Please refer to https://github.com/vmware-samples/packer-examples-for-vsphere.
Cc @nywilken
@tenthirtyam thanks for the ping it seems like this issue might be resolved given your last suggestion. I will transfer to the vSphere repository for tracking and management.
It seems like a user configuration more than a bug. I think we can close it if there are no objections or further questions.
I fixed this issue with proper boot_command, (see the whole ip= part), so Packer can access Ubuntu with correct interface settings:
"boot_command_prefix": "c<wait>linux /casper/vmlinuz ipv6.disable={{ user `boot_disable_ipv6` }} ip={{ user `vm_ip` }}::{{ user `vm_gateway` }}:{{ user `vm_netmask` }}::::{{ user `vm_dns` }} --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04/'<enter><wait>initrd /casper/initrd<enter><wait>boot<enter>",
"vm_ip": "10.1.1.1",
"vm_netmask": "255.255.254.0",
"vm_gateway": "10.1.1.254",
"vm_dns": "10.1.1.3"
Community Note
When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.
Overview of the Issue
With vSphere 7.0 is not possible to use floppy drive and option "floppy_dirs" because floppy drive is gone from this version. Same with cloud-init settings
'ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04/'
in boot_command isn't possible to use if you don't have DHCP server deployed. Static IP configuration still isn't seems to be solved regards to this issue https://github.com/hashicorp/packer/issues/9115 .Debian installer preseed option is gone from Ubuntu 22 and there is no way how to provide config file for cloud-init.
Is there any way how to use USB device instead of floppy drive in configuration?
Reproduction Steps
Run similar command with specifing vSphere API settings in vsphere.json:
/usr/bin/packer build -except=local -only=vsphere-iso -var-file="image-builder-0.1.16/extras/capi_image_adds_v1.21.json" -only=vsphere packer/ova/packer-node.json
Packer version
Packer v1.9.1
Simplified Packer Template
All in default configuration.
Operating system and Environment details
vSphere 7.0 -> Oracle Linux Server 8.7 (run packer), Ubuntu 22.04 (ISO to be provisioned)
Log Fragments and crash.log files
Nothing interesting in packer logs, but in build VM there are lot of errors regards to floppy.