From 1428fe73f79f84904267493d8ea65b67925bbe9c Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Thu, 19 Jan 2023 21:15:48 +0100 Subject: [PATCH] Fix path;Debug packer contextual vars --- ansible/roles/firstboot/tasks/main.yml | 2 +- packer/build.pkr.hcl | 41 +++++--------------------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/ansible/roles/firstboot/tasks/main.yml b/ansible/roles/firstboot/tasks/main.yml index 40b55f4..0bc0217 100644 --- a/ansible/roles/firstboot/tasks/main.yml +++ b/ansible/roles/firstboot/tasks/main.yml @@ -27,7 +27,7 @@ - name: Copy payload folder (per appliancetype) ansible.builtin.copy: - src: ansible_payload/{{ appliancetype }} + src: ansible_payload/{{ appliancetype }}/ dest: /opt/firstboot/ansible/ owner: root group: root diff --git a/packer/build.pkr.hcl b/packer/build.pkr.hcl index 8278214..f730e2f 100644 --- a/packer/build.pkr.hcl +++ b/packer/build.pkr.hcl @@ -9,44 +9,15 @@ build { vm_name = "${var.vm_name}-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}-${source.name}.ovf' \"", - "pwsh -file scripts/Update-Manifest.ps1 \\", - " -ManifestFileName '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.mf'", - "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", - " '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.ovf' \\", - " /output/airgapped-k8s.${source.name}.ova" - ] - } -} - -build { source "vsphere-iso.ubuntu" { name = "upgrade" vm_name = "${var.vm_name}-upgrade" } + provisioner "shell" { + inline = ["echo ${source.name}"] + } + provisioner "ansible" { pause_before = "2m30s" @@ -65,6 +36,10 @@ build { ] } + provisioner "shell" { + inline = ["echo ${source.name}"] + } + post-processor "shell-local" { inline = [ "pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",