cirruslabs / packer-plugin-tart

Packer builder for Tart VMs
https://developer.hashicorp.com/packer/plugins/builders/tart
Mozilla Public License 2.0
65 stars 17 forks source link

Refactor linux creation install #139

Closed torarnv closed 7 months ago

torarnv commented 7 months ago

The code for Linux installation was maintained separately in stepCreateVM, even though it shared most of the logic with the macOS installation flow of stepRun.

We now use the same flow for Linux and macOS installation:

  1. The VM is created in stepCreateVM
  2. We run the VM in stepRun, which based on the boot_command does automated installation of the OS
  3. Once the automated installation is done, and SSH access is enabled, SSH provisioning steps can proceed

To achieve this flow for Linux, the autoinstall cloud config in the Ubuntu example had to be changed to from "poweroff" to "reboot", so that the VM was rebooted into a level where SSH is available. This is the default value for the autoinstall shutdown key, and the only reason we needed to override it previously was because we did the installation (via boot_command) as part of stepCreateVM.

The SSH timeout in the example also had to be increased, as we now wait for the installation to be completed, just like we for macOS.

Fixes #127

torarnv commented 7 months ago

A quick survey of Linux Packer templates on the Web seems to indicate that the common approach is to let the VM reboot after installation so that the SSH provisioning can continue, so this change should not be too surprising, but may require a major version bump just in case.

We should probably pin https://github.com/cirruslabs/linux-image-templates/blob/main/cloud-init.pkr.hcl#L5 for now to 1.10.0 so that whatever we do it doesn't break Cirrus CI

torarnv commented 7 months ago

Side note, this doesn't seem to apply to Ubuntu 22.04.04:

https://github.com/cirruslabs/packer-plugin-tart/pull/139/files#diff-0ca100a8fa890600beffa65b75dc02223f8eff023a437458e00be9bdc369d8fcL29-L30

tart-cli.tart: FAILED: /dev/vda: does not exist

fkorotkov commented 7 months ago

Seems this PR includes all your other PRs. Could you please rebase so the change is scope to Linux creation.

torarnv commented 7 months ago

Seems this PR includes all your other PRs. Could you please rebase so the change is scope to Linux creation.

Should be good now. GitHub can be annoying sometimes when working with several PRs in parallel 😔