Skip to content

Conversation

laurelmay
Copy link
Member

@laurelmay laurelmay commented Jul 17, 2022

This rewrites the packer JSON files to use the HCL2 language support
added in 1.5 and stabilized in 1.7. The initial conversion was performed
using the hcl2_upgrade command but quite a lot of custom work has been
done on top of that.

A base shared definition for the VM is created that defines all the
shared options (CPU, memory, SSH stuff, etc) and then that is
specialized in the build block for each source, this is where the
differences between Ubuntu and Mint are specified.

Additionally, we now store version information as complex objects that
meet our needs a bit more closely. This is required because some of the
interpolation that we did in JSON is no longer available.

As I was reviewing the VirtualBox builder config I also moved a few
things from manual VBoxManage commands to actual packer definitions
but some of those could have been done in the JSON format as well.

Closes #460

@laurelmay laurelmay force-pushed the use-hcl2-packer branch 2 times, most recently from 9a41168 to 5922cfc Compare July 17, 2022 17:27
@laurelmay
Copy link
Member Author

Hmm... Looks like something goes wrong either during the Ubuntu boot_command or with the preseed file. Not sure if that same behavior happens on main or not atm so I'll have to check.

@laurelmay laurelmay force-pushed the use-hcl2-packer branch 2 times, most recently from bec56a1 to cba6d51 Compare July 17, 2022 18:04
@laurelmay laurelmay marked this pull request as ready for review July 17, 2022 18:06
@laurelmay
Copy link
Member Author

@ripleymj If you're opposed to enabling EFI, I can try to debug the second commit on this PR a bit more... but also might be fun to just see what happens?

@ripleymj
Copy link
Member

It looks like the Ubuntu file never got updated for 22.04, and the corresponding grub syntax change. I think you've got the right syntax now, especially c<wait> with or without EFI.

@laurelmay
Copy link
Member Author

Okay. Let me try just dropping the EFI change then. For some reason it felt like I got a slightly different flow with BIOS but let's find out!

@laurelmay
Copy link
Member Author

got the right syntax now

u right. EFI removed (for now)

@laurelmay laurelmay force-pushed the use-hcl2-packer branch 3 times, most recently from 12bb915 to 7a67fd0 Compare July 18, 2022 00:22
Copy link
Member Author

@laurelmay laurelmay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I've done my best here to also reduce some code duplication; it makes less-than-perfectly clean code in a few places but:

  • we just try both initrd and initrd.lz as paths for the initrd; grub ignores the wrong one
  • we use || true to a systemctl command so that we can use the same script to stop apt and run the oem-build script

The mint_info and ubuntu_info blocks in locals also aren't the mostly lovely thing in the world. But on the whole, this significantly reduces the duplication that we had before and makes these a little easier to manage going forward hopefully.

I wish there was a good way to merge the export_opts so that we only had to specify the different values but I don't see a phenomenal option (and again, we were duplicating it before anyway).

Unless I find some sort of issue with this during testing, I think that for the most part I am done making changes here and this is actually ready for review.

@laurelmay laurelmay linked an issue Jul 18, 2022 that may be closed by this pull request
@ripleymj
Copy link
Member

Before I try to understand this, any thoughts on how AARCH64 from #457 will merge in? Is qemu too far away to merge with VirtualBox?

@laurelmay
Copy link
Member Author

laurelmay commented Jul 18, 2022

Before I try to understand this, any thoughts on how AARCH64 from #457 will merge in? Is qemu too far away to merge with VirtualBox?

Yeah, so it'd definitely need a different top-level source block since it uses a different builder plugin. We might be able to reuse the source block? And there'd be some overlap... I think we'd want to look at https://github.com/hashicorp/packer/blob/03d29386dd92d45ad3ada54dc282f229f7bed526/examples/hcl/ubuntu/build.pkr.hcl as an example (and it's sibling files in that directory).

https://github.com/hashicorp/packer/tree/main/examples/hcl/linux is the directory on the main branch, though slightly less clean.

@ripleymj
Copy link
Member

A warning to anyone else who might test this, the Mint beta vars are required at the moment after the c<wait> change.

@laurelmay laurelmay force-pushed the use-hcl2-packer branch 2 times, most recently from a228401 to d06a6b4 Compare July 20, 2022 02:21
This rewrites the packer JSON files to use the HCL2 language support
added in 1.5 and stabilized in 1.7. The initial conversion was performed
using the `hcl2_upgrade` command but quite a lot of custom work has been
done on top of that.

A base shared definition for the VM is created that defines all the
shared options (CPU, memory, SSH stuff, etc) and then that is
specialized in the `build` block for each `source`, this is where the
differences between Ubuntu and Mint are specified.

Additionally, we now store version information as complex objects that
meet our needs a bit more closely. This is required because some of the
interpolation that we did in JSON is no longer available.

As I was reviewing the VirtualBox builder config I also moved a few
things from manual `VBoxManage` commands to actual packer definitions
but some of those could have been done in the JSON format as well.
@ripleymj ripleymj merged commit f0c540b into jmunixusers:main Aug 3, 2022
@laurelmay laurelmay deleted the use-hcl2-packer branch January 13, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move configurations out of vboxmanage

2 participants