From 3f2f19b36afd8a6f04451dcea49578a06bcecb77 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Wed, 25 Jan 2023 14:35:54 +0100 Subject: [PATCH] Attempt to properly match build w/ source #2 --- packer/build.pkr.hcl | 51 +++++++++++-------------------------------- packer/source.pkr.hcl | 1 - 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/packer/build.pkr.hcl b/packer/build.pkr.hcl index ef3bc33..e97b66c 100644 --- a/packer/build.pkr.hcl +++ b/packer/build.pkr.hcl @@ -6,45 +6,20 @@ packer { build { source "vsphere-iso.ubuntu" { name = "bootstrap" - vm_name = "${var.vm_name}-{{ build `PackerRunUUID` }}" + vm_name = "${var.vm_name}-bootstrap" + + export { + output_directory = "/scratch/airgapped-k8s/bootstrap" + } } - 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" - ] - } -} - -build { source "vsphere-iso.ubuntu" { name = "upgrade" - vm_name = "${var.vm_name}-{{ build `PackerRunUUID` }}" + vm_name = "${var.vm_name}-upgrade" + + export { + output_directory = "/scratch/airgapped-k8s/upgrade" + } } provisioner "ansible" { @@ -69,11 +44,11 @@ build { inline = [ "pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\", " -ApplianceType '${source.name}' \\", - " -OVFFile '/scratch/airgapped-k8s/${var.vm_name}-{{ build `PackerRunUUID` }}.ovf' \"", + " -OVFFile '/scratch/airgapped-k8s/${source.name}/${var.vm_name}-${source.name}.ovf' \"", "pwsh -file scripts/Update-Manifest.ps1 \\", - " -ManifestFileName '/scratch/airgapped-k8s/${var.vm_name}-{{ build `PackerRunUUID` }}.mf'", + " -ManifestFileName '/scratch/airgapped-k8s/${source.name}/${var.vm_name}-${source.name}.mf'", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", - " '/scratch/airgapped-k8s/${var.vm_name}-{{ build `PackerRunUUID` }}.ovf' \\", + " '/scratch/airgapped-k8s/${source.name}/${var.vm_name}-${source.name}.ovf' \\", " /output/airgapped-k8s.${source.name}.ova" ] } diff --git a/packer/source.pkr.hcl b/packer/source.pkr.hcl index 074a9d5..174b636 100644 --- a/packer/source.pkr.hcl +++ b/packer/source.pkr.hcl @@ -56,6 +56,5 @@ source "vsphere-iso" "ubuntu" { export { images = false - output_directory = "/scratch/airgapped-k8s" } }