packer-plugin-xenserver
packer-plugin-xenserver copied to clipboard
Add support for `cd_files` in addition to `floppy_files`
At least the Ubuntu 24.04 server ISO hangs for 5 minutes when booting with a Xen-provided floppy drive. The primary purpose of floppy_files is to provide the autoinstall config files, and cloud-init is happy to find those files on an inserted CD instead. Add the ability for packer-plugin-xenserver to create such a CD.
I don't know if you might have time to review this @ddelnano ? Our DevOps team is still in assembling and will really start in September.
@ceejatec have you tested your changes?
@olivierlambert I have - I've got a config for setting up an Ubuntu 24.04 VM using this change, along with some other tweaks. Should I add that to the change as a new example?
Indeed, if you can add some example/doc in the PR, it will really help to get the PR merged faster :+1:
Ok, I've pushed a new commit adding the example. It does the necessary things to pull the Ubuntu 24.04 ISO and upload it to XCP (similar to the ubuntu-2004 example); create a CD with the autoinstall user-data/meta-data files; install Ubuntu 24.04 with the testuser/ubuntu user; and install the newest version of xen-guest-agent from the upstream apt repository. I found that the xe-guest-utilities package from the XCP CD didn't work in Ubuntu 24.04. And man, it took a long time to get that apt repository working with autoinstall/subiquity/curtin.
The ubuntu-2404.pkr.hcl also adds a shell provisioner to run cloud-init status --wait after rebooting from the installer, to ensure that cloud-init has time to finish doing things like creating the testuser user before packer-plugin-xenserver shuts the VM down to create the template.
One note: the example should probably specify version >= 0.7.4 for packer-plugin-xenserver. However I couldn't figure out how to test that with a locally-built packer-plugin-xenserver. I ran packer plugins install -path packer-plugin-xenserver github.com/ddelnano/xenserver v0.7.4, but that resulted in installing it as v0.6.0 for reasons I don't understand. I had to actually copy packer-plugin-xenserver on top of the 0.7.3 binary in my ~/.config/packer/plugins directory to test this functionality. Obviously I'm new to this - if you know how I can test a locally-modified plugin more correctly, please let me know!
Note that this ubuntu-2404 example should work fine with the released packer-plugin-xenserver v0.7.3 if you change cd_files to floppy_files - you'll just experience a long pause during boot of the initial VM. It should also work http_directory; I couldn't test that here, I believe due to firewall configurations (my XCP instance is behind a VPN).
Also note that for cd_files to work, you need to have xorriso, mkisofs, or a similar tool installed on your local system to create the CD image. That's inherited from packer-plugin-sdk.
Heya @ddelnano @olivierlambert - any chance this could be merged? I've updated the ubuntu-2404.pkr.hcl example to specify version = ">=v0.7.4" as I figured out how to build it as that version locally, by modifying version/version.go (using -ldflags "-X 'version.Version=v0.7.4'" doesn't work, I believe because the variable PluginVersion is actually used and is initialized via a function call, so modifying Version via ldflags is too late).
@gCyrille and I are going to review and test this PR.
Hi @ceejatec . Great PR! I've been waiting for such a feature for a long time :star_struck:
Is it possible to let users choosing the CD label via a new cd_label configuration entry ?
Can we also imagine a cd_content option like on the vsphere-iso builder to let users build dynamic files using templatefile() function for example ?
@FlorianLaunay I'm afraid I won't be able to add additional functionality here, as I'm no longer using this feature myself. I've switched our XCP base images to Debian, and neither my cd_files nor the original floppy_files seemed to work with Debian 12.9 ISOs.
@FlorianLaunay I'm afraid I won't be able to add additional functionality here, as I'm no longer using this feature myself. I've switched our XCP base images to Debian, and neither my
cd_filesnor the originalfloppy_filesseemed to work with Debian 12.9 ISOs.
@ceejatec OK thanks, no worries :wink:. Anyway, I was thinking about bringing these features myself because I think they could be useful to other users. I will open a dedicated PR.
What exactly are you stuck on with Debian? Auto install with preseed? Debian installer has no detection mechanism for loading a preseed file stored on a second drive.
To get this working, you can use a trick with boot_command and cd_files in the preseed (sequence only working with UEFI firmware, grub menu is different with legacy BIOS):
cd_files = "path/to/your/preseed.cfg"
boot_command = [
"c<wait>",
"linux /install.amd/vmlinuz",
" initrd=/install.amd/initrd.gz",
" auto-install/enable=true",
" debconf/priority=critical",
" preseed/file=/mnt/cdrom/preseed.cfg",
" noprompt --<enter>",
"initrd /install.amd/initrd.gz<enter>",
"boot<enter><wait10>",
"<leftAltOn><f2><leftAltOff>",
"<enter><wait>",
"mkdir /mnt/cdrom<enter>",
"mount /dev/sr1 /mnt/cdrom<enter>",
"<leftAltOn><f1><leftAltOff>",
"<enter><wait><enter>",
"<down><down><down><down><enter>"
]
And set this early_command in your preseed.cfg file:
d-i preseed/early_command string if mount | grep -q /mnt/cdrom; then umount /mnt/cdrom && echo 1 > /sys/block/sr1/device/delete && rm -rf /mnt/cdrom; fi
It works like a charm with vsphere-iso builder. I hope this can help you :wink:
Hello! Thanks for the work on this. I'm curious if there's something blocking this from being merged?
Having this merged would be helpful since it looks like floppy disks don't work with UEFI and this would be the perfect alternative.
Probably just time for @gCyrille to review it. We'll see soon :)