Packer.Images/packer/build.pkr.hcl
Danny Bessems 6942c33ae8
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Fix Ansible templating;DRY
2023-04-03 16:26:38 +02:00

62 lines
1.8 KiB
HCL

packer {
required_plugins {
}
}
build {
source "vsphere-iso.ubuntu" {
name = "bootstrap"
vm_name = "ova.bootstrap-${var.vm_name}"
export {
images = false
output_directory = "/scratch/airgapped-k8s/bootstrap"
}
}
source "vsphere-iso.ubuntu" {
name = "upgrade"
vm_name = "ova.upgrade-${var.vm_name}"
export {
images = false
output_directory = "/scratch/airgapped-k8s/upgrade"
}
}
provisioner "ansible" {
pause_before = "45s"
playbook_file = "ansible/playbook.yml"
user = "ubuntu"
ansible_env_vars = [
"ANSIBLE_CONFIG=ansible/ansible.cfg",
"PYTHONUNBUFFERED=1"
]
use_proxy = "false"
collections-path = "/scratch/ansible-galaxy"
extra_arguments = [
"--extra-vars", "appliancetype=${source.name}",
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}",
"--extra-vars", "docker_username=${var.docker_username}",
"--extra-vars", "docker_password=${var.docker_password}",
"--extra-vars", "repo_username=${var.repo_username}",
"--extra-vars", "repo_password=${var.repo_password}"
]
}
post-processor "shell-local" {
inline = [
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
" -ApplianceType '${source.name}' \\",
" -OVFFile '/scratch/airgapped-k8s/${source.name}/ova.${source.name}-${var.vm_name}.ovf' \"",
"pwsh -file scripts/Update-Manifest.ps1 \\",
" -ManifestFileName '/scratch/airgapped-k8s/${source.name}/ova.${source.name}-${var.vm_name}.mf'",
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
" '/scratch/airgapped-k8s/${source.name}/ova.${source.name}-${var.vm_name}.ovf' \\",
" /output/airgapped-k8s-${var.k8s_version}.${source.name}.ova"
]
}
}