Files
vms/sources/build.pkr.hcl
T
Greg HellingsandGitHub 634aae8d75 Do some better linting (#13)
* Do some better linting

* Update names, Packer version, and more

* Do not lint on push

* More linting and scripting

* Cleanup shellcheck lint

* Add Packer format check

* Fix Packer formatting

* Limit to only one

* Remove generated HCL files

* Only lint checked files

* Use pipes instead

* Improve attempt to build

Actually go back to attempting to build boxes on GitHub. Maybe it will
work better with this structure

* Change to using environment files

* Initialize plugins, first

* More verbose usage of the file

* Do the output properly this time

* PACKER_LOG set to 1

* No need for python3 anymore

* Limit to only one result

* Choose a specific CPU model

* Init separately

* Update actions version

* Add version outputting

* Correct actions version

* Try to execute qemu properly

* Fix CPU model name

* Do not over-subscribe GitHub runners

* Try type instead of command to guard runs

* Do not write to non-existent folder

* Cache packer plugins

* Use ~ instead of /home/greg

* Try the proper path

* Move to intelligent matrix

* Set global env path

* Add lots of waits for VBoxManage on hosted runners

* Add more waits

* Add more waits
2023-12-06 10:21:32 -06:00

84 lines
2.3 KiB
HCL

packer {
required_plugins {
qemu = {
source = "github.com/hashicorp/qemu"
version = "~> 1"
}
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
vagrant = {
source = "github.com/hashicorp/vagrant"
version = "= 1.1.1"
}
vmware = {
version = ">= 1.0"
source = "github.com/hashicorp/vmware"
}
hyperv = {
version = "= 1.1.1"
source = "github.com/hashicorp/hyperv"
}
virtualbox = {
source = "github.com/hashicorp/virtualbox"
version = "~> 1"
}
}
}
build {
sources = [
"source.qemu.amd64",
"source.virtualbox-iso.amd64",
"source.vmware-iso.amd64",
"source.hyperv-iso.amd64"
]
# If anything needs specific support for one of the distros
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["qemu.amd64"]
script = "distros/${var.distro}/${var.version}/qemu.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["virtualbox-iso.amd64"]
script = "distros/${var.distro}/${var.version}/virtualbox.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["vmware-iso.amd64"]
script = "distros/${var.distro}/${var.version}/vmware.sh"
}
# Generic wrapping up the provisioner before packaging
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
scripts = [
"scripts/vagrant.sh",
"distros/${var.distro}/${var.version}/finalize.sh",
"scripts/minimize.sh"
]
}
post-processors {
post-processor "vagrant" {
keep_input_artifact = true
compression_level = 9
output = "output/{{ .Provider }}/${local.name}.box"
vagrantfile_template = "vagrant/${var.arch}.rb"
}
post-processor "vagrant-cloud" {
name = "upload"
access_token = var.vagrant_cloud_token
architecture = var.arch
box_tag = "boxen/${local.name}"
default_architecture = "amd64"
version = var.build
version_description = local.description
}
}
}