Files
vms/sources/build.pkr.hcl
T

98 lines
2.7 KiB
HCL
Raw Normal View History

2023-08-03 14:44:02 -05:00
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"
2023-11-28 10:32:08 -06:00
version = "= 1.1.1"
2023-08-03 14:44:02 -05:00
}
2023-08-14 01:05:21 -05:00
vmware = {
version = ">= 1.0"
2023-12-06 08:21:32 -08:00
source = "github.com/hashicorp/vmware"
2023-08-14 01:05:21 -05:00
}
2023-11-28 14:02:55 -06:00
hyperv = {
2023-12-07 12:15:48 -06:00
version = "= 1.1.3"
2023-12-06 08:21:32 -08:00
source = "github.com/hashicorp/hyperv"
2023-11-28 14:02:55 -06:00
}
virtualbox = {
source = "github.com/hashicorp/virtualbox"
version = "~> 1"
}
2023-08-03 14:44:02 -05:00
}
}
2022-05-25 01:40:52 -05:00
build {
2023-12-06 08:21:32 -08:00
sources = [
"source.qemu.amd64",
"source.virtualbox-iso.amd64",
"source.vmware-iso.amd64",
"source.hyperv-iso.amd64"
]
2022-05-25 01:40:52 -05:00
2023-12-06 08:21:32 -08:00
# 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"
}
2022-05-25 01:40:52 -05:00
2023-12-06 08:21:32 -08:00
# 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"
]
}
2022-05-25 01:40:52 -05:00
2023-12-06 08:21:32 -08:00
post-processors {
post-processor "vagrant" {
keep_input_artifact = true
compression_level = 9
output = "output/{{ .Provider }}/${local.name}.box"
vagrantfile_template = "vagrant/${var.arch}.rb"
2023-12-30 05:37:32 +00:00
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"]
2023-12-06 08:21:32 -08:00
}
2022-05-25 01:40:52 -05:00
2023-12-06 08:21:32 -08:00
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
}
}
2022-05-25 01:40:52 -05:00
}