Files
vms/sources/build.pkr.hcl

83 lines
2.3 KiB
HCL

packer {
required_plugins {
qemu = {
source = "github.com/hashicorp/qemu"
version = "= 1.1.4"
}
vagrant = {
source = "github.com/hashicorp/vagrant"
version = "= 1.1.6"
}
hyperv = {
version = "= 1.1.4"
source = "github.com/hashicorp/hyperv"
}
virtualbox = {
source = "github.com/hashicorp/virtualbox"
version = "= 1.1.3"
}
}
}
build {
sources = [
"source.qemu.amd64",
"source.virtualbox-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"
}
# 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"
only = ["qemu.amd64"]
include = [
"${var.efi_dir}/OVMF_CODE.fd",
"${var.efi_dir}/OVMF_VARS.fd",
"output/libvirt/${local.name}/efivars.fd"
]
}
post-processor "vagrant" {
keep_input_artifact = true
compression_level = 9
output = "output/{{ .Provider }}/${local.name}.box"
vagrantfile_template = "vagrant/${var.arch}.rb"
except = ["qemu.amd64"]
}
post-processor "vagrant-registry" {
name = "upload"
architecture = var.arch
box_tag = "boxen/${local.name}"
default_architecture = "amd64"
version = var.build
version_description = local.description
}
}
}