ddelnano / packer-plugin-xenserver

A builder plugin for Packer.IO to support building XenServer images.
Mozilla Public License 2.0
74 stars 37 forks source link

Add support for `cd_files` in addition to `floppy_files` #144

Open ceejatec opened 3 months ago

ceejatec commented 3 months ago

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.

olivierlambert commented 3 months ago

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?

ceejatec commented 3 months ago

@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?

olivierlambert commented 3 months ago

Indeed, if you can add some example/doc in the PR, it will really help to get the PR merged faster :+1:

ceejatec commented 3 months ago

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!

ceejatec commented 3 months ago

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.