Attempt to properly match build w/ source
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2023-01-25 14:16:50 +01:00
parent 4bcb1198f3
commit fdfe5f100b
2 changed files with 42 additions and 9 deletions

View File

@ -6,12 +6,7 @@ packer {
build { build {
source "vsphere-iso.ubuntu" { source "vsphere-iso.ubuntu" {
name = "bootstrap" name = "bootstrap"
vm_name = "${var.vm_name}-bootstrap" vm_name = "${var.vm_name}-${build.PackerRunUUID}"
}
source "vsphere-iso.ubuntu" {
name = "upgrade"
vm_name = "${var.vm_name}-upgrade"
} }
provisioner "ansible" { provisioner "ansible" {
@ -36,11 +31,49 @@ build {
inline = [ inline = [
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\", "pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
" -ApplianceType '${source.name}' \\", " -ApplianceType '${source.name}' \\",
" -OVFFile '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.ovf' \"", " -OVFFile '/scratch/airgapped-k8s/${var.vm_name}-${build.PackerRunUUID}.ovf' \"",
"pwsh -file scripts/Update-Manifest.ps1 \\", "pwsh -file scripts/Update-Manifest.ps1 \\",
" -ManifestFileName '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.mf'", " -ManifestFileName '/scratch/airgapped-k8s/${var.vm_name}-${build.PackerRunUUID}.mf'",
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
" '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.ovf' \\", " '/scratch/airgapped-k8s/${var.vm_name}-${build.PackerRunUUID}.ovf' \\",
" /output/airgapped-k8s.${source.name}.ova"
]
}
}
build {
source "vsphere-iso.ubuntu" {
name = "upgrade"
vm_name = "${var.vm_name}-${build.PackerRunUUID}"
}
provisioner "ansible" {
pause_before = "2m30s"
playbook_file = "ansible/playbook.yml"
user = "ubuntu"
ansible_env_vars = [
"ANSIBLE_CONFIG=ansible/ansible.cfg",
"PYTHONUNBUFFERED=1"
]
use_proxy = "false"
extra_arguments = [
"--extra-vars", "appliancetype=${source.name}",
"--extra-vars", "ansible_ssh_pass=${var.ssh_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/${var.vm_name}-${build.PackerRunUUID}.ovf' \"",
"pwsh -file scripts/Update-Manifest.ps1 \\",
" -ManifestFileName '/scratch/airgapped-k8s/${var.vm_name}-${build.PackerRunUUID}.mf'",
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
" '/scratch/airgapped-k8s/${var.vm_name}-${build.PackerRunUUID}.ovf' \\",
" /output/airgapped-k8s.${source.name}.ova" " /output/airgapped-k8s.${source.name}.ova"
] ]
} }