Open tomjn opened 1 year ago
I didn't fancy manually setting up all the VMs myself, and Cirrus provide a Tart packer plugin. My hope was to use this with the Chef Bento boxes that are used on a lot of vagrant projects.
Unfortunately the instructions say to add the plugin require to the top of the HCL2 file passed as configuration to Packer, but Bento still uses JSON files that have no equivalent. It's also unclear how to specify Tart as the provider, the closest I can see is that virtualbox-iso
is set as the type for some VMs in the builders
section:
https://github.com/chef/bento/blob/main/packer_templates/ubuntu/ubuntu-22.04-amd64.json
Maybe I should manually install the plugin then fork chef/bento
to add Tart entries for packer_templates/ubuntu/ubuntu-20.04-arm64.json
?
Tart doesn't appear to be Arm specific, though it is what it's most wanted for here. We still have Intel/amd64/x86, so how do we differentiate Arm and Intel boxes?
Options I've thought of:
tart_arm64
and tart_x86
x86
and arm64
to the box names e.g. tomjn/ubuntu-22.04-x86
and tomjn/ubuntu-22.04-arm64
The latter option might require that I either manually adjust the names after a packer build, or, that it's manually done for intel builds. Perhaps a packer config for each?
I raised an issue over at Tart to see if we could get a local import/export command added to Tart:
https://github.com/cirruslabs/tart/issues/370
This would be better longterm for compatibility, it doesn't seem nice to be messing around inside another applications internal folders
I got a hold of the macos ventura package from the github container registry that Tart uses. After a bit of hunting around trying to use docker pull
and oras
I tried pulling it via tart pull
and the result ended up in the .tart
cache folder.
The result is basically the same as any other VM:
~/.tart
❯ tree
.
├── cache
│ └── OCIs
│ └── ghcr.io
│ └── cirruslabs
│ └── macos-ventura-base
│ ├── latest -> /Users/tomjn/.tart/cache/OCIs/ghcr.io/cirruslabs/macos-ventura-base/sha256:c95ffaa4efeb9db79855f958a6de51bf5b54f3f9502fd024e6e1b0c1ec9a5c49
│ └── sha256:c95ffaa4efeb9db79855f958a6de51bf5b54f3f9502fd024e6e1b0c1ec9a5c49
│ ├── config.json
│ ├── disk.img
│ └── nvram.bin
├── tart.log
├── tmp
└── vms
├── linuxy
│ ├── config.json
│ ├── disk.img
│ └── nvram.bin
├── ubuntu
│ ├── config.json
│ ├── disk.img
│ └── nvram.bin
└── ubuntu-22.04-vanilla
├── config.json
├── disk.img
└── nvram.bin
12 directories, 13 files
~/.tart
❯
Here's the MacOS Ventura base config.json
:
{
"memorySize": 8589934592,
"arch": "arm64",
"os": "darwin",
"hardwareModel": "YnBsaXN0MDDTAQIDBAUGXxAZRGF0YVJlcHJlc2VudGF0aW9uVmVyc2lvbl8QD1BsYXRmb3JtVmVyc2lvbl8QEk1pbmltdW1TdXBwb3J0ZWRPUxQAAAAAAAAAAAAAAAAAAAABEAKjBwgIEAwQAAgPKz1SY2VpawAAAAAAAAEBAAAAAAAAAAkAAAAAAAAAAAAAAAAAAABt",
"cpuCountMin": 2,
"display": {
"width": 1024,
"height": 768
},
"cpuCount": 4,
"ecid": "YnBsaXN0MDDRAQJURUNJRBNaA\/GYRn+UWQgLEAAAAAAAAAEBAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAZ",
"version": 1,
"macAddress": "92:9c:f5:f9:4c:ff",
"memorySizeMin": 4294967296
}
And an Ubuntu linux config.json
:
{
"memorySize" : 4294967296,
"arch" : "arm64",
"os" : "linux",
"cpuCountMin" : 4,
"display" : {
"width" : 1024,
"height" : 768
},
"cpuCount" : 4,
"version" : 1,
"macAddress" : "8e:8a:46:4a:7b:f5",
"memorySizeMin" : 4294967296
}
Vagrant Box format documentation:
https://developer.hashicorp.com/vagrant/docs/boxes/format
It needs a metadata.json
inside the box file which is a zip file, that contains:
{
"provider": "tart"
}
https://developer.hashicorp.com/vagrant/docs/boxes/base#what-s-in-a-base-box
I didn't fancy manually setting up all the VMs myself, and Cirrus provide a Tart packer plugin. My hope was to use this with the Chef Bento boxes that are used on a lot of vagrant projects.
Unfortunately the instructions say to add the plugin require to the top of the HCL2 file passed as configuration to Packer, but Bento still uses JSON files that have no equivalent. It's also unclear how to specify Tart as the provider, the closest I can see is that
virtualbox-iso
is set as the type for some VMs in thebuilders
section:https://github.com/chef/bento/blob/main/packer_templates/ubuntu/ubuntu-22.04-amd64.json
Maybe I should manually install the plugin then fork
chef/bento
to add Tart entries forpacker_templates/ubuntu/ubuntu-20.04-arm64.json
?
You may well have sorted this by now. But in the old json format, the builder plugin being used is specified by the type
field within the builders
section (ref). You have to install the plugin manually outside of the template file hence the json not including more detail. Since packer 1.7, you can define all of the plugin details in the hcl file and install using packer init
hence the difference (ref) .
Not sure if you've seen but bento has been updated to use hcl files, however it looks like they've consolidated all of the templates. I got together some hcl templates for use with parallels a while back, it hasn't been updated for a while but there may be helpful bits for you to work from if needed https://github.com/x-delfino/tiffin. I can create some templates for tart next week
We need a box format.
Notes:
/.tart
folder and these VMs are:hello
has the folder namehello
disk.img
containing the VM filesystemnvram.bin
of the virtual machineWe can copy a VM to create a new VM by copying a VMs folder and giving it a new name.
E.g. I took my
ubuntu
VM that I created usingtart
commands, and duplicated/copied the folder and named the new folderlinuxy
:Now that VM shows up in
tart list
and can be started:and I can run
tart run linuxy
alongside theubuntu
VM.