Skip to content

Commit 9a41168

Browse files
committed
Convert Packer definition to HCL2
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.
1 parent f381f5b commit 9a41168

File tree

8 files changed

+267
-337
lines changed

8 files changed

+267
-337
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ jobs:
3737
- name: Install dependencies
3838
run: |
3939
pip3 install demjson3
40-
- name: Run jsonlint
41-
run: |
42-
jsonlint packer/*json
4340
- name: Install Hashicorp repo
4441
run: >
4542
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor |

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77

88
# Packer-related binaries
99
packer/packer_cache/*
10-
packer/artifacts_mint/*
11-
packer/artifacts_ubuntu/*
10+
packer/artifacts*/*

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ Linux and Windows hosts, but feedback on other platforms is always welcome.
143143

144144
Due to difficulties with Packer packaging, this VM is frequently built with the
145145
latest version of Packer available directly from Hashicorp. Check the
146-
`mint-build.json` file for the current minimum version required.
146+
`main.pkr.hcl` file for the current minimum version required.
147147

148148
Once the prerequisites are installed, change into the `cs-vm-build/packer`
149-
directory and execute `packer build mint-build.json`. This will take a
149+
directory and execute `packer build -only "*.mint" .`. This will take a
150150
considerable amount of time, depending on host resources available, but should
151151
output progress indicators along the way.
152152

@@ -164,15 +164,31 @@ specify `dsound` for Windows, `coreaudio` for Mac.
164164
### Building beta images
165165

166166
A large number of variables can be overridden at once by passing a `var-file`
167-
to Packer. An example of this is provided as `beta-vars.json`, and can be used
167+
to Packer. An example of this is provided as `mint-beta.pkrvars.hcl`, and can be used
168168
like this:
169169

170-
`packer build -var-file=beta-vars.json mint-build.json`
170+
`packer build -var-file=mint-beta.pkrvars.hcl -only "*.mint" .`
171171

172172
Packer allows further overrides, with precedence given to the last option in the
173173
command. For example, to build a beta image on Windows, use this command:
174174

175-
`packer build -var-file=beta-vars.json -var 'audio=dsound' mint-build.json`
175+
`packer build -var-file=mint-beta.pkrvars.hcl -var 'audio=dsound' -only "*.mint" .`
176+
177+
### Building Ubuntu images
178+
179+
Native support is available for creating an Ubuntu variant of the image (and in
180+
fact, all previous commands have specifically excluded Ubuntu image builds). By
181+
default, the `packer` configuration will build both a Mint and Ubuntu VM. Try it
182+
with:
183+
184+
`packer build .`
185+
186+
Much as with the previous commands, you can build only an ubuntu-based image by
187+
running:
188+
189+
`packer build -only "*.ubuntu" .`
190+
191+
Support for building beta variants of Ubuntu images is not currently supported.
176192

177193
## Contributing
178194

packer/beta-vars.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

packer/mint-beta.pkrvars.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
semester = "Fa22"
2+
3+
mint_version = {
4+
version = "21"
5+
name = "vanessa"
6+
beta = true
7+
}

packer/mint-build.json

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)