2023-01-18 14:09:32 +00:00
|
|
|
packer {
|
|
|
|
required_plugins {
|
2023-08-21 07:39:05 +00:00
|
|
|
vsphere = {
|
|
|
|
source = "github.com/hashicorp/vsphere"
|
|
|
|
version = "~> 1"
|
|
|
|
}
|
|
|
|
|
|
|
|
ansible = {
|
|
|
|
source = "github.com/hashicorp/ansible"
|
|
|
|
version = "~> 1"
|
|
|
|
}
|
2023-01-18 14:09:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
source "vsphere-iso.ubuntu" {
|
|
|
|
name = "bootstrap"
|
2023-04-05 14:51:42 +00:00
|
|
|
vm_name = "bld_${var.vm_name}_bootstrap"
|
2023-01-25 13:16:50 +00:00
|
|
|
}
|
|
|
|
|
2023-01-18 14:09:32 +00:00
|
|
|
source "vsphere-iso.ubuntu" {
|
|
|
|
name = "upgrade"
|
2023-04-05 14:51:42 +00:00
|
|
|
vm_name = "bld_${var.vm_name}_upgrade"
|
2023-01-18 14:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "ansible" {
|
2023-02-06 09:59:41 +00:00
|
|
|
pause_before = "45s"
|
2023-01-18 14:09:32 +00:00
|
|
|
|
|
|
|
playbook_file = "ansible/playbook.yml"
|
|
|
|
user = "ubuntu"
|
|
|
|
ansible_env_vars = [
|
2023-01-18 17:42:21 +00:00
|
|
|
"ANSIBLE_CONFIG=ansible/ansible.cfg",
|
|
|
|
"PYTHONUNBUFFERED=1"
|
2023-01-18 14:09:32 +00:00
|
|
|
]
|
|
|
|
use_proxy = "false"
|
2023-04-03 19:37:09 +00:00
|
|
|
collections_path = "ansible/collections"
|
2023-04-03 14:26:38 +00:00
|
|
|
|
2023-01-18 14:09:32 +00:00
|
|
|
extra_arguments = [
|
|
|
|
"--extra-vars", "appliancetype=${source.name}",
|
2023-07-07 15:12:20 +00:00
|
|
|
"--extra-vars", "applianceversion=${var.appliance_version}",
|
2023-03-02 09:23:38 +00:00
|
|
|
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}",
|
2023-03-09 11:45:51 +00:00
|
|
|
"--extra-vars", "docker_username=${var.docker_username}",
|
2023-03-09 11:47:28 +00:00
|
|
|
"--extra-vars", "docker_password=${var.docker_password}",
|
2023-03-02 09:23:38 +00:00
|
|
|
"--extra-vars", "repo_username=${var.repo_username}",
|
|
|
|
"--extra-vars", "repo_password=${var.repo_password}"
|
2023-01-18 14:09:32 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
post-processor "shell-local" {
|
|
|
|
inline = [
|
|
|
|
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
2023-01-19 15:08:20 +00:00
|
|
|
" -ApplianceType '${source.name}' \\",
|
2024-06-07 03:08:18 +00:00
|
|
|
" -OVFFile '/data/scratch/bld_${var.vm_name}_${source.name}.ovf' \"",
|
2023-01-18 14:09:32 +00:00
|
|
|
"pwsh -file scripts/Update-Manifest.ps1 \\",
|
2024-06-07 03:08:18 +00:00
|
|
|
" -ManifestFileName '/data/scratch/bld_${var.vm_name}_${source.name}.mf'",
|
2023-01-18 14:09:32 +00:00
|
|
|
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
2024-06-07 03:08:18 +00:00
|
|
|
" '/data/scratch/bld_${var.vm_name}_${source.name}.ovf' \\",
|
2023-07-07 15:31:32 +00:00
|
|
|
" /output/airgapped-k8s-${var.appliance_version}+${var.k8s_version}-${source.name}.ova"
|
2023-01-18 14:09:32 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|