From d915c21e4422e2b7b5d88a61f041daaeb2302c72 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Thu, 19 Jan 2023 15:24:23 +0100 Subject: [PATCH] Upgrade base image;Unpin ansible-core;Attempt different packer syntax --- ansible/roles/os/vars/main.yml | 4 +-- packer/build.pkr.hcl | 59 +++++++++++++++++++++++----------- packer/iso.auto.pkrvars.hcl | 9 +++--- packer/sources.pkr.hcl | 5 +++ 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/ansible/roles/os/vars/main.yml b/ansible/roles/os/vars/main.yml index 79e5098..58082b1 100644 --- a/ansible/roles/os/vars/main.yml +++ b/ansible/roles/os/vars/main.yml @@ -3,8 +3,8 @@ packages: - jq - python3-pip pip: - # Some change causes high load during loops of importing/pushing container images - - ansible-core<2.14.0 + # - ansible-core<2.14.0 + - ansible-core - jinja2 - lxml - markupsafe diff --git a/packer/build.pkr.hcl b/packer/build.pkr.hcl index 0a24804..b932e40 100644 --- a/packer/build.pkr.hcl +++ b/packer/build.pkr.hcl @@ -7,21 +7,6 @@ build { source "vsphere-iso.ubuntu" { name = "bootstrap" vm_name = "${var.vm_name}-bootstrap" - - export { - images = false - output_directory = "/scratch/airgapped-k8s/bootstrap" - } - } - - source "vsphere-iso.ubuntu" { - name = "upgrade" - vm_name = "${var.vm_name}-upgrade" - - export { - images = false - output_directory = "/scratch/airgapped-k8s/upgrade" - } } provisioner "ansible" { @@ -46,11 +31,49 @@ build { inline = [ "pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\", " -ApplianceType '${source.name} \\", - " -OVFFile '/scratch/airgapped-k8s/${source.name}/${var.vm_name}-${source.name}.ovf' \"", + " -OVFFile '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.ovf' \"", "pwsh -file scripts/Update-Manifest.ps1 \\", - " -ManifestFileName '/scratch/airgapped-k8s/${source.name}/${var.vm_name}-${source.name}.mf'", + " -ManifestFileName '/scratch/airgapped-k8s/${var.vm_name}-${source.name}.mf'", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", - " '/scratch/airgapped-k8s/${source.name}/${var.vm_name}-${source.name}.ovf' \\", + " '/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 "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" ] } diff --git a/packer/iso.auto.pkrvars.hcl b/packer/iso.auto.pkrvars.hcl index 5b5e597..5409498 100644 --- a/packer/iso.auto.pkrvars.hcl +++ b/packer/iso.auto.pkrvars.hcl @@ -1,4 +1,5 @@ -iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2022.04/ubuntu-22.04-live-server-amd64.iso" -iso_checksum = "sha256:84AEAF7823C8C61BAA0AE862D0A06B03409394800000B3235854A6B38EB4856F" -// iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2020.04/ubuntu-20.04.2-live-server-amd64.iso" -// iso_checksum = "sha256:D1F2BF834BBE9BB43FAF16F9BE992A6F3935E65BE0EDECE1DEE2AA6EB1767423" +iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2022.04/ubuntu-22.04.1-live-server-amd64.iso" +iso_checksum = "sha256:10F19C5B2B8D6DB711582E0E27F5116296C34FE4B313BA45F9B201A5007056CB" + +// iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2022.04/ubuntu-22.04-live-server-amd64.iso" +// iso_checksum = "sha256:84AEAF7823C8C61BAA0AE862D0A06B03409394800000B3235854A6B38EB4856F" diff --git a/packer/sources.pkr.hcl b/packer/sources.pkr.hcl index 3774c76..074a9d5 100644 --- a/packer/sources.pkr.hcl +++ b/packer/sources.pkr.hcl @@ -53,4 +53,9 @@ source "vsphere-iso" "ubuntu" { shutdown_timeout = "5m" remove_cdrom = true + + export { + images = false + output_directory = "/scratch/airgapped-k8s" + } }