From 9750106dc072302b7b4456ac9decf6e7ac3e96fd Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:11:05 -0500 Subject: [PATCH 01/13] chore: ignore packer plugin files --- .gitignore | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 444098a..ce41500 100644 --- a/.gitignore +++ b/.gitignore @@ -2,21 +2,27 @@ **/credentials* # Configurations -## Ignore default config directory. +# Ignore default config directory. config/ # Manifests -## Ignore manifests directory. +# Ignore manifests directory. manifests/*.json # MacOS -## Ignore desktop services files. +# Ignore desktop services files. **/.DS_Store # Certificates and Keys -## Ignore certificates files. +# Ignore certificates files. **/*.cer **/*.crt **/*.p7b -## Ignore public key files + +# Ignore public key files **/*.pub + +# Ignore packer plugin files +plugin.hwm +plugin.pwd +plugin.pwi From d5561e53041d8ae952629c737d07708c3f63fce6 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:12:05 -0500 Subject: [PATCH 02/13] feat: add help, build_vars, and updated builds themselves --- build.sh | 342 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 304 insertions(+), 38 deletions(-) diff --git a/build.sh b/build.sh index 7c0d2a7..02591d7 100755 --- a/build.sh +++ b/build.sh @@ -4,11 +4,55 @@ set -e source common.sh +if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then + echo "Usage: script.sh [OPTIONS] [CONFIG_PATH]" + echo "" + echo "Options:" + echo " -h, --help Show this help message and exit." + echo " -d, --debug Run builds in debug mode." + echo "" + echo "Arguments:" + echo " CONFIG_PATH Path to the configuration directory." + echo "" + echo "Examples:" + echo " ./build.sh" + echo " ./build.sh --help" + echo " ./build.sh --debug" + echo " ./build.sh config" + echo " ./build.sh us-west-1" + echo " ./build.sh --debug config" + echo " ./build.sh --debug us-west-1" + exit 0 +fi + +if [ "$1" == "--debug" ] || [ "$1" == "-d" ]; then + debug_mode=true + debug_option="-debug" + shift +else + debug_mode=false + debug_option="" +fi + SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")") -CONFIG_PATH=$(realpath "${1:-${SCRIPT_PATH}/config}") + +if [ -n "$1" ]; then + CONFIG_PATH=$(realpath "$1") +else + CONFIG_PATH=$(realpath "${SCRIPT_PATH}/config") +fi + +menu_message="Select a HashiCorp Packer build for Proxmox." + +if [ "$debug_mode" = true ]; then + menu_message+=" \e[31m(Debug Mode)\e[0m" +fi menu_option_1() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux/9/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a AlmaLinux 9 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -26,13 +70,15 @@ menu_option_1() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### @@ -41,6 +87,9 @@ menu_option_1() { menu_option_2() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux/8/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a AlmaLinux 8 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -58,13 +107,15 @@ menu_option_2() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### @@ -72,7 +123,47 @@ menu_option_2() { } menu_option_3() { + INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/10-stream/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + + echo -e "\nCONFIRM: Build a CentOS 10 Stream Template for Proxmox?" + echo -e "\nContinue? (y/n)" + read -r REPLY + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + exit 1 + fi + + ### Build a CentOS 10 Stream Template for Proxmox. ### + echo "Building a CentOS 10 Stream Template for Proxmox..." + + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." + packer init "$INPUT_PATH" + + ### Start the Build. ### + echo "Starting the build...." + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ + -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ + "$INPUT_PATH" + + ### All done. ### + echo "Done." +} + +menu_option_4() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/9-stream/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a CentOS 9 Stream Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -90,21 +181,26 @@ menu_option_3() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_4() { +menu_option_5() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/debian/12/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Debian 12 (Bookworm) Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -122,21 +218,26 @@ menu_option_4() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_5() { +menu_option_6() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/debian/11/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Debian 11 (Bullseye) Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -154,21 +255,26 @@ menu_option_5() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_6() { +menu_option_7() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/opensuse/leap-15-6/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a OpenSUSE Leap 15.6 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -186,21 +292,26 @@ menu_option_6() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_7() { +menu_option_8() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/opensuse/leap-15-5/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a OpenSUSE Leap 15.5 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -218,21 +329,26 @@ menu_option_7() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_8() { +menu_option_9() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/oracle/9/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Oracle Linux 9 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -250,21 +366,26 @@ menu_option_8() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_9() { +menu_option_10() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/oracle/8/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Oracle Linux 8 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -282,21 +403,26 @@ menu_option_9() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_10() { +menu_option_11() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky/9/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Rocky Linux 9 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -314,21 +440,26 @@ menu_option_10() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_11() { +menu_option_12() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky/8/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Rocky Linux 8 Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -346,21 +477,26 @@ menu_option_11() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_12() { +menu_option_13() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/24-04-lts/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Ubuntu Server 24.04 LTS Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -378,21 +514,26 @@ menu_option_12() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_13() { +menu_option_14() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/22-04-lts/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Ubuntu Server 22.04 LTS Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -410,21 +551,26 @@ menu_option_13() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### echo "Done." } -menu_option_14() { +menu_option_15() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/20-04-lts/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS Template for Proxmox?" echo -e "\nContinue? (y/n)" read -r REPLY @@ -442,13 +588,125 @@ menu_option_14() { ### Start the Build. ### echo "Starting the build...." - packer build -force \ + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ -var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \ -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ + "$INPUT_PATH" + + ### All done. ### + echo "Done." +} + +menu_option_16() { + INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + + echo -e "\nCONFIRM: Build all Windows 11 Templates for Proxmox?" + echo -e "\nContinue? (y/n)" + read -r REPLY + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + exit 1 + fi + + ### Build all Windows 11 Templates for Proxmox. ### + echo "Building all Windows 11 Templates for Proxmox..." + + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." + packer init "$INPUT_PATH" + + ### Start the Build. ### + echo "Starting the build...." + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ + -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ + "$INPUT_PATH" + + ### All done. ### + echo "Done." +} + +menu_option_17() { + INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + + echo -e "\nCONFIRM: Build a Windows 11 - Enterprise Template for Proxmox?" + echo -e "\nContinue? (y/n)" + read -r REPLY + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + exit 1 + fi + + ### Build a Windows 11 - Enterprise Template for Proxmox. ### + echo "Building a Windows 11 - Enterprise Template for Proxmox..." + + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." + packer init "$INPUT_PATH" + + ### Start the Build. ### + echo "Starting the build...." + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ + --only proxmox-iso.windows-desktop-ent \ + -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ + "$INPUT_PATH" + + ### All done. ### + echo "Done." +} + +menu_option_18() { + INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/ + BUILD_PATH=${INPUT_PATH#"${SCRIPT_PATH}/builds/"} + BUILD_VARS="$(echo "${BUILD_PATH%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + + echo -e "\nCONFIRM: Build a Windows 11 - Professional Template for Proxmox?" + echo -e "\nContinue? (y/n)" + read -r REPLY + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + exit 1 + fi + + ### Build a Windows 11 - Professional Templates for Proxmox. ### + echo "Building a Windows 11 - Professional Template for Proxmox..." + + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." + packer init "$INPUT_PATH" + + ### Start the Build. ### + echo "Starting the build...." + echo "packer build -force -on-error=ask $debug_option" + packer build -force -on-error=ask $debug_option \ + --only proxmox-iso.windows-desktop-pro \ + -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/network.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/$BUILD_VARS" \ "$INPUT_PATH" ### All done. ### @@ -489,18 +747,22 @@ until [ "$selection" = "0" ]; do echo "" echo " 1 - AlmaLinux 9" echo " 2 - AlmaLinux 8" - echo " 3 - CentOS 9 Stream" - echo " 4 - Debian 12" - echo " 5 - Debian 11" - echo " 6 - OpenSUSE Leap 15.6" - echo " 7 - OpenSUSE Leap 15.5" - echo " 8 - Oracle Linux 9" - echo " 9 - Oracle Linux 8" - echo " 10 - Rocky Linux 9" - echo " 11 - Rocky Linux 8" - echo " 12 - Ubuntu Server 24.04 LTS" - echo " 13 - Ubuntu Server 22.04 LTS" - echo " 14 - Ubuntu Server 20.04 LTS" + echo " 3 - CentOS 10 Stream" + echo " 4 - CentOS 9 Stream" + echo " 5 - Debian 12" + echo " 6 - Debian 11" + echo " 7 - OpenSUSE Leap 15.6" + echo " 8 - OpenSUSE Leap 15.5" + echo " 9 - Oracle Linux 9" + echo " 10 - Oracle Linux 8" + echo " 11 - Rocky Linux 9" + echo " 12 - Rocky Linux 8" + echo " 13 - Ubuntu Server 24.04 LTS" + echo " 14 - Ubuntu Server 22.04 LTS" + echo " 15 - Ubuntu Server 20.04 LTS" + echo " 16 - Windows 11 - All" + echo " 17 - Windows 11 - Enterprise Only" + echo " 18 - Windows 11 - Professional Only" echo "" echo " Other:" echo "" @@ -524,6 +786,10 @@ until [ "$selection" = "0" ]; do 12) clear ; menu_option_12 ; press_enter ;; 13) clear ; menu_option_13 ; press_enter ;; 14) clear ; menu_option_14 ; press_enter ;; + 15) clear ; menu_option_15 ; press_enter ;; + 16) clear ; menu_option_16 ; press_enter ;; + 17) clear ; menu_option_17 ; press_enter ;; + 18) clear ; menu_option_18 ; press_enter ;; [Ii] ) clear ; info ; press_enter ;; [Qq] ) clear ; exit ;; * ) clear ; incorrect_selection ; press_enter ;; From a90d6c603767b4c4a16137edcafe4573082e7965 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:12:47 -0500 Subject: [PATCH 03/13] feat: add support for copying vars files for individual builds --- config.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/config.sh b/config.sh index b33faac..abe1f8b 100755 --- a/config.sh +++ b/config.sh @@ -7,24 +7,31 @@ source common.sh SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")") CONFIG_PATH=${1:-${SCRIPT_PATH}/config} -mkdir -p "$CONFIG_PATH" +# Define the script and config paths +follow_link_result=$(follow_link "$0") +if ! SCRIPT_PATH=$(realpath "$(dirname "${follow_link_result}")"); then + echo "Error: follow_link or realpath failed" + exit 1 +fi +CONFIG_PATH=${1:-${SCRIPT_PATH}/config} + +mkdir -p "${CONFIG_PATH}" ### Copy the example input variables. echo echo "> Copying the example input variables..." -cp -av "$SCRIPT_PATH"/builds/*.pkrvars.hcl.example "$CONFIG_PATH" +cp -av "${SCRIPT_PATH}"/builds/*.pkrvars.hcl.example "${CONFIG_PATH}" +find "${SCRIPT_PATH}"/builds/*/ -type f -name "*.pkrvars.hcl.example" | while IFS= read -r srcfile; do + srcdir=$(dirname "${srcfile}" | tr -s /) + dstfile=$(echo "${srcdir#"${SCRIPT_PATH}"/builds/}" | tr '/' '-') + cp -av "${srcfile}" "${CONFIG_PATH}/${dstfile}.pkrvars.hcl.example" +done ### Rename the example input variables. echo echo "> Renaming the example input variables..." -srcext=".pkrvars.hcl.example" -dstext=".pkrvars.hcl" - -for f in "$CONFIG_PATH"/*"${srcext}"; do - bname="${f%"${srcext}"}" - echo "${bname}{${srcext} → ${dstext}}" - mv "${f}" "${bname}${dstext}" +for file in "${CONFIG_PATH}"/*.pkrvars.hcl.example; do + mv -- "${file}" "${file%.example}" done echo echo "> Done." - From 72222454360a3ca0d30bd5066398e3dfdec85fcd Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:13:08 -0500 Subject: [PATCH 04/13] feat: add build validator script --- validate.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 validate.sh diff --git a/validate.sh b/validate.sh new file mode 100755 index 0000000..969ea03 --- /dev/null +++ b/validate.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +set -e + +# Load common functions +source common.sh + +# === Colors === +GREEN="\033[0;32m" +YELLOW="\033[1;33m" +RED="\033[0;31m" +BLUE="\033[0;34m" +NC="\033[0m" + +# === Paths === +SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")") +CONFIG_PATH=$(realpath "${1:-${SCRIPT_PATH}/config}") + +INPUT_PATHS=( + "$SCRIPT_PATH/builds/linux/almalinux/9/" + "$SCRIPT_PATH/builds/linux/almalinux/8/" + "$SCRIPT_PATH/builds/linux/centos/10-stream/" + "$SCRIPT_PATH/builds/linux/centos/9-stream/" + "$SCRIPT_PATH/builds/linux/debian/12/" + "$SCRIPT_PATH/builds/linux/debian/11/" + "$SCRIPT_PATH/builds/linux/opensuse/leap-15-6/" + "$SCRIPT_PATH/builds/linux/opensuse/leap-15-5/" + "$SCRIPT_PATH/builds/linux/oracle/9/" + "$SCRIPT_PATH/builds/linux/oracle/8/" + "$SCRIPT_PATH/builds/linux/rocky/9/" + "$SCRIPT_PATH/builds/linux/rocky/8/" + "$SCRIPT_PATH/builds/linux/ubuntu/24-04-lts/" + "$SCRIPT_PATH/builds/linux/ubuntu/22-04-lts/" + "$SCRIPT_PATH/builds/linux/ubuntu/20-04-lts/" + "$SCRIPT_PATH/builds/windows/desktop/11/" +) + +# === Result storage === +declare -a summary=() + +# === Validation Function === +validate_packer() { + local input_path="$1" + local current_build_path current_build_vars os version + + version=$(basename "$input_path") + os=$(basename "$(dirname "$input_path")") + + echo -e "${BLUE}▶ Validating: ${YELLOW}${os^^} ${version}${NC}" + + if echo "$input_path" | grep -qi "windows"; then + current_build_path=${input_path#"${SCRIPT_PATH}/builds/"} + current_build_vars="$(echo "${current_build_path%/}" | tr -s '/' | tr '/' '-').pkrvars.hcl" + VAR_FILES=( + "$CONFIG_PATH/ansible.pkrvars.hcl" + "$CONFIG_PATH/build.pkrvars.hcl" + "$CONFIG_PATH/common.pkrvars.hcl" + "$CONFIG_PATH/network.pkrvars.hcl" + "$CONFIG_PATH/proxmox.pkrvars.hcl" + "$CONFIG_PATH/proxy.pkrvars.hcl" + "$CONFIG_PATH/$current_build_vars" + ) + else + VAR_FILES=( + "$CONFIG_PATH/ansible.pkrvars.hcl" + "$CONFIG_PATH/build.pkrvars.hcl" + "$CONFIG_PATH/common.pkrvars.hcl" + "$CONFIG_PATH/linux-storage.pkrvars.hcl" + "$CONFIG_PATH/network.pkrvars.hcl" + "$CONFIG_PATH/proxmox.pkrvars.hcl" + "$CONFIG_PATH/proxy.pkrvars.hcl" + ) + fi + +if packer_output=$(packer validate "${VAR_FILES[@]/#/--var-file=}" "$input_path" 2>&1); then + echo -e " ${GREEN}✔ PASS${NC}" + summary+=("${os}/${version} : PASS") +else + echo -e " ${RED}✘ FAIL${NC}" + echo "$packer_output" + summary+=("${os}/${version} : FAIL") +fi + + echo -e "${NC}----------------------------------------" +} + +# === Main Execution === +echo -e "${BLUE}==> Starting Packer validations...${NC}" +for path in "${INPUT_PATHS[@]}"; do + validate_packer "$path" +done + +# === Summary Output === +echo -e "\n${BLUE}==> Validation Summary:${NC}" +for entry in "${summary[@]}"; do + if [[ "$entry" == *FAIL ]]; then + echo -e "${RED}$entry${NC}" + else + echo -e "${GREEN}$entry${NC}" + fi +done + From f87e61ab80581498c551d5d8cb77baf09293b651 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:17:51 -0500 Subject: [PATCH 05/13] fix: add or update var names for consistency --- builds/common.pkrvars.hcl.example | 14 ++++++++------ builds/proxmox.pkrvars.hcl.example | 7 +++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/builds/common.pkrvars.hcl.example b/builds/common.pkrvars.hcl.example index 64c7e1e..722096c 100644 --- a/builds/common.pkrvars.hcl.example +++ b/builds/common.pkrvars.hcl.example @@ -11,12 +11,14 @@ common_iso_storage = "OS" vm_storage_pool = "pool0" // Boot and Provisioning Settings -common_data_source = "http" -common_http_ip = null -common_http_port_min = 8000 -common_http_port_max = 8099 -common_ip_wait_timeout = "20m" -common_shutdown_timeout = "15m" +common_data_source = "http" +common_http_interface = null +common_http_bind_address = null +common_http_port_min = 8000 +common_http_port_max = 8099 +common_ip_wait_timeout = "20m" +common_shutdown_timeout = "15m" // HCP Packer common_hcp_packer_registry_enabled = false + diff --git a/builds/proxmox.pkrvars.hcl.example b/builds/proxmox.pkrvars.hcl.example index 16a26e9..ceba91b 100644 --- a/builds/proxmox.pkrvars.hcl.example +++ b/builds/proxmox.pkrvars.hcl.example @@ -5,11 +5,10 @@ */ // Proxmox Credentials -proxmox_api_url = "" proxmox_api_token_id = "name@realm!token" proxmox_api_token_secret = "" proxmox_insecure_connection = false -// Proxmox Settings -proxmox_node = "" -proxmox_hostname = "" +// Proxmox Specific Settings +proxmox_hostname = "" +proxmox_node = "" From cf8f643f0a9bbb7038af6284efa14af1d9bac97b Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:19:44 -0500 Subject: [PATCH 06/13] fix: update boot_iso section, fix var names, and pin proxmox plugin version --- .../linux/almalinux/8/linux-almalinux.pkr.hcl | 21 +++++++++++------ builds/linux/almalinux/8/variables.pkr.hcl | 10 ++++++-- .../linux/almalinux/9/linux-almalinux.pkr.hcl | 21 +++++++++++------ builds/linux/almalinux/9/variables.pkr.hcl | 10 ++++++-- .../10-stream/linux-centos-stream.pkr.hcl | 23 ++++++++++++------- .../linux/centos/10-stream/variables.pkr.hcl | 8 ++++++- .../9-stream/linux-centos-stream.pkr.hcl | 23 ++++++++++++------- .../linux/centos/9-stream/variables.pkr.hcl | 10 ++++++-- builds/linux/debian/11/linux-debian.pkr.hcl | 23 ++++++++++++------- builds/linux/debian/11/variables.pkr.hcl | 10 ++++++-- builds/linux/debian/12/linux-debian.pkr.hcl | 23 ++++++++++++------- builds/linux/debian/12/variables.pkr.hcl | 10 ++++++-- .../leap-15-5/linux-opensuse-leap.pkr.hcl | 21 +++++++++++------ .../opensuse/leap-15-5/variables.pkr.hcl | 10 ++++++-- .../leap-15-6/linux-opensuse-leap.pkr.hcl | 21 +++++++++++------ .../opensuse/leap-15-6/variables.pkr.hcl | 10 ++++++-- builds/linux/oracle/8/linux-oracle.pkr.hcl | 21 +++++++++++------ builds/linux/oracle/8/variables.pkr.hcl | 10 ++++++-- builds/linux/oracle/9/linux-oracle.pkr.hcl | 21 +++++++++++------ builds/linux/oracle/9/variables.pkr.hcl | 10 ++++++-- builds/linux/rocky/8/linux-rocky.pkr.hcl | 23 ++++++++++++------- builds/linux/rocky/8/variables.pkr.hcl | 10 ++++++-- builds/linux/rocky/9/linux-rocky.pkr.hcl | 21 +++++++++++------ builds/linux/rocky/9/variables.pkr.hcl | 10 ++++++-- .../ubuntu/20-04-lts/linux-ubuntu.pkr.hcl | 21 +++++++++++------ .../linux/ubuntu/20-04-lts/variables.pkr.hcl | 10 ++++++-- .../ubuntu/22-04-lts/linux-ubuntu.pkr.hcl | 21 +++++++++++------ .../linux/ubuntu/22-04-lts/variables.pkr.hcl | 10 ++++++-- .../ubuntu/24-04-lts/linux-ubuntu.pkr.hcl | 21 +++++++++++------ .../linux/ubuntu/24-04-lts/variables.pkr.hcl | 10 ++++++-- 30 files changed, 334 insertions(+), 139 deletions(-) diff --git a/builds/linux/almalinux/8/linux-almalinux.pkr.hcl b/builds/linux/almalinux/8/linux-almalinux.pkr.hcl index 48fdca2..47ea347 100644 --- a/builds/linux/almalinux/8/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux/8/linux-almalinux.pkr.hcl @@ -7,7 +7,7 @@ // The Packer configuration. packer { - required_version = ">= 1.11.0" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" @@ -18,7 +18,7 @@ packer { source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.1.8" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -36,7 +36,7 @@ locals { bios_boot_command = [ // This sends the "up arrow" key, typically used to navigate through boot menu options. "", - // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. + // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. "", "inst.text biosdevname=0 net.ifnames=0 inst.gpt", " ${local.data_source_command}", @@ -103,7 +103,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-almalinux" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -122,12 +122,14 @@ source "proxmox-iso" "linux-almalinux" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -136,13 +138,11 @@ source "proxmox-iso" "linux-almalinux" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -155,6 +155,7 @@ source "proxmox-iso" "linux-almalinux" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -162,6 +163,12 @@ source "proxmox-iso" "linux-almalinux" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/almalinux/8/variables.pkr.hcl b/builds/linux/almalinux/8/variables.pkr.hcl index 25b08c4..5d8f009 100644 --- a/builds/linux/almalinux/8/variables.pkr.hcl +++ b/builds/linux/almalinux/8/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/almalinux/9/linux-almalinux.pkr.hcl b/builds/linux/almalinux/9/linux-almalinux.pkr.hcl index 282051f..3326ee2 100644 --- a/builds/linux/almalinux/9/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux/9/linux-almalinux.pkr.hcl @@ -7,7 +7,7 @@ // The Packer configuration. packer { - required_version = ">= 1.11.0" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" @@ -18,7 +18,7 @@ packer { source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.1.8" + version = ">= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -36,7 +36,7 @@ locals { bios_boot_command = [ // This sends the "up arrow" key, typically used to navigate through boot menu options. "", - // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. + // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. "", "inst.text biosdevname=0 net.ifnames=0 inst.gpt", " ${local.data_source_command}", @@ -103,7 +103,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-almalinux" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -122,12 +122,14 @@ source "proxmox-iso" "linux-almalinux" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -136,13 +138,11 @@ source "proxmox-iso" "linux-almalinux" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -155,6 +155,7 @@ source "proxmox-iso" "linux-almalinux" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -162,6 +163,12 @@ source "proxmox-iso" "linux-almalinux" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/almalinux/9/variables.pkr.hcl b/builds/linux/almalinux/9/variables.pkr.hcl index e255b76..9c052fe 100644 --- a/builds/linux/almalinux/9/variables.pkr.hcl +++ b/builds/linux/almalinux/9/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl b/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl index e77c0f6..0f8e444 100644 --- a/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -53,7 +53,7 @@ locals { "text ${local.data_source_command}", // This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process. "x" - ] + ] build_by = "Built by: HashiCorp Packer ${packer.version}" build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" ) @@ -102,7 +102,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-centos-stream" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -121,12 +121,14 @@ source "proxmox-iso" "linux-centos-stream" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -135,13 +137,11 @@ source "proxmox-iso" "linux-centos-stream" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -154,6 +154,7 @@ source "proxmox-iso" "linux-centos-stream" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -161,6 +162,12 @@ source "proxmox-iso" "linux-centos-stream" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/centos/10-stream/variables.pkr.hcl b/builds/linux/centos/10-stream/variables.pkr.hcl index 5c4eedc..645c37f 100644 --- a/builds/linux/centos/10-stream/variables.pkr.hcl +++ b/builds/linux/centos/10-stream/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { diff --git a/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl b/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl index 008fed4..7a00a8c 100644 --- a/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -53,7 +53,7 @@ locals { "text ${local.data_source_command}", // This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process. "x" - ] + ] build_by = "Built by: HashiCorp Packer ${packer.version}" build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" ) @@ -102,7 +102,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-centos-stream" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -121,12 +121,14 @@ source "proxmox-iso" "linux-centos-stream" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -135,13 +137,11 @@ source "proxmox-iso" "linux-centos-stream" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -154,6 +154,7 @@ source "proxmox-iso" "linux-centos-stream" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -161,6 +162,12 @@ source "proxmox-iso" "linux-centos-stream" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/centos/9-stream/variables.pkr.hcl b/builds/linux/centos/9-stream/variables.pkr.hcl index 021fd86..fd174d3 100644 --- a/builds/linux/centos/9-stream/variables.pkr.hcl +++ b/builds/linux/centos/9-stream/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/debian/11/linux-debian.pkr.hcl b/builds/linux/debian/11/linux-debian.pkr.hcl index a66b9c8..b08bbf2 100644 --- a/builds/linux/debian/11/linux-debian.pkr.hcl +++ b/builds/linux/debian/11/linux-debian.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -32,7 +32,7 @@ data "git-repository" "cwd" {} // BLOCK: locals // Defines the local variables. -locals { +locals { bios_boot_command = [ "", @@ -125,7 +125,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "debian" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -144,12 +144,14 @@ source "proxmox-iso" "debian" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -158,13 +160,11 @@ source "proxmox-iso" "debian" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -177,6 +177,7 @@ source "proxmox-iso" "debian" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -184,6 +185,12 @@ source "proxmox-iso" "debian" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/debian/11/variables.pkr.hcl b/builds/linux/debian/11/variables.pkr.hcl index c80568e..2c06bdc 100644 --- a/builds/linux/debian/11/variables.pkr.hcl +++ b/builds/linux/debian/11/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/debian/12/linux-debian.pkr.hcl b/builds/linux/debian/12/linux-debian.pkr.hcl index 6c300af..8a8d444 100644 --- a/builds/linux/debian/12/linux-debian.pkr.hcl +++ b/builds/linux/debian/12/linux-debian.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -32,7 +32,7 @@ data "git-repository" "cwd" {} // BLOCK: locals // Defines the local variables. -locals { +locals { bios_boot_command = [ "", @@ -124,7 +124,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "debian" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -143,12 +143,14 @@ source "proxmox-iso" "debian" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -157,13 +159,11 @@ source "proxmox-iso" "debian" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -176,6 +176,7 @@ source "proxmox-iso" "debian" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -183,6 +184,12 @@ source "proxmox-iso" "debian" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/debian/12/variables.pkr.hcl b/builds/linux/debian/12/variables.pkr.hcl index ca3b54a..1c24e51 100644 --- a/builds/linux/debian/12/variables.pkr.hcl +++ b/builds/linux/debian/12/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/opensuse/leap-15-5/linux-opensuse-leap.pkr.hcl b/builds/linux/opensuse/leap-15-5/linux-opensuse-leap.pkr.hcl index 89f7582..da10146 100644 --- a/builds/linux/opensuse/leap-15-5/linux-opensuse-leap.pkr.hcl +++ b/builds/linux/opensuse/leap-15-5/linux-opensuse-leap.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.1.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -107,7 +107,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-opensuse-leap" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -126,12 +126,14 @@ source "proxmox-iso" "linux-opensuse-leap" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -140,13 +142,11 @@ source "proxmox-iso" "linux-opensuse-leap" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -159,6 +159,7 @@ source "proxmox-iso" "linux-opensuse-leap" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -166,6 +167,12 @@ source "proxmox-iso" "linux-opensuse-leap" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/opensuse/leap-15-5/variables.pkr.hcl b/builds/linux/opensuse/leap-15-5/variables.pkr.hcl index b5451e1..44453e3 100644 --- a/builds/linux/opensuse/leap-15-5/variables.pkr.hcl +++ b/builds/linux/opensuse/leap-15-5/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkr.hcl b/builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkr.hcl index c09a13a..d25ef6f 100644 --- a/builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkr.hcl +++ b/builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.1.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -100,7 +100,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-opensuse-leap" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -119,12 +119,14 @@ source "proxmox-iso" "linux-opensuse-leap" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -133,13 +135,11 @@ source "proxmox-iso" "linux-opensuse-leap" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -152,6 +152,7 @@ source "proxmox-iso" "linux-opensuse-leap" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -159,6 +160,12 @@ source "proxmox-iso" "linux-opensuse-leap" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/opensuse/leap-15-6/variables.pkr.hcl b/builds/linux/opensuse/leap-15-6/variables.pkr.hcl index 54e0a69..93439fd 100644 --- a/builds/linux/opensuse/leap-15-6/variables.pkr.hcl +++ b/builds/linux/opensuse/leap-15-6/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/oracle/8/linux-oracle.pkr.hcl b/builds/linux/oracle/8/linux-oracle.pkr.hcl index 8b0c648..52251e6 100644 --- a/builds/linux/oracle/8/linux-oracle.pkr.hcl +++ b/builds/linux/oracle/8/linux-oracle.pkr.hcl @@ -7,7 +7,7 @@ // The Packer configuration. packer { - required_version = ">= 1.11.0" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" @@ -18,7 +18,7 @@ packer { source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.1.8" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -36,7 +36,7 @@ locals { bios_boot_command = [ // This sends the "up arrow" key, typically used to navigate through boot menu options. "", - // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. + // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. "", "inst.text biosdevname=0 net.ifnames=0 inst.gpt", " ${local.data_source_command}", @@ -103,7 +103,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-oracle" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -122,12 +122,14 @@ source "proxmox-iso" "linux-oracle" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -136,13 +138,11 @@ source "proxmox-iso" "linux-oracle" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -155,6 +155,7 @@ source "proxmox-iso" "linux-oracle" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -162,6 +163,12 @@ source "proxmox-iso" "linux-oracle" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/oracle/8/variables.pkr.hcl b/builds/linux/oracle/8/variables.pkr.hcl index e539bbe..01de9e9 100644 --- a/builds/linux/oracle/8/variables.pkr.hcl +++ b/builds/linux/oracle/8/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/oracle/9/linux-oracle.pkr.hcl b/builds/linux/oracle/9/linux-oracle.pkr.hcl index 58a19d3..54c5cb2 100644 --- a/builds/linux/oracle/9/linux-oracle.pkr.hcl +++ b/builds/linux/oracle/9/linux-oracle.pkr.hcl @@ -7,7 +7,7 @@ // The Packer configuration. packer { - required_version = ">= 1.11.0" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" @@ -18,7 +18,7 @@ packer { source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.1.8" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -36,7 +36,7 @@ locals { bios_boot_command = [ // This sends the "up arrow" key, typically used to navigate through boot menu options. "", - // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. + // This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options. "", "inst.text biosdevname=0 net.ifnames=0 inst.gpt", " ${local.data_source_command}", @@ -103,7 +103,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-oracle" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -122,12 +122,14 @@ source "proxmox-iso" "linux-oracle" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -136,13 +138,11 @@ source "proxmox-iso" "linux-oracle" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -155,6 +155,7 @@ source "proxmox-iso" "linux-oracle" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -162,6 +163,12 @@ source "proxmox-iso" "linux-oracle" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/oracle/9/variables.pkr.hcl b/builds/linux/oracle/9/variables.pkr.hcl index e1715c7..223bc96 100644 --- a/builds/linux/oracle/9/variables.pkr.hcl +++ b/builds/linux/oracle/9/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/rocky/8/linux-rocky.pkr.hcl b/builds/linux/rocky/8/linux-rocky.pkr.hcl index 9f93bcc..0b45e19 100644 --- a/builds/linux/rocky/8/linux-rocky.pkr.hcl +++ b/builds/linux/rocky/8/linux-rocky.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -53,7 +53,7 @@ locals { "text ${local.data_source_command}", // This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process. "x" - ] + ] build_by = "Built by: HashiCorp Packer ${packer.version}" build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" ) @@ -103,7 +103,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-rocky" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -122,12 +122,14 @@ source "proxmox-iso" "linux-rocky" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -136,13 +138,11 @@ source "proxmox-iso" "linux-rocky" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -155,6 +155,7 @@ source "proxmox-iso" "linux-rocky" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -162,6 +163,12 @@ source "proxmox-iso" "linux-rocky" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/rocky/8/variables.pkr.hcl b/builds/linux/rocky/8/variables.pkr.hcl index 2989464..41938b0 100644 --- a/builds/linux/rocky/8/variables.pkr.hcl +++ b/builds/linux/rocky/8/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/rocky/9/linux-rocky.pkr.hcl b/builds/linux/rocky/9/linux-rocky.pkr.hcl index 4c9b15d..1076a9e 100644 --- a/builds/linux/rocky/9/linux-rocky.pkr.hcl +++ b/builds/linux/rocky/9/linux-rocky.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -103,7 +103,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "linux-rocky" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -122,12 +122,14 @@ source "proxmox-iso" "linux-rocky" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -136,13 +138,11 @@ source "proxmox-iso" "linux-rocky" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -155,6 +155,7 @@ source "proxmox-iso" "linux-rocky" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -162,6 +163,12 @@ source "proxmox-iso" "linux-rocky" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/rocky/9/variables.pkr.hcl b/builds/linux/rocky/9/variables.pkr.hcl index 1751228..b3db96b 100644 --- a/builds/linux/rocky/9/variables.pkr.hcl +++ b/builds/linux/rocky/9/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl b/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl index 1681d56..06a9ad4 100644 --- a/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl +++ b/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -110,7 +110,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "ubuntu" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -129,12 +129,14 @@ source "proxmox-iso" "ubuntu" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -143,13 +145,11 @@ source "proxmox-iso" "ubuntu" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -162,6 +162,7 @@ source "proxmox-iso" "ubuntu" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -169,6 +170,12 @@ source "proxmox-iso" "ubuntu" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl b/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl index 3e89fed..ec7a706 100644 --- a/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl b/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl index 3b31787..128fca1 100644 --- a/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl +++ b/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -106,7 +106,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "ubuntu" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -125,12 +125,14 @@ source "proxmox-iso" "ubuntu" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -139,13 +141,11 @@ source "proxmox-iso" "ubuntu" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -158,6 +158,7 @@ source "proxmox-iso" "ubuntu" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -165,6 +166,12 @@ source "proxmox-iso" "ubuntu" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl b/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl index 7a9197a..2ac8974 100644 --- a/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} diff --git a/builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkr.hcl b/builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkr.hcl index 912d164..7642c44 100644 --- a/builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkr.hcl +++ b/builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkr.hcl @@ -7,18 +7,18 @@ // The Packer configuration. packer { - required_version = ">= 1.9.1" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" version = "~> 1" } git = { - version = ">= 0.4.2" + version = ">= 0.6.2" source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.0.6" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -106,7 +106,7 @@ locals { // Defines the builder configuration blocks. source "proxmox-iso" "ubuntu" { - + // Proxmox Connection Settings and Credentials proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" username = "${var.proxmox_api_token_id}" @@ -125,12 +125,14 @@ source "proxmox-iso" "ubuntu" { memory = "${var.vm_mem_size}" os = "${var.vm_os_type}" scsi_controller = "${var.vm_disk_controller_type}" + disks { disk_size = "${var.vm_disk_size}" type = "${var.vm_disk_type}" storage_pool = "${var.vm_storage_pool}" format = "${var.vm_disk_format}" } + dynamic "efi_config" { for_each = var.vm_bios == "ovmf" ? [1] : [] content { @@ -139,13 +141,11 @@ source "proxmox-iso" "ubuntu" { pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null } } - unmount_iso = true + ssh_username = "${var.build_username}" ssh_password = "${var.build_password}" ssh_timeout = "${var.timeout}" ssh_port = "22" - iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" - iso_checksum = "${var.iso_checksum}" qemu_agent = true network_adapters { @@ -158,6 +158,7 @@ source "proxmox-iso" "ubuntu" { http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null // Boot and Provisioning Settings + http_interface = var.common_data_source == "http" ? var.common_http_interface : null http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null @@ -165,6 +166,12 @@ source "proxmox-iso" "ubuntu" { boot_wait = var.vm_boot_wait boot_command = local.boot_command + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = "${var.iso_checksum}" + } + dynamic "additional_iso_files" { for_each = var.common_data_source == "disk" ? [1] : [] content { diff --git a/builds/linux/ubuntu/24-04-lts/variables.pkr.hcl b/builds/linux/ubuntu/24-04-lts/variables.pkr.hcl index 01f9028..853d0b4 100644 --- a/builds/linux/ubuntu/24-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu/24-04-lts/variables.pkr.hcl @@ -215,6 +215,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -250,7 +256,7 @@ variable "common_shutdown_timeout" { variable "build_username" { type = string description = "The username to login to the guest operating system. (e.g. 'ubuntu')" -# sensitive = true +# sensitive = true } variable "build_password" { @@ -304,4 +310,4 @@ variable "additional_packages" { type = list(string) description = "Additional packages to install." default = [] -} \ No newline at end of file +} From 1d76112e931ab63009af3638474b33a1f51d413c Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:20:44 -0500 Subject: [PATCH 07/13] fix: update windows build vars for consistency --- builds/windows/desktop/11/variables.pkr.hcl | 17 +++++++------ builds/windows/desktop/11/windows.pkr.hcl | 19 +++++++++------ .../desktop/11/windows.pkrvars.hcl.example | 24 +++++++++++-------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/builds/windows/desktop/11/variables.pkr.hcl b/builds/windows/desktop/11/variables.pkr.hcl index 8169e6d..09f39dc 100644 --- a/builds/windows/desktop/11/variables.pkr.hcl +++ b/builds/windows/desktop/11/variables.pkr.hcl @@ -114,19 +114,16 @@ variable "vm_os_name" { variable "vm_os_version" { type = string description = "The guest operating system version. Used for naming." - default = "11" } variable "vm_os_edition_pro" { type = string description = "The guest operating system edition. Used for naming." - default = "pro" } variable "vm_os_edition_ent" { type = string description = "The guest operating system edition. Used for naming." - default = "ent" } variable "vm_os_type" { @@ -297,6 +294,12 @@ variable "common_http_bind_address" { default = null } +variable "common_http_interface" { + type = string + description = "Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -307,10 +310,10 @@ variable "common_http_port_max" { description = "The end of the HTTP port range." } -// variable "vm_boot_order" { -// type = string -// description = "The boot order for virtual machines devices." -// } +variable "vm_boot_order" { + type = string + description = "The boot order for virtual machines devices." +} variable "vm_boot_wait" { type = string diff --git a/builds/windows/desktop/11/windows.pkr.hcl b/builds/windows/desktop/11/windows.pkr.hcl index 0295da7..25a6691 100644 --- a/builds/windows/desktop/11/windows.pkr.hcl +++ b/builds/windows/desktop/11/windows.pkr.hcl @@ -8,7 +8,7 @@ // The Packer configuration. packer { - required_version = ">= 1.11.0" + required_version = ">= 1.12.0" required_plugins { ansible = { source = "github.com/hashicorp/ansible" @@ -19,7 +19,7 @@ packer { source = "github.com/ethanmdavidson/git" } proxmox = { - version = ">= 1.2.2" + version = "= 1.2.1" source = "github.com/hashicorp/proxmox" } } @@ -125,11 +125,11 @@ source "proxmox-iso" "windows-desktop-pro" { "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { build_username = var.build_username build_password = var.build_password - vm_inst_os_eval = var.vm_inst_os_eval // Does not support evaluation. + vm_inst_os_eval = var.vm_inst_os_eval vm_inst_os_language = var.vm_inst_os_language vm_inst_os_keyboard = var.vm_inst_os_keyboard vm_inst_os_image = var.vm_inst_os_image_pro - vm_inst_os_key = var.vm_inst_os_key_pro // Does not support evaluation. + vm_inst_os_key = var.vm_inst_os_key_pro vm_guest_os_language = var.vm_os_language vm_guest_os_keyboard = var.vm_os_keyboard vm_guest_os_timezone = var.vm_os_timezone @@ -141,6 +141,8 @@ source "proxmox-iso" "windows-desktop-pro" { } // Boot and Provisioning Settings + http_interface = var.common_http_interface + http_bind_address = var.common_http_bind_address http_port_min = var.common_http_port_min http_port_max = var.common_http_port_max boot_wait = var.vm_boot_wait @@ -235,11 +237,11 @@ source "proxmox-iso" "windows-desktop-ent" { "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { build_username = var.build_username build_password = var.build_password - vm_inst_os_eval = var.vm_inst_os_eval // Does not support evaluation. + vm_inst_os_eval = var.vm_inst_os_eval vm_inst_os_language = var.vm_inst_os_language vm_inst_os_keyboard = var.vm_inst_os_keyboard vm_inst_os_image = var.vm_inst_os_image_ent - vm_inst_os_key = var.vm_inst_os_key_ent // Does not support evaluation. + vm_inst_os_key = var.vm_inst_os_key_ent vm_guest_os_language = var.vm_os_language vm_guest_os_keyboard = var.vm_os_keyboard vm_guest_os_timezone = var.vm_os_timezone @@ -251,6 +253,8 @@ source "proxmox-iso" "windows-desktop-ent" { } // Boot and Provisioning Settings + http_interface = var.common_http_interface + http_bind_address = var.common_http_bind_address http_port_min = var.common_http_port_min http_port_max = var.common_http_port_max boot_wait = var.vm_boot_wait @@ -272,7 +276,8 @@ source "proxmox-iso" "windows-desktop-ent" { build { sources = [ - "source.proxmox-iso.windows-desktop-ent" + "source.proxmox-iso.windows-desktop-pro", + "source.proxmox-iso.windows-desktop-ent", ] provisioner "ansible" { diff --git a/builds/windows/desktop/11/windows.pkrvars.hcl.example b/builds/windows/desktop/11/windows.pkrvars.hcl.example index 7d0c9ed..a5398f8 100644 --- a/builds/windows/desktop/11/windows.pkrvars.hcl.example +++ b/builds/windows/desktop/11/windows.pkrvars.hcl.example @@ -5,16 +5,20 @@ */ // Installation Operating System Metadata +vm_inst_os_eval = true +vm_inst_os_language = "en-US" +vm_inst_os_keyboard = "en-US" +vm_inst_os_image_pro = "Windows 11 Pro" vm_inst_os_key_pro = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" +vm_inst_os_image_ent = "Windows 11 Enterprise Evaluation" vm_inst_os_key_ent = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" -// Virtual Machine Guest Operating System Setting -vm_guest_os_type = "windows9_64Guest" - -// Virtual Machine Hardware Settings -vm_firmware = "efi-secure" - -// Removable Media Settings -iso_datastore_path = "iso/windows/windows-desktop/11/amd64" -iso_content_library_item = "22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us" -iso_file = "22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso" +// Guest Operating System Metadata +vm_os_language = "en-US" +vm_os_keyboard = "en-US" +vm_os_timezone = "UTC" +vm_os_family = "windows" +vm_os_name = "desktop" +vm_os_version = "11" +vm_os_edition_pro = "pro" +vm_os_edition_ent = "ent" From 21ec1dbea441022a699792047017111cd6b10f8e Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:21:30 -0500 Subject: [PATCH 08/13] feat: variablize the list of chocolatey packages --- ansible/roles/base/defaults/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ansible/roles/base/defaults/main.yml b/ansible/roles/base/defaults/main.yml index ee29246..b720345 100644 --- a/ansible/roles/base/defaults/main.yml +++ b/ansible/roles/base/defaults/main.yml @@ -1,2 +1,6 @@ --- -enable_cloudinit: false \ No newline at end of file +enable_cloudinit: false + +base_chocolatey_packages: + - firefox + - putty From 78e6cdcf844eea077b11809ce2f41af37ed6531b Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:22:01 -0500 Subject: [PATCH 09/13] feat: streamline the chocolatey install and removed windows system updates --- ansible/roles/base/tasks/windows.yml | 51 +++++----------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/ansible/roles/base/tasks/windows.yml b/ansible/roles/base/tasks/windows.yml index d4559dc..3d5d0db 100644 --- a/ansible/roles/base/tasks/windows.yml +++ b/ansible/roles/base/tasks/windows.yml @@ -6,46 +6,13 @@ ansible.builtin.debug: msg: "OS: {{ ansible_os_name }}" -- name: Ensure .NET Framework 4.8 requirement is satisfied for Chocolatey v2.0.0 and later - when: ansible_os_installation_type != "Server Core" - block: - - name: Install Chocolatey CLI - chocolatey.chocolatey.win_chocolatey: - name: chocolatey - state: present - version: 1.4.0 +- name: Install latest version of Chocolatey + chocolatey.chocolatey.win_chocolatey: + name: chocolatey + state: latest - - name: Install Microsoft .NET Framework 4.8 - chocolatey.chocolatey.win_chocolatey: - name: netfx-4.8 - state: present - - - name: Reboot the host to complete .NET Framework 4.8 install - ansible.windows.win_reboot: - - - name: Install latest version of Chocolatey - chocolatey.chocolatey.win_chocolatey: - name: chocolatey - state: latest - - - name: Installing additional packages using Chocolatey - chocolatey.chocolatey.win_chocolatey: - name: - - googlechrome - - putty - state: latest - ignore_checksums: true - -- name: Updating the operating system - ansible.windows.win_updates: - category_names: - - SecurityUpdates - - CriticalUpdates - reject_list: - - 5034439 - - 5034441 - reboot: true - register: win_updates - until: not win_updates.failed - retries: 5 - delay: 300 +- name: Installing additional packages using Chocolatey + chocolatey.chocolatey.win_chocolatey: + name: "{{ item }}" + state: latest + loop: "{{ base_chocolatey_packages }}" From 5c4404f82b4337d00e79c1fc5005c2c9cdf187bc Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:22:12 -0500 Subject: [PATCH 10/13] fix: typo --- scripts/windows/windows-init.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/windows/windows-init.ps1 b/scripts/windows/windows-init.ps1 index e28786b..affda61 100644 --- a/scripts/windows/windows-init.ps1 +++ b/scripts/windows/windows-init.ps1 @@ -5,7 +5,7 @@ $ErrorActionPreference = 'Stop' -# Set network connections provile to Private mode. +# Set network connections profile to Private mode. Write-Output 'Setting the network connection profiles to Private...' $connectionProfile = Get-NetConnectionProfile While ($connectionProfile.Name -eq 'Identifying...') { From dfde775e37b4a982ab3757d04f90d23f68a3c7a4 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:58:10 -0500 Subject: [PATCH 11/13] feat: make build user more generic --- builds/build.pkrvars.hcl.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builds/build.pkrvars.hcl.example b/builds/build.pkrvars.hcl.example index 6e6e576..3da11c8 100644 --- a/builds/build.pkrvars.hcl.example +++ b/builds/build.pkrvars.hcl.example @@ -6,7 +6,7 @@ */ // Default Account Credentials -build_username = "ubuntu" -build_password = "ubuntu" -build_password_encrypted = "$6$Gg0b6uacy6apqKTP$OIvG1n8YUNpiDpsQgS02PgGgGY0egsYM0lqQq1lvOLKCAhMQcrY6SXq2K6ynt6RI8GVvmiagbKkcN6YXRzQtb1" +build_username = "deploy" +build_password = "deploy" +build_password_encrypted = "$6$MsfTs/5vjdnlgqEt$pkl1uGs645Y1NLpzQu7R/coOohkyzksn2YkY2EgjOuXkA6Tnrr3Yag8LYeotfYaiiyIzn3MyYCWdeqM.2VKAz1" build_key = "Your public SSH key goes here" From 4287339d6bfd7e463d36d9db9278003c70d24c4f Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:15:12 -0500 Subject: [PATCH 12/13] doc: updated README --- README.md | 92 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 2c9b4fd..0e995fe 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,20 @@ The following builds are available: | :--- | :--- | :---: | :---: | :---: | :---: | | AlmaLinux | 9 | ✓ | ✓ | ✓ | | | AlmaLinux | 8 | ✓ | ✓ | ✓ | | -| CentOS Stream | 9 | ✓ | ✓ | | | -| Debian | 12 | ✓ | | | | -| Debian | 11 | ✓ | | | | -| Oracle Linux | 9 | ✓ | | | | -| Oracle Linux | 8 | ✓ | | | | -| Rocky Linux | 9 | ✓ | | | | -| Rocky Linux | 8 | ✓ | | | | -| OpenSUSE Leap | 15.6 | ✓ | | | | -| OpenSUSE Leap | 15.5 | ✓ | | | | -| Ubuntu Server | 24.04 LTS | ✓ | | | | -| Ubuntu Server | 22.04 LTS | ✓ | | | | +| CentOS Stream | 10 | ✓ | ✓ | ✓ | ✓ | +| CentOS Stream | 9 | ✓ | ✓ | ✓ | ✓ | +| Debian | 12 | ✓ | ✓ | ✓ | ✓ | +| Debian | 11 | ✓ | ✓ | ✓ | ✓ | +| OpenSUSE Leap | 15.6 | ✓ | ✓ | ✓ | ✓ | +| OpenSUSE Leap | 15.5 | ✓ | ✓ | ✓ | ✓ | +| Oracle Linux | 9 | ✓ | ✓ | ✓ | ✓ | +| Oracle Linux | 8 | ✓ | ✓ | ✓ | ✓ | +| Rocky Linux | 9 | ✓ | ✓ | ✓ | ✓ | +| Rocky Linux | 8 | ✓ | ✓ | ✓ | ✓ | +| Ubuntu Server | 24.04 LTS | ✓ | ✓ | ✓ | ✓ | +| Ubuntu Server | 22.04 LTS | ✓ | ✓ | ✓ | ✓ | | Ubuntu Server | 20.04 LTS | ✓ | ✓ | ✓ | ✓ | +| Windows Desktop | 11 | | | ✓ | N/A | ## Requirements @@ -52,7 +54,7 @@ Operating systems and versions tested with the project: **Packer**: -- HashiCorp [Packer][packer-install] 1.11.0 or higher. +- HashiCorp [Packer][packer-install] 1.12.0 or higher. > **Note** > @@ -121,12 +123,12 @@ Operating systems and versions tested with the project: > > Required plugins are automatically downloaded and initialized when using `./build.sh`. For dark sites, you may download the plugins and place these same directory as your Packer executable `/usr/local/bin` or `$HOME/.packer.d/plugins`. - - HashiCorp [Packer Plugin for Proxmox][packer-plugin-proxmox] 1.1.8 or later. - [Packer Plugin for Git][packer-plugin-git] 0.6.2 or later - a community plugin for HashiCorp Packer. + - HashiCorp [Packer Plugin for Proxmox-ISO][packer-plugin-proxmox] version 1.2.1 - the plugin for HashiCorp Packer to communicate with Proxmox VE. This needs to be pinned to version 1.2.1 at this time due to a [CPU bug](https://github.com/hashicorp/packer-plugin-proxmox/issues/307). **Ansible**: -- [Ansible][ansible] [Core][ansible-core] version 2.10 or higher. +- [Ansible][ansible] [Core][ansible-core] version 2.14 or higher. > **Note** > @@ -165,12 +167,12 @@ Operating systems and versions tested with the project: -
CentOS Stream 9 - It is recommended that you install ansible-core using your system's package manager instead of via pip. + It is recommended that you install ansible using your system's package manager instead of via pip. Install. ```shell - dnf -y install ansible-core + dnf -y install ansible ```
@@ -263,7 +265,7 @@ You will need to generate a SHA-512 encrypted password for the `build_password_e Run the following command to generate a SHA-512 encrypted password: ```shell -mkpasswd -m sha512 +mkpasswd -m sha512crypt ``` The following output is displayed: @@ -315,12 +317,13 @@ Edit the `config/common.pkrvars.hcl` file to configure the following common vari common_iso_storage = "" // Boot and Provisioning Settings -common_data_source = "http" -common_http_ip = null -common_http_port_min = 8000 -common_http_port_max = 8099 -common_ip_wait_timeout = "20m" -common_shutdown_timeout = "15m" +common_data_source = "http" +common_http_interface = null +common_http_bind_address = null +common_http_port_min = 8000 +common_http_port_max = 8099 +common_ip_wait_timeout = "20m" +common_shutdown_timeout = "15m" // HCP Packer common_hcp_packer_registry_enabled = false @@ -359,21 +362,42 @@ common_data_source = "disk" The Packer plugin's `cd_content` option is used when selecting `disk` unless the distribution does not support a secondary CD-ROM. -#### HTTP Binding +#### HTTP Interface -If you need to define a specific IPv4 address from your host for Packer's built-in HTTP server, modify the `common_http_ip` variable from `null` to a `string` value that matches an IP address on your Packer host. +Name of the network interface that Packer gets `HTTPIP` from. Defaults to the first non loopback interface. ```hcl title="config/common.pkrvars.hcl" -common_http_ip = "172.16.11.254" +common_http_interface = "eth2" +``` + +#### HTTP Bind Address + +IP address on the build server to bind the Packer HTTP instance to. Must be an interface that is reachable from the Proxmox server. +```hcl title="config/common.pkrvars.hcl" +common_http_bind_address = 172.16.15.97" ``` ### Network Variables -Configuring a static IP address under the `configs/network.pkrvars.hcl` file is supported. If you want to use DHCP for the templates then leave these variables commented out. The default is DHCP. - Edit the `config/network.pkrvars.hcl` file to configure the following: -- Static IP address settings +#### Proxmox Specific Network Variables for VM Templates +These variables are used by Packer to configure the network interface for the VM template. These are specific to your environment. For example, to use the default `vmbr0` interface and the tag for VLAN 102, you would set it as follows: + +```hcl title="config/network.pkrvars.hcl" +// Proxmox settings for VM templates +vm_bridge_interface = "vmbr0" +vm_vlan_tag = "102" +``` + +Configuring a static IP address under the `configs/network.pkrvars.hcl` file is supported. If you want to use DHCP for the templates then leave these variables commented out. The default is DHCP. + +> **Note** +> +> - These settings are site specific for each Proxmox host and are going to be needed regardless if you use DHCP or static IP addresses. + +#### Static IP address settings +The Packer build templates default to using DHCP, however, you can use static IP addressing for your VM templates. Simply uncomment the following vars and configure to your specific requirements: ```hcl title="config/network.pkrvars.hcl" vm_ip_address = "192.168.101.100" @@ -382,6 +406,10 @@ vm_ip_gateway = "192.168.101.1" vm_dns_list = [ "8.8.8.8", "8.8.4.4" ] ``` +> **Note** +> +> - If you need/want to go back to using DHCP, just comment these variables out again and the templates should go back to using DHCP. + ### Proxmox Variables Edit the `config/proxmox.pkrvars.hcl` file to configure the following: @@ -390,13 +418,13 @@ Edit the `config/proxmox.pkrvars.hcl` file to configure the following: ```hcl title="config/proxmox.pkrvars.hcl" // Proxmox Credentials -proxmox_api_url = "" proxmox_api_token_id = "name@realm!token" proxmox_api_token_secret = "" proxmox_insecure_connection = false -// Proxmox Settings -proxmox_node = "" +// Proxmox Specific Settings +proxmox_hostname = "" +proxmox_node = "" ``` The `proxmox_api_token_id` variable uses a specific format and, as the time of this writing, needs to be assigned to the `PVEAdmin` role. One of the to-do's is to document a least-privilege method of creating the Proxmox API token. From 496ad532291f4e9d3a557eebc3229d9046f8aed0 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:27:26 -0500 Subject: [PATCH 13/13] feat: rename auto vars files to support build_vars feature --- ...linux.auto.pkrvars.hcl => linux-almalinux.pkrvars.hcl.example} | 0 ...linux.auto.pkrvars.hcl => linux-almalinux.pkrvars.hcl.example} | 0 ...m.auto.pkrvars.hcl => linux-centos-stream.pkrvars.hcl.example} | 0 ...m.auto.pkrvars.hcl => linux-centos-stream.pkrvars.hcl.example} | 0 ...x-debian.auto.pkrvars.hcl => linux-debian.pkrvars.hcl.example} | 0 ...x-debian.auto.pkrvars.hcl => linux-debian.pkrvars.hcl.example} | 0 ...p.auto.pkrvars.hcl => linux-opensuse-leap.pkrvars.hcl.example} | 0 ...p.auto.pkrvars.hcl => linux-opensuse-leap.pkrvars.hcl.example} | 0 ...x-oracle.auto.pkrvars.hcl => linux-oracle.pkrvars.hcl.example} | 0 ...x-oracle.auto.pkrvars.hcl => linux-oracle.pkrvars.hcl.example} | 0 ...nux-rocky.auto.pkrvars.hcl => linux-rocky.pkrvars.hcl.example} | 0 ...nux-rocky.auto.pkrvars.hcl => linux-rocky.pkrvars.hcl.example} | 0 ...x-ubuntu.auto.pkrvars.hcl => linux-ubuntu.pkrvars.hcl.example} | 0 ...x-ubuntu.auto.pkrvars.hcl => linux-ubuntu.pkrvars.hcl.example} | 0 ...x-ubuntu.auto.pkrvars.hcl => linux-ubuntu.pkrvars.hcl.example} | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename builds/linux/almalinux/8/{linux-almalinux.auto.pkrvars.hcl => linux-almalinux.pkrvars.hcl.example} (100%) rename builds/linux/almalinux/9/{linux-almalinux.auto.pkrvars.hcl => linux-almalinux.pkrvars.hcl.example} (100%) rename builds/linux/centos/10-stream/{linux-centos-stream.auto.pkrvars.hcl => linux-centos-stream.pkrvars.hcl.example} (100%) rename builds/linux/centos/9-stream/{linux-centos-stream.auto.pkrvars.hcl => linux-centos-stream.pkrvars.hcl.example} (100%) rename builds/linux/debian/11/{linux-debian.auto.pkrvars.hcl => linux-debian.pkrvars.hcl.example} (100%) rename builds/linux/debian/12/{linux-debian.auto.pkrvars.hcl => linux-debian.pkrvars.hcl.example} (100%) rename builds/linux/opensuse/leap-15-5/{linux-opensuse-leap.auto.pkrvars.hcl => linux-opensuse-leap.pkrvars.hcl.example} (100%) rename builds/linux/opensuse/leap-15-6/{linux-opensuse-leap.auto.pkrvars.hcl => linux-opensuse-leap.pkrvars.hcl.example} (100%) rename builds/linux/oracle/8/{linux-oracle.auto.pkrvars.hcl => linux-oracle.pkrvars.hcl.example} (100%) rename builds/linux/oracle/9/{linux-oracle.auto.pkrvars.hcl => linux-oracle.pkrvars.hcl.example} (100%) rename builds/linux/rocky/8/{linux-rocky.auto.pkrvars.hcl => linux-rocky.pkrvars.hcl.example} (100%) rename builds/linux/rocky/9/{linux-rocky.auto.pkrvars.hcl => linux-rocky.pkrvars.hcl.example} (100%) rename builds/linux/ubuntu/20-04-lts/{linux-ubuntu.auto.pkrvars.hcl => linux-ubuntu.pkrvars.hcl.example} (100%) rename builds/linux/ubuntu/22-04-lts/{linux-ubuntu.auto.pkrvars.hcl => linux-ubuntu.pkrvars.hcl.example} (100%) rename builds/linux/ubuntu/24-04-lts/{linux-ubuntu.auto.pkrvars.hcl => linux-ubuntu.pkrvars.hcl.example} (100%) diff --git a/builds/linux/almalinux/8/linux-almalinux.auto.pkrvars.hcl b/builds/linux/almalinux/8/linux-almalinux.pkrvars.hcl.example similarity index 100% rename from builds/linux/almalinux/8/linux-almalinux.auto.pkrvars.hcl rename to builds/linux/almalinux/8/linux-almalinux.pkrvars.hcl.example diff --git a/builds/linux/almalinux/9/linux-almalinux.auto.pkrvars.hcl b/builds/linux/almalinux/9/linux-almalinux.pkrvars.hcl.example similarity index 100% rename from builds/linux/almalinux/9/linux-almalinux.auto.pkrvars.hcl rename to builds/linux/almalinux/9/linux-almalinux.pkrvars.hcl.example diff --git a/builds/linux/centos/10-stream/linux-centos-stream.auto.pkrvars.hcl b/builds/linux/centos/10-stream/linux-centos-stream.pkrvars.hcl.example similarity index 100% rename from builds/linux/centos/10-stream/linux-centos-stream.auto.pkrvars.hcl rename to builds/linux/centos/10-stream/linux-centos-stream.pkrvars.hcl.example diff --git a/builds/linux/centos/9-stream/linux-centos-stream.auto.pkrvars.hcl b/builds/linux/centos/9-stream/linux-centos-stream.pkrvars.hcl.example similarity index 100% rename from builds/linux/centos/9-stream/linux-centos-stream.auto.pkrvars.hcl rename to builds/linux/centos/9-stream/linux-centos-stream.pkrvars.hcl.example diff --git a/builds/linux/debian/11/linux-debian.auto.pkrvars.hcl b/builds/linux/debian/11/linux-debian.pkrvars.hcl.example similarity index 100% rename from builds/linux/debian/11/linux-debian.auto.pkrvars.hcl rename to builds/linux/debian/11/linux-debian.pkrvars.hcl.example diff --git a/builds/linux/debian/12/linux-debian.auto.pkrvars.hcl b/builds/linux/debian/12/linux-debian.pkrvars.hcl.example similarity index 100% rename from builds/linux/debian/12/linux-debian.auto.pkrvars.hcl rename to builds/linux/debian/12/linux-debian.pkrvars.hcl.example diff --git a/builds/linux/opensuse/leap-15-5/linux-opensuse-leap.auto.pkrvars.hcl b/builds/linux/opensuse/leap-15-5/linux-opensuse-leap.pkrvars.hcl.example similarity index 100% rename from builds/linux/opensuse/leap-15-5/linux-opensuse-leap.auto.pkrvars.hcl rename to builds/linux/opensuse/leap-15-5/linux-opensuse-leap.pkrvars.hcl.example diff --git a/builds/linux/opensuse/leap-15-6/linux-opensuse-leap.auto.pkrvars.hcl b/builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkrvars.hcl.example similarity index 100% rename from builds/linux/opensuse/leap-15-6/linux-opensuse-leap.auto.pkrvars.hcl rename to builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkrvars.hcl.example diff --git a/builds/linux/oracle/8/linux-oracle.auto.pkrvars.hcl b/builds/linux/oracle/8/linux-oracle.pkrvars.hcl.example similarity index 100% rename from builds/linux/oracle/8/linux-oracle.auto.pkrvars.hcl rename to builds/linux/oracle/8/linux-oracle.pkrvars.hcl.example diff --git a/builds/linux/oracle/9/linux-oracle.auto.pkrvars.hcl b/builds/linux/oracle/9/linux-oracle.pkrvars.hcl.example similarity index 100% rename from builds/linux/oracle/9/linux-oracle.auto.pkrvars.hcl rename to builds/linux/oracle/9/linux-oracle.pkrvars.hcl.example diff --git a/builds/linux/rocky/8/linux-rocky.auto.pkrvars.hcl b/builds/linux/rocky/8/linux-rocky.pkrvars.hcl.example similarity index 100% rename from builds/linux/rocky/8/linux-rocky.auto.pkrvars.hcl rename to builds/linux/rocky/8/linux-rocky.pkrvars.hcl.example diff --git a/builds/linux/rocky/9/linux-rocky.auto.pkrvars.hcl b/builds/linux/rocky/9/linux-rocky.pkrvars.hcl.example similarity index 100% rename from builds/linux/rocky/9/linux-rocky.auto.pkrvars.hcl rename to builds/linux/rocky/9/linux-rocky.pkrvars.hcl.example diff --git a/builds/linux/ubuntu/20-04-lts/linux-ubuntu.auto.pkrvars.hcl b/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkrvars.hcl.example similarity index 100% rename from builds/linux/ubuntu/20-04-lts/linux-ubuntu.auto.pkrvars.hcl rename to builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkrvars.hcl.example diff --git a/builds/linux/ubuntu/22-04-lts/linux-ubuntu.auto.pkrvars.hcl b/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkrvars.hcl.example similarity index 100% rename from builds/linux/ubuntu/22-04-lts/linux-ubuntu.auto.pkrvars.hcl rename to builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkrvars.hcl.example diff --git a/builds/linux/ubuntu/24-04-lts/linux-ubuntu.auto.pkrvars.hcl b/builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkrvars.hcl.example similarity index 100% rename from builds/linux/ubuntu/24-04-lts/linux-ubuntu.auto.pkrvars.hcl rename to builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkrvars.hcl.example