Files
vms/sources/build.pkr.hcl
T

84 lines
2.0 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"
source = "github.com/hashicorp/vmware"
}
2023-11-28 14:02:55 -06:00
hyperv = {
version = "= 1.1.1"
source = "github.com/hashicorp/hyperv"
}
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 {
2022-06-04 13:23:22 -05:00
sources = [
2023-11-27 21:00:35 -06:00
"source.qemu.amd64",
"source.virtualbox-iso.amd64",
"source.vmware-iso.amd64",
"source.hyperv-iso.amd64"
2022-06-04 13:23:22 -05:00
]
2022-05-25 01:40:52 -05:00
2023-08-22 00:18:02 -05:00
# If anything needs specific support for one of the distros
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
2023-11-27 21:00:35 -06:00
only = ["qemu.amd64"]
2023-08-22 00:18:02 -05:00
script = "distros/${var.distro}/${var.version}/qemu.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
2023-11-27 21:00:35 -06:00
only = ["virtualbox-iso.amd64"]
2023-08-22 00:18:02 -05:00
script = "distros/${var.distro}/${var.version}/virtualbox.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
2023-11-27 21:00:35 -06:00
only = ["vmware-iso.amd64"]
2023-08-22 00:18:02 -05:00
script = "distros/${var.distro}/${var.version}/vmware.sh"
2022-05-25 01:40:52 -05:00
}
2023-08-22 00:18:02 -05:00
# Generic wrapping up the provisioner before packaging
2022-05-25 01:40:52 -05:00
provisioner "shell" {
2023-08-22 00:18:02 -05:00
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
2022-05-25 01:40:52 -05:00
scripts = [
2023-08-22 00:18:02 -05:00
"scripts/vagrant.sh",
"distros/${var.distro}/${var.version}/finalize.sh",
2022-05-25 01:40:52 -05:00
"scripts/minimize.sh"
]
}
post-processors {
post-processor "vagrant" {
keep_input_artifact = true
compression_level = 9
2023-08-12 13:54:23 -05:00
output = "output/{{ .Provider }}/${local.name}.box"
2022-05-25 01:40:52 -05:00
vagrantfile_template = "vagrant/${var.arch}.rb"
}
post-processor "vagrant-cloud" {
name = "upload"
2022-05-27 08:40:09 -05:00
access_token = var.vagrant_cloud_token
2023-11-28 14:02:55 -06:00
architecture = var.arch
2022-05-27 01:04:42 -05:00
box_tag = "boxen/${local.name}"
2023-11-27 21:00:35 -06:00
default_architecture = "amd64"
2022-06-08 02:27:48 -05:00
version = var.build
2022-05-25 01:40:52 -05:00
version_description = local.description
}
}
}