UTM icon indicating copy to clipboard operation
UTM copied to clipboard

Please provide mechanisms for launching unattended OS installations in VMs, especially Linux kickstart/preseeding

Open mprzybylski opened this issue 2 years ago • 12 comments

The feature must provide some automated way of "typing" on the console after the VM boots.

The feature should also provide some way of launching an ephemeral web server and related infrastructure that allows a guest to retrieve an unattended installation settings file.

HashiCorp Packer's qemu builder includes good examples of both features: https://developer.hashicorp.com/packer/plugins/builders/qemu

mprzybylski avatar Apr 19 '23 07:04 mprzybylski

Have you tried https://docs.getutm.app/scripting/cheat-sheet/

osy avatar Apr 19 '23 07:04 osy

Have you tried https://docs.getutm.app/scripting/cheat-sheet/

I have, @osy. While it covers the creation of the vm, it does not provide any mechanisms for interacting with the guest OS at boot time, nor does it provide an easy way to supply the guest OS with a kickstart or preseed file.

mprzybylski avatar Apr 19 '23 08:04 mprzybylski

This can be accomplished with an ISO image or attached USB device containing a kickstart/cloud-init/whatever definition file - is the request here to create a UI for that?

brad-x avatar Apr 26 '23 14:04 brad-x

This can be accomplished with an ISO image or attached USB device containing a kickstart/cloud-init/whatever definition file

It can, but the process of creating that file is really finicky, which is why I asked for functionality that looks like the way Packer's qemu builder serves up kickstart files via an ephemeral http server.

But even more importantly, UTM's scripting API needs to provide a way to "type" on the VM's console once the VM "powers on." Some installer images like Ubuntu need autoinstall[^1] appended to the kernel command line in order to make proper use of the kickstart file, however it gets supplied.

[^1]: As noted in https://ubuntu.com/server/docs/install/autoinstall-quickstart, "Unless you interrupt boot to add autoinstall to the kernel command line, the installer will prompt for confirmation before touching the disk."

mprzybylski avatar Apr 26 '23 20:04 mprzybylski

I can only second this feature request!

If we could create packer images for UTM a whole new world would open up. I'd like to use packer with ansible to create UTM templates like the derivative-maker does for the Whonix UTM template.

stephan-devop avatar Aug 26 '23 21:08 stephan-devop

Has anyone tried this? https://github.com/naveenrajm7/packer-plugin-utm

jnoxon avatar Aug 12 '24 01:08 jnoxon

Hello! I am the developer of UTM packer plugin. Currently, the plugin supports building custom UTM VM with provisioner support using an already existing UTM file. (uses builder utm-utm)

I tried to add support for building VMs from ISO (builder utm-iso). But currently, there is no way to send boot commands to UTM to do OS installation. As the OP shared, packer qemu plugin uses VNC to send boot commands and does OS installation . Since UTM uses qemu something similar is possible if we launch UTM VM with qemu additional arguments -vnc localhost:1 .

However, currently UTM APIs does not support adding qemu additional arguments. Once the API is available, we can try implementing unattended OS installs.

naveenrajm7 avatar Aug 12 '24 23:08 naveenrajm7

We don't expose arguments because UTM doesn't just call QEMU. It uses a fork of QEMU and is integrated with UTM's backend. For example we don't support VNC at all.

osy avatar Aug 12 '24 23:08 osy

Hmm actually.. If I'm not wrong the support was added , here ? Because, I am able to launch VM with VNC arguments and connect to it through VNC client.

  1. Launch with VNC arguments Screenshot 2024-08-12 at 6 07 50 PM

  2. Connect with VNC client Screenshot 2024-08-12 at 6 22 28 PM

So I just need the ability to do the same using API . (Specifically, ability to update QEMU additional arguments section of the config )

naveenrajm7 avatar Aug 13 '24 00:08 naveenrajm7

Oh you're right, I guess I forgot about that

osy avatar Aug 13 '24 00:08 osy

Update:

I added ISO builder to my packer plugin. So now we can create VMs from ISO and perform automated OS installation using the plugin.

Check the demo below (Creating Ubuntu VM using autoinstall by automatically sending boot commands through VNC). The two manual steps were

  1. adding qemu arguments #6661
  2. updating display. #6660

I have created issues to address both steps so we can completly automate VM creation/installation.

https://github.com/user-attachments/assets/72c23bc7-7ca5-4aa5-9b54-2b72d37dd473

naveenrajm7 avatar Sep 08 '24 21:09 naveenrajm7

Does UTM not use libvirt to interface with qemu then?

virt-install is much nicer than packer as you can provide kernel arguments and inject a kickstart/preseed/cloud-init without messing with custom ISO's or typing over vnc.

sej7278 avatar Oct 05 '24 21:10 sej7278