From a8af568abfbeaddd7af8f37e34db8da2059e0ac8 Mon Sep 17 00:00:00 2001 From: jonadis Date: Tue, 19 Nov 2024 16:02:36 -0500 Subject: [PATCH 01/22] Add proxmox_hostname variable to proxmox.pkrvars.hcl.example --- builds/proxmox.pkrvars.hcl.example | 1 + 1 file changed, 1 insertion(+) diff --git a/builds/proxmox.pkrvars.hcl.example b/builds/proxmox.pkrvars.hcl.example index 6b2653e..16a26e9 100644 --- a/builds/proxmox.pkrvars.hcl.example +++ b/builds/proxmox.pkrvars.hcl.example @@ -12,3 +12,4 @@ proxmox_insecure_connection = false // Proxmox Settings proxmox_node = "" +proxmox_hostname = "" From c6dbdc37b8d496e928e7ed77eb9ccafa94bb16ce Mon Sep 17 00:00:00 2001 From: ajschroeder Date: Mon, 9 Dec 2024 22:35:44 +0000 Subject: [PATCH 02/22] feat: add devcontiner support --- .devcontainer/Dockerfile | 28 ++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 16 ++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..058e467 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,28 @@ +# Use the base Ubuntu devcontainer image. +FROM mcr.microsoft.com/devcontainers/base:ubuntu + +# Install additional packages. +RUN apt-get update && \ + apt-get install -y curl software-properties-common ca-certificates + +RUN update-ca-certificates + +# Install Packer +RUN sudo mkdir -m 0755 -p /etc/apt/keyrings/ && \ + curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/hashicorp-packer.gpg && \ + sudo echo "deb [arch=amd64, signed-by=/etc/apt/keyrings/hashicorp-packer.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp-packer.list > /dev/null && \ + sudo chmod 0644 /etc/apt/keyrings/hashicorp-packer.gpg && \ + sudo apt-get update && sudo apt-get install packer + +# Install Python3 and Ansible. +RUN add-apt-repository --yes --update ppa:ansible/ansible && \ + apt-get update && \ + apt-get install -y python3 python3-pip ansible + +# Cleanup. +RUN apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set PATH +ENV PATH="$HOME/.local/bin:$PATH" \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..3e8f311 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "Packer Examples for Proxmox", + "build": { + "dockerfile": "Dockerfile" + }, + "features": {}, + "customizations": { + "vscode": { + "extensions": [ + "GitHub.vscode-pull-request-github", + "hashicorp.hcl", + "redhat.ansible" + ] + } + } +} \ No newline at end of file From 6c313c97d95c6133f9b4fbbd8a7e59fa0cb0eef6 Mon Sep 17 00:00:00 2001 From: ajschroeder Date: Mon, 9 Dec 2024 22:36:07 +0000 Subject: [PATCH 03/22] feat: add vscode defaults --- .vscode/extensions.json | 7 +++++++ .vscode/settings.json | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..9dccc2a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "hashicorp.hcl", // HCL + "redhat.ansible", // Ansible + "vscode.json-language-features" // JSON + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..629451a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,27 @@ +{ + // Ansible settings + "ansible.python.interpreterPath": "/usr/bin/python3", + // Editor settings + "editor.bracketPairColorization.enabled": true, + "editor.bracketPairColorization.independentColorPoolPerBracketType": true, + "editor.formatOnSaveMode": "modificationsIfAvailable", + "editor.guides.bracketPairs": true, + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true, + // File watcher settings + "files.watcherExclude": { + "**/.DS_Store": true, + "**/.site/**": true, + "**/.trunk/**": true + }, + // Extension settings + "extensions.ignoreRecommendations": false, + // Language-specific settings + "[json]": { + "editor.defaultFormatter": "vscode.json-language-features", + "editor.formatOnPaste": true, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "editor.trimAutoWhitespace": true + }, +} \ No newline at end of file From dbc24c668893ea3ff6da2fd90ec9383e4d8881bb Mon Sep 17 00:00:00 2001 From: ajschroeder <6432150+ajschroeder@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:39:52 +0000 Subject: [PATCH 04/22] test: add network template tests --- tests/.gitignore | 1 + tests/network/golden/dhcp-autoinstall | 6 ++ tests/network/golden/dhcp-kickstart | 1 + tests/network/golden/dhcp-preseed | 1 + tests/network/golden/static-autoinstall | 13 +++++ tests/network/golden/static-kickstart | 1 + tests/network/golden/static-preseed | 7 +++ tests/network/templates/autoinstall.pkrtpl | 19 ++++++ tests/network/templates/kickstart.pkrtpl | 5 ++ tests/network/templates/preseed.pkrtpl | 9 +++ tests/network/test | 68 ++++++++++++++++++++++ tests/network/test-dhcp.pkrvars.hcl | 1 + tests/network/test-static.pkrvars.hcl | 4 ++ tests/network/test.pkr.hcl | 57 ++++++++++++++++++ tests/network/variables.pkr.hcl | 34 +++++++++++ 15 files changed, 227 insertions(+) create mode 100644 tests/.gitignore create mode 100644 tests/network/golden/dhcp-autoinstall create mode 100644 tests/network/golden/dhcp-kickstart create mode 100644 tests/network/golden/dhcp-preseed create mode 100644 tests/network/golden/static-autoinstall create mode 100644 tests/network/golden/static-kickstart create mode 100644 tests/network/golden/static-preseed create mode 100644 tests/network/templates/autoinstall.pkrtpl create mode 100644 tests/network/templates/kickstart.pkrtpl create mode 100644 tests/network/templates/preseed.pkrtpl create mode 100644 tests/network/test create mode 100644 tests/network/test-dhcp.pkrvars.hcl create mode 100644 tests/network/test-static.pkrvars.hcl create mode 100644 tests/network/test.pkr.hcl create mode 100644 tests/network/variables.pkr.hcl diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..6caf68a --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +output \ No newline at end of file diff --git a/tests/network/golden/dhcp-autoinstall b/tests/network/golden/dhcp-autoinstall new file mode 100644 index 0000000..f93d2cc --- /dev/null +++ b/tests/network/golden/dhcp-autoinstall @@ -0,0 +1,6 @@ + network: + network: + version: 2 + ethernets: + eth0: + dhcp4: true diff --git a/tests/network/golden/dhcp-kickstart b/tests/network/golden/dhcp-kickstart new file mode 100644 index 0000000..24f4ec3 --- /dev/null +++ b/tests/network/golden/dhcp-kickstart @@ -0,0 +1 @@ +network --device=eth0 --bootproto=dhcp diff --git a/tests/network/golden/dhcp-preseed b/tests/network/golden/dhcp-preseed new file mode 100644 index 0000000..9cbaebb --- /dev/null +++ b/tests/network/golden/dhcp-preseed @@ -0,0 +1 @@ +d-i netcfg/choose_interface select eth0 diff --git a/tests/network/golden/static-autoinstall b/tests/network/golden/static-autoinstall new file mode 100644 index 0000000..a3629b1 --- /dev/null +++ b/tests/network/golden/static-autoinstall @@ -0,0 +1,13 @@ + network: + network: + version: 2 + ethernets: + eth0: + dhcp4: false + addresses: + - 192.168.100.192/24 + gateway4: 192.168.100.1 + nameservers: + addresses: + - 192.168.100.3 + - 192.168.100.1 diff --git a/tests/network/golden/static-kickstart b/tests/network/golden/static-kickstart new file mode 100644 index 0000000..91f984f --- /dev/null +++ b/tests/network/golden/static-kickstart @@ -0,0 +1 @@ +network --device=eth0 --bootproto=static --ip=192.168.100.192 --netmask=255.255.255.0 --gateway=192.168.100.1 --nameserver=192.168.100.3,192.168.100.1 diff --git a/tests/network/golden/static-preseed b/tests/network/golden/static-preseed new file mode 100644 index 0000000..b7c207e --- /dev/null +++ b/tests/network/golden/static-preseed @@ -0,0 +1,7 @@ +d-i netcfg/choose_interface select eth0 +d-i netcfg/disable_autoconfig boolean true +d-i netcfg/get_ipaddress string 192.168.100.192 +d-i netcfg/get_netmask string 255.255.255.0 +d-i netcfg/get_gateway string 192.168.100.1 +d-i netcfg/get_nameservers string 192.168.100.3 192.168.100.1 +d-i netcfg/confirm_static boolean true diff --git a/tests/network/templates/autoinstall.pkrtpl b/tests/network/templates/autoinstall.pkrtpl new file mode 100644 index 0000000..c4ab4c0 --- /dev/null +++ b/tests/network/templates/autoinstall.pkrtpl @@ -0,0 +1,19 @@ + network: + network: + version: 2 + ethernets: +%{ if ip != null ~} + ${device}: + dhcp4: false + addresses: + - ${ip}/${netmask} + gateway4: ${gateway} + nameservers: + addresses: +%{ for item in dns ~} + - ${item} +%{ endfor ~} +%{ else ~} + ${device}: + dhcp4: true +%{ endif ~} \ No newline at end of file diff --git a/tests/network/templates/kickstart.pkrtpl b/tests/network/templates/kickstart.pkrtpl new file mode 100644 index 0000000..a813431 --- /dev/null +++ b/tests/network/templates/kickstart.pkrtpl @@ -0,0 +1,5 @@ +%{~ if ip != null ~} +network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)} +%{~ else ~} +network --device=${device} --bootproto=dhcp +%{~ endif ~} diff --git a/tests/network/templates/preseed.pkrtpl b/tests/network/templates/preseed.pkrtpl new file mode 100644 index 0000000..159bea2 --- /dev/null +++ b/tests/network/templates/preseed.pkrtpl @@ -0,0 +1,9 @@ +d-i netcfg/choose_interface select ${device} +%{ if ip != null ~} +d-i netcfg/disable_autoconfig boolean true +d-i netcfg/get_ipaddress string ${ip} +d-i netcfg/get_netmask string ${cidrnetmask("${ip}/${netmask}")} +d-i netcfg/get_gateway string ${gateway} +d-i netcfg/get_nameservers string ${join(" ", dns)} +d-i netcfg/confirm_static boolean true +%{ endif ~} diff --git a/tests/network/test b/tests/network/test new file mode 100644 index 0000000..9281511 --- /dev/null +++ b/tests/network/test @@ -0,0 +1,68 @@ +#!/usr/bin/env bats + +setup() { + DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" + echo "$DIR" + packer init -upgrade "$DIR" +} + +teardown() { + rm -f /tmp/tmpfile +} + +clean_blank_lines() { + # Remove any blank lines that HCL likes to leave around + awk 'NF' "$1" > /tmp/tmpfile && cat /tmp/tmpfile > "$1" +} + +## Test DHCP +############################################################################### +@test "network with Autoinstall using DHCP" { + mkdir -p "$DIR/output/dhcp" + packer build -var-file="$DIR/test-dhcp.pkrvars.hcl" -var "output_folder=$DIR/output/dhcp" -only "autoinstall.*" "$DIR" + run clean_blank_lines "$DIR/output/dhcp/autoinstall" + run diff -u "$DIR/output/dhcp/autoinstall" "$DIR/golden/dhcp-autoinstall" + [ "$status" -eq 0 ] +} + +@test "network with Kickstart using DHCP" { + mkdir -p "$DIR/output/dhcp" + packer build -var-file="$DIR/test-dhcp.pkrvars.hcl" -var "output_folder=$DIR/output/dhcp" -only "kickstart.*" "$DIR" + run clean_blank_lines "$DIR/output/dhcp/kickstart" + run diff -u "$DIR/output/dhcp/kickstart" "$DIR/golden/dhcp-kickstart" + [ "$status" -eq 0 ] +} + +@test "network with Preseed using DHCP" { + mkdir -p "$DIR/output/dhcp" + packer build -var-file="$DIR/test-dhcp.pkrvars.hcl" -var "output_folder=$DIR/output/dhcp" -only "preseed.*" "$DIR" + run clean_blank_lines "$DIR/output/dhcp/preseed" + run diff -u "$DIR/output/dhcp/preseed" "$DIR/golden/dhcp-preseed" + [ "$status" -eq 0 ] +} + +## Test static IP +############################################################################### +@test "network with Autoinstall using static IP" { + mkdir -p "$DIR/output/static" + packer build -var-file="$DIR/test-static.pkrvars.hcl" -var "output_folder=$DIR/output/static" -only "autoinstall.*" "$DIR" + run clean_blank_lines "$DIR/output/static/autoinstall" + run diff -u "$DIR/output/static/autoinstall" "$DIR/golden/static-autoinstall" + [ "$status" -eq 0 ] +} + +@test "network with Kickstart using static IP" { + mkdir -p "$DIR/output/static" + packer build -var-file="$DIR/test-static.pkrvars.hcl" -var "output_folder=$DIR/output/static" -only "kickstart.*" "$DIR" + run clean_blank_lines "$DIR/output/static/kickstart" + run diff -u "$DIR/output/static/kickstart" "$DIR/golden/static-kickstart" + [ "$status" -eq 0 ] +} + +@test "network with Preseed using static IP" { + mkdir -p "$DIR/output/static" + packer build -var-file="$DIR/test-static.pkrvars.hcl" -var "output_folder=$DIR/output/static" -only "preseed.*" "$DIR" + run clean_blank_lines "$DIR/output/static/preseed" + run diff -u "$DIR/output/static/preseed" "$DIR/golden/static-preseed" + [ "$status" -eq 0 ] +} diff --git a/tests/network/test-dhcp.pkrvars.hcl b/tests/network/test-dhcp.pkrvars.hcl new file mode 100644 index 0000000..9864fd8 --- /dev/null +++ b/tests/network/test-dhcp.pkrvars.hcl @@ -0,0 +1 @@ +// Nothing to set for DHCP \ No newline at end of file diff --git a/tests/network/test-static.pkrvars.hcl b/tests/network/test-static.pkrvars.hcl new file mode 100644 index 0000000..8b210fe --- /dev/null +++ b/tests/network/test-static.pkrvars.hcl @@ -0,0 +1,4 @@ +vm_ip_address = "192.168.100.192" +vm_ip_netmask = 24 +vm_ip_gateway = "192.168.100.1" +vm_dns_list = ["192.168.100.3", "192.168.100.1"] \ No newline at end of file diff --git a/tests/network/test.pkr.hcl b/tests/network/test.pkr.hcl new file mode 100644 index 0000000..1efe062 --- /dev/null +++ b/tests/network/test.pkr.hcl @@ -0,0 +1,57 @@ +source "null" "test" { + communicator = "none" +} + +locals { + autoinstall = templatefile("${abspath(path.root)}/templates/autoinstall.pkrtpl", { + device = var.vm_network_device, + ip = var.vm_ip_address, + netmask = var.vm_ip_netmask, + gateway = var.vm_ip_gateway, + dns = var.vm_dns_list, + }) + kickstart = templatefile("${abspath(path.root)}/templates/kickstart.pkrtpl", { + device = var.vm_network_device, + ip = var.vm_ip_address, + netmask = var.vm_ip_netmask, + gateway = var.vm_ip_gateway, + dns = var.vm_dns_list, + }) + preseed = templatefile("${abspath(path.root)}/templates/preseed.pkrtpl", { + device = var.vm_network_device, + ip = var.vm_ip_address, + netmask = var.vm_ip_netmask, + gateway = var.vm_ip_gateway, + dns = var.vm_dns_list, + }) +} + +build { + name = "autoinstall" + sources = ["source.null.test"] + provisioner "shell-local" { + inline = [ + "echo '${local.autoinstall}' > ${var.output_folder}/autoinstall", + ] + } +} + +build { + name = "kickstart" + sources = ["source.null.test"] + provisioner "shell-local" { + inline = [ + "echo '${local.kickstart}' > ${var.output_folder}/kickstart", + ] + } +} + +build { + name = "preseed" + sources = ["source.null.test"] + provisioner "shell-local" { + inline = [ + "echo '${local.preseed}' > ${var.output_folder}/preseed", + ] + } +} \ No newline at end of file diff --git a/tests/network/variables.pkr.hcl b/tests/network/variables.pkr.hcl new file mode 100644 index 0000000..2f58e94 --- /dev/null +++ b/tests/network/variables.pkr.hcl @@ -0,0 +1,34 @@ +variable "vm_network_device" { + type = string + description = "The network device of the VM." + default = "eth0" +} + +variable "vm_ip_address" { + type = string + description = "The IP address of the VM (e.g. 172.16.100.192)." + default = null +} + +variable "vm_ip_netmask" { + type = number + description = "The netmask of the VM (e.g. 24)." + default = null +} + +variable "vm_ip_gateway" { + type = string + description = "The gateway of the VM (e.g. 172.16.100.1)." + default = null +} + +variable "vm_dns_list" { + type = list(string) + description = "The nameservers of the VM." + default = [] +} + +variable "output_folder" { + type = string + description = "The output folder for the generated files." +} \ No newline at end of file From 9f1ff435ae8897222785ca57616fc6278f2191e9 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Thu, 20 Feb 2025 23:29:38 -0600 Subject: [PATCH 05/22] feat: add windows 11 build --- ansible/roles/base/tasks/main.yml | 4 +- ansible/roles/base/tasks/windows.yml | 51 +++ ansible/roles/configure/tasks/main.yml | 4 +- ansible/roles/configure/tasks/windows.yml | 133 ++++++ ansible/windows-playbook.yml | 8 + ansible/windows-requirements.yml | 8 + builds/proxy.pkrvars.hcl.example | 11 + .../desktop/11/data/autounattend.pkrtpl.hcl | 220 ++++++++++ builds/windows/desktop/11/variables.pkr.hcl | 413 ++++++++++++++++++ .../desktop/11/windows.auto.pkrvars.hcl | 43 ++ builds/windows/desktop/11/windows.pkr.hcl | 317 ++++++++++++++ .../desktop/11/windows.pkrvars.hcl.example | 20 + scripts/windows/windows-init.ps1 | 30 ++ scripts/windows/windows-virtio.ps1 | 99 +++++ 14 files changed, 1359 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/base/tasks/windows.yml create mode 100644 ansible/roles/configure/tasks/windows.yml create mode 100644 ansible/windows-playbook.yml create mode 100644 ansible/windows-requirements.yml create mode 100644 builds/proxy.pkrvars.hcl.example create mode 100644 builds/windows/desktop/11/data/autounattend.pkrtpl.hcl create mode 100644 builds/windows/desktop/11/variables.pkr.hcl create mode 100644 builds/windows/desktop/11/windows.auto.pkrvars.hcl create mode 100644 builds/windows/desktop/11/windows.pkr.hcl create mode 100644 builds/windows/desktop/11/windows.pkrvars.hcl.example create mode 100644 scripts/windows/windows-init.ps1 create mode 100644 scripts/windows/windows-virtio.ps1 diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml index ba19a60..d486600 100644 --- a/ansible/roles/base/tasks/main.yml +++ b/ansible/roles/base/tasks/main.yml @@ -20,4 +20,6 @@ include_tasks: suse.yml when: "ansible_facts['distribution'] in ['openSUSE Leap', 'Suse']" -... \ No newline at end of file +- name: "{{ base_task_name }}" + ansible.builtin.include_tasks: windows.yml + when: ansible_os_family == "Windows" diff --git a/ansible/roles/base/tasks/windows.yml b/ansible/roles/base/tasks/windows.yml new file mode 100644 index 0000000..d4559dc --- /dev/null +++ b/ansible/roles/base/tasks/windows.yml @@ -0,0 +1,51 @@ +--- +# Microsoft Windows specific tasks. + +# Tasks for updating the operating system and installing additional packages. +- name: Getting guest operating system information + 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 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 diff --git a/ansible/roles/configure/tasks/main.yml b/ansible/roles/configure/tasks/main.yml index b295b54..dd5683e 100644 --- a/ansible/roles/configure/tasks/main.yml +++ b/ansible/roles/configure/tasks/main.yml @@ -16,4 +16,6 @@ include_tasks: suse.yml when: "ansible_facts['distribution'] in ['openSUSE Leap', 'Suse']" -... \ No newline at end of file +- name: "{{ configure_task_name }}" + ansible.builtin.include_tasks: windows.yml + when: ansible_os_family == "Windows" diff --git a/ansible/roles/configure/tasks/windows.yml b/ansible/roles/configure/tasks/windows.yml new file mode 100644 index 0000000..353f110 --- /dev/null +++ b/ansible/roles/configure/tasks/windows.yml @@ -0,0 +1,133 @@ +--- +# Microsoft Windows specific tasks. + +# Set the Windows Explorer options. +# ansible-lint: disable=line-length +- name: Setting the Windows Explorer options... + when: ansible_os_installation_type != "Server Core" + block: + - name: Show hidden files. + ansible.windows.win_regedit: + path: HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced + name: Hidden + data: 1 + type: dword + + - name: Show file extensions. + ansible.windows.win_regedit: + path: HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced + name: HideFileExt + data: 0 + type: dword + + - name: Show drives with no media. + ansible.windows.win_regedit: + path: HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced + name: HideDrivesWithNoMedia + data: 0 + type: dword + + - name: Disabling Sync Provider Notifications. + ansible.windows.win_regedit: + path: HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced + name: ShowSyncProviderNotifications + data: 1 + type: dword + +# Disable system hibernation. +- name: Disabling System Hibernation... + block: + - name: Disabling Hibernation. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\Power + name: HibernateEnabled + data: 0 + type: dword + + - name: Setting HiberFileSizePercent to 0. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\Power + name: HiberFileSizePercent + data: 0 + type: dword + +# Disable TLS 1.0.s +- name: Disabling TLS 1.0 for Client... + block: + - name: Disabling TLS 1.0 for Client. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client + name: Enabled + data: 0 + type: dword + + - name: Setting TLS 1.0 for Client to Disabled by Default. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client + name: DisabledByDefault + data: 1 + type: dword + + - name: Disabling TLS 1.0 for Server. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server + name: Enabled + data: 0 + type: dword + + - name: Setting TLS 1.0 for Server to Disabled by Default. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server + name: DisabledByDefault + data: 1 + type: dword + +# Disable TLS 1.1. +- name: Disabling TLS 1.1 for Client... + block: + - name: Disabling TLS 1.1 for Client. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client + name: Enabled + data: 0 + type: dword + + - name: Setting TLS 1.1 for Client to Disabled by Default. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client + name: DisabledByDefault + data: 1 + type: dword + + - name: Disabling TLS 1.1 for Server. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server + name: Enabled + data: 0 + type: dword + + - name: Setting TLS 1.1 for Server to Disabled by Default. + ansible.windows.win_regedit: + path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server + name: DisabledByDefault + data: 1 + type: dword + +# Disable Password Expiration for Administrator and Build Accounts +- name: Disabling Local Administrator Password Expiration... + ansible.windows.win_user: + name: Administrator + password_never_expires: true + +- name: Disabling Password Expiration for "{{ build_username }}" + ansible.windows.win_user: + name: "{{ build_username }}" + password_never_expires: true + +# Enable Remote Desktop. +- name: Enabling Remote Desktop... + ansible.windows.win_powershell: + script: | + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0 | Out-Null + Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0 + Enable-NetFirewallRule -Group '@FirewallAPI.dll,-28752' diff --git a/ansible/windows-playbook.yml b/ansible/windows-playbook.yml new file mode 100644 index 0000000..3cfb776 --- /dev/null +++ b/ansible/windows-playbook.yml @@ -0,0 +1,8 @@ +--- +- name: Playbook for Microsoft Windows + debugger: never + gather_facts: true + hosts: all + roles: + - base + - configure diff --git a/ansible/windows-requirements.yml b/ansible/windows-requirements.yml new file mode 100644 index 0000000..d6b35fd --- /dev/null +++ b/ansible/windows-requirements.yml @@ -0,0 +1,8 @@ +--- +collections: + - name: ansible.windows + version: 2.3.0 + - name: chocolatey.chocolatey + version: 1.5.1 + - name: community.general + version: 8.6.0 diff --git a/builds/proxy.pkrvars.hcl.example b/builds/proxy.pkrvars.hcl.example new file mode 100644 index 0000000..6765d05 --- /dev/null +++ b/builds/proxy.pkrvars.hcl.example @@ -0,0 +1,11 @@ +/* + DESCRIPTION: + Proxy variables used for Linux builds. (Optional) + - Variables are passed to and used by configuration scripts. +*/ + +// Proxy Credentials +// communicator_proxy_host = "proxy.example.com" +// communicator_proxy_port = 3128 +// communicator_proxy_username = "packer_proxy" +// communicator_proxy_password = "Sup3rdup3rSecr3t!" diff --git a/builds/windows/desktop/11/data/autounattend.pkrtpl.hcl b/builds/windows/desktop/11/data/autounattend.pkrtpl.hcl new file mode 100644 index 0000000..26a5260 --- /dev/null +++ b/builds/windows/desktop/11/data/autounattend.pkrtpl.hcl @@ -0,0 +1,220 @@ + + + + + + ${vm_inst_os_language} + + ${vm_inst_os_keyboard} + ${vm_inst_os_language} + ${vm_inst_os_language} + ${vm_inst_os_language} + ${vm_inst_os_language} + + + + + F:\viostor\w11\amd64\ + + + F:\NetKVM\w11\amd64\ + + + + + + + 0 + true + + + + 1 + Primary + 550 + + + + 2 + EFI + 100 + + + + 3 + MSR + 128 + + + + 4 + Primary + true + + + + + + 1 + 1 + + NTFS + DE94BBA4-06D1-4D40-A16A-BFD50179D6AC + + + + 2 + 2 + + FAT32 + + + + 3 + 3 + + + + 4 + 4 + + C + NTFS + + + + + + + + + /IMAGE/NAME + ${vm_inst_os_image} + + + + 0 + 4 + + + + + + 1 + + cmd /c powercfg.exe /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c + + + + true + ${build_username} + ${build_username} + %{if vm_inst_os_eval != true ~} + + ${vm_inst_os_key} + OnError + + %{ endif ~} + + false + + + + + false + + + + + 1 + + + + + + false + + ${vm_guest_os_timezone} + + + + true + + + true + + + true + + + + + ${vm_guest_os_keyboard} + ${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} + + + + + ${build_password} + true</PlainText> + </Password> + <Enabled>true</Enabled> + <Username>${build_username}</Username> + </AutoLogon> + <OOBE> + <HideEULAPage>true</HideEULAPage> + <HideLocalAccountScreen>true</HideLocalAccountScreen> + <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> + <HideOnlineAccountScreens>true</HideOnlineAccountScreens> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + <NetworkLocation>Work</NetworkLocation> + <ProtectYourPC>2</ProtectYourPC> + </OOBE> + <UserAccounts> + <AdministratorPassword> + <Value>${build_password}</Value> + <PlainText>true</PlainText> + </AdministratorPassword> + <LocalAccounts> + <LocalAccount wcm:action="add"> + <Password> + <Value>${build_password}</Value> + <PlainText>true</PlainText> + </Password> + <Group>administrators</Group> + <DisplayName>${build_username}</DisplayName> + <Name>${build_username}</Name> + <Description>Build Account</Description> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> + <Description>Set Execution Policy 64-Bit</Description> + <Order>1</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> + <Description>Set Execution Policy 32-Bit</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File E:\windows-virtio.ps1</CommandLine> + <Order>3</Order> + <Description>Install VMware Tools</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File E:\windows-init.ps1</CommandLine> + <Order>4</Order> + <Description>Initial Configuration</Description> + </SynchronousCommand> + </FirstLogonCommands> + </component> + </settings> +</unattend> diff --git a/builds/windows/desktop/11/variables.pkr.hcl b/builds/windows/desktop/11/variables.pkr.hcl new file mode 100644 index 0000000..8169e6d --- /dev/null +++ b/builds/windows/desktop/11/variables.pkr.hcl @@ -0,0 +1,413 @@ +/* + DESCRIPTION: + Microsoft Windows 11 input variables. + Packer Plugin for Proxmox: 'proxmox-iso' builder. +*/ + +// BLOCK: variable +// Defines the input variables. + +// Proxmox Credentials + +variable "proxmox_hostname" { + type = string + description = "The FQDN or IP address of a Proxmox node. Only one node should be specified in a cluster." +} + +variable "proxmox_api_token_id" { + type = string + description = "The token to login to the Proxmox node/cluster. The format is USER@REALM!TOKENID. (e.g. packer@pam!packer_pve_token)" +} + +variable "proxmox_api_token_secret" { + type = string + description = "The secret for the API token used to login to the Proxmox API." +# sensitive = true +} + +variable "proxmox_insecure_connection" { + description = "true/false to skip Proxmox TLS certificate checks." + type = bool + default = true +} + +// Proxmox Settings + +variable "proxmox_node" { + type = string + description = "The name of the Proxmox node that Packer will build templates on." +} + +// Installer Settings + +variable "vm_inst_os_language" { + type = string + description = "The installation operating system lanugage." + default = "en-US" +} + +variable "vm_inst_os_keyboard" { + type = string + description = "The installation operating system keyboard input." + default = "en-US" +} + +variable "vm_inst_os_eval" { + type = bool + description = "Build using the operating system evaluation" + default = true +} + +variable "vm_inst_os_image_pro" { + type = string + description = "The installation operating system image input.\nDoes not support evaluation." + default = "Windows 11 Pro" +} + +variable "vm_inst_os_image_ent" { + type = string + description = "The installation operating system image input. Does support evaluation." + default = "Windows 11 Enterprise" +} + +variable "vm_inst_os_key_pro" { + type = string + description = "The installation operating system key input." +} +variable "vm_inst_os_key_ent" { + type = string + description = "The installation operating system key input." +} + +// Virtual Machine Settings + +variable "vm_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en-US" +} + +variable "vm_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "en-US" +} + +variable "vm_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_os_family" { + type = string + description = "The guest operating system family. Used for naming. (e.g. 'linux')" + default = "windows" +} + +variable "vm_os_name" { + type = string + description = "The guest operating system name. Used for naming." + default = "desktop" +} + +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" { + type = string + description = "The guest operating system type, also know as guestid." +} + +variable "vm_bios" { + type = string + description = "The firmware type. Allowed values 'ovmf' or 'seabios'" + default = "ovmf" + validation { + condition = contains(["ovmf", "seabios"], var.vm_bios) + error_message = "The vm_bios value must be 'ovmf' or 'seabios'." + } +} + +variable "vm_firmware_path" { + type = string + description = "The firmware file to be used. Needed for EFI" + default = "/usr/share/ovmf/OVMF.fd" +} + +variable "vm_efi_storage_pool" { + type = string + description = "Set the UEFI disk storage location. (e.g. 'local')" + default = "local" +} + +variable "vm_efi_type" { + type = string + description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')" + default = "4m" +} + +variable "vm_efi_pre_enrolled_keys" { + type = bool + description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)" + default = false +} + +variable "vm_machine_type" { + type = string + description = "Set the machine type. Supported values are 'pc' or 'q35'." + default = "pc" + validation { + condition = contains(["pc", "q35"], var.vm_machine_type) + error_message = "The vm_machine_type value must be 'pc' or 'q35'." + } +} +variable "vm_cpu_count" { + type = number + description = "The number of virtual CPUs." + default = 2 +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPU sockets. (e.g. '1')" +} + +variable "vm_cpu_type" { + type = string + description = "The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64." +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB." + default = 4096 +} + +variable "vm_tpm_storage_pool" { + type = string + description = "Storage location virtual trusted platform module (vTPM)." +} + +variable "vm_tpm_version" { + type = string + description = "Version of virtual trusted platform module (vTPM). Can be 'v1.2' or 'v2.0' Defaults to 'v2.0'" + default = "v2.0" +} + +variable "vm_disk_controller_type" { + type = string + description = "The SCSI controller model to emulate. (e.g. 'virtio-scsi-pci')" +} + +variable "vm_disk_type" { + type = string + description = "The type of disk to emulate. (e.g. 'virtio')" +} + +variable "vm_storage_pool" { + type = string + description = "The name of the Proxmox storage pool to store the VM template. (e.g. 'local')" +} + +variable "vm_disk_size" { + type = string + description = "The size for the virtual disk in GB. (e.g. '32G')" +} + +variable "vm_disk_format" { + type = string + description = "The format of the file backing the disk. (e.g. 'qcow2')" +} + +variable "vm_network_card_model" { + type = string + description = "The model of the virtual network adapter to emulate. (e.g. 'virtio')" +} + +variable "vm_bridge_interface" { + type = string + description = "The name of the Proxmox bridge to attach the adapter to." +} + +variable "vm_vlan_tag" { + type = string + description = "If the adapter should tag packets, give the VLAN ID. (e.g. '102')" +} + +variable "vm_video_ram" { + type = number + description = "The size for the video memory in KB." + default = 4096 +} + +variable "vm_video_displays" { + type = number + description = "The number of video displays." + default = 1 +} + +// Removable Media Settings + +variable "common_iso_storage" { + type = string + description = "The name of the source Proxmox storage location for ISO images. (e.g. 'local')" +} + +variable "iso_path" { + type = string + description = "The path on the source Proxmox storage location for ISO images. (e.g. 'iso')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')" +} + +variable "iso_checksum" { + type = string + description = "The checksum value of the ISO image provided by the vendor." +} + +// Boot Settings + +variable "common_data_source" { + type = string + description = "The provisioning data source. One of `http` or `disk`." +} + +variable "common_http_bind_address" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + 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_wait" { + type = string + description = "The time to wait before boot." + default = "5s" +} + +variable "vm_boot_command" { + type = list(string) + description = "The virtual machine boot command." + default = ["<spacebar><spacebar>"] +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system." + sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." + sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The SHA-512 encrypted password to login to the guest operating system." + sensitive = true + default = "" +} + +variable "build_key" { + type = string + description = "The public key to login to the guest operating system." + sensitive = true + default = "" +} + +// Communicator Credentials + +variable "communicator_port" { + type = number + description = "The port for the communicator protocol." + default = 5985 +} + +variable "communicator_timeout" { + type = string + description = "The timeout for the communicator protocol." + default = "12h" +} + +// Ansible Credentials + +variable "ansible_username" { + type = string + description = "The username for Ansible to login to the guest operating system." + sensitive = true +} + +variable "ansible_key" { + type = string + description = "The public key for Ansible to login to the guest operating system." + sensitive = true +} + +// Provisioner Settings + +variable "scripts" { + type = list(string) + description = "A list of scripts and their relative paths to transfer and run." + default = [] +} + +variable "inline" { + type = list(string) + description = "A list of commands to run." + default = [] +} + +// HCP Packer Settings + +variable "common_hcp_packer_registry_enabled" { + type = bool + description = "Enable the HCP Packer registry." + default = false +} diff --git a/builds/windows/desktop/11/windows.auto.pkrvars.hcl b/builds/windows/desktop/11/windows.auto.pkrvars.hcl new file mode 100644 index 0000000..c38a40a --- /dev/null +++ b/builds/windows/desktop/11/windows.auto.pkrvars.hcl @@ -0,0 +1,43 @@ +/* + DESCRIPTION: + Microsoft Windows 11 variables used by the Packer Plugin for Proxmox (proxmox-iso). +*/ + +// Guest Operating System Metadata +vm_os_language = "en_US" +vm_os_keyboard = "us" +vm_os_timezone = "UTC" + +// Virtual Machine Guest Operating System Setting +vm_os_type = "win11" + +// Machine type +// Q35 less resource overhead and newer chipset +vm_machine_type = "q35" + +// Virtual Machine Hardware Settings +vm_bios = "ovmf" +vm_cpu_count = 2 +vm_cpu_sockets = 1 +vm_cpu_type = "x86-64-v2-AES" +vm_mem_size = 4096 +vm_disk_type = "virtio" +vm_disk_size = "32G" +vm_disk_format = "raw" +vm_disk_controller_type = "virtio-scsi-single" +vm_network_card_model = "virtio" + +// Removable Media Settings +iso_path = "iso" +iso_file = "22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso" +iso_checksum = "" + +// Boot Settings +vm_boot_order = "order=virtio0;ide2;net0" + +// EFI Settings +vm_efi_storage_pool = "pool0" +vm_firmware_path = "./OVMF.fd" + +// TPM Settings +vm_tpm_storage_pool = "pool0" diff --git a/builds/windows/desktop/11/windows.pkr.hcl b/builds/windows/desktop/11/windows.pkr.hcl new file mode 100644 index 0000000..0295da7 --- /dev/null +++ b/builds/windows/desktop/11/windows.pkr.hcl @@ -0,0 +1,317 @@ +/* + DESCRIPTION: + Microsoft Windows 11 build definition. + Packer Plugin for Proxmox: 'proxmox-iso' builder. +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.11.0" + required_plugins { + ansible = { + source = "github.com/hashicorp/ansible" + version = "~> 1" + } + git = { + version = ">= 0.6.2" + source = "github.com/ethanmdavidson/git" + } + proxmox = { + version = ">= 1.2.2" + source = "github.com/hashicorp/proxmox" + } + } +} + +// BLOCK: data +// Defines the data sources. + +data "git-repository" "cwd" {} + +// BLOCK: locals +// Defines the local variables. + +locals { + build_by = "Built by: HashiCorp Packer ${packer.version}" + build_date = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) + build_version = data.git-repository.cwd.head + build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}" + manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) + manifest_path = "${path.cwd}/manifests/" + manifest_output = "${local.manifest_path}${local.manifest_date}.json" + vm_name_pro = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}-${var.vm_os_edition_pro}" + vm_name_ent = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}-${var.vm_os_edition_ent}" + bucket_name = replace("${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}", ".", "") + bucket_description = "${var.vm_os_family} ${var.vm_os_name} ${var.vm_os_version}" +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "proxmox-iso" "windows-desktop-pro" { + + // Proxmox Connection Settings and Credentials + proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" + username = var.proxmox_api_token_id + token = var.proxmox_api_token_secret + insecure_skip_tls_verify = var.proxmox_insecure_connection + + // Proxmox Settings + node = var.proxmox_node + + // Virtual Machine Settings + machine = var.vm_machine_type + vm_name = local.vm_name_pro + bios = var.vm_bios + sockets = var.vm_cpu_sockets + cores = var.vm_cpu_count + cpu_type = var.vm_cpu_type + memory = var.vm_mem_size + os = var.vm_os_type + qemu_agent = true + 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 + } + + network_adapters { + bridge = var.vm_bridge_interface + model = var.vm_network_card_model + vlan_tag = var.vm_vlan_tag + } + + tpm_config { + tpm_storage_pool = var.vm_tpm_storage_pool + tpm_version = var.vm_tpm_version + } + + dynamic "efi_config" { + for_each = var.vm_bios == "ovmf" ? [1] : [] + content { + efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null + efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null + pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null + } + } + + # Windows Server ISO File + boot_iso { + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = var.iso_checksum + type = "ide" + index = 0 + } + + // Removable Media Settings + additional_iso_files { + iso_file = "${var.common_iso_storage}:iso/virtio-win.iso" + iso_storage_pool = var.common_iso_storage + cd_label = "VirtIO" + unmount = true + } + + additional_iso_files { + cd_files = [ + "${path.cwd}/scripts/${var.vm_os_family}/" + ] + cd_content = { + "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_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_guest_os_language = var.vm_os_language + vm_guest_os_keyboard = var.vm_os_keyboard + vm_guest_os_timezone = var.vm_os_timezone + }) + } + cd_label = "Unattend" + iso_storage_pool = var.common_iso_storage + unmount = true + } + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + boot_wait = var.vm_boot_wait + boot_command = var.vm_boot_command + + // Communicator Settings and Credentials + communicator = "winrm" + winrm_username = var.build_username + winrm_password = var.build_password + winrm_port = var.communicator_port + winrm_timeout = var.communicator_timeout + + template_name = local.vm_name_pro + template_description = local.build_description + +} + +# Build Definition to create the VM Template +source "proxmox-iso" "windows-desktop-ent" { + + // Proxmox Connection Settings and Credentials + proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json" + username = var.proxmox_api_token_id + token = var.proxmox_api_token_secret + insecure_skip_tls_verify = var.proxmox_insecure_connection + + // Proxmox Settings + node = var.proxmox_node + + // Virtual Machine Settings + machine = var.vm_machine_type + vm_name = local.vm_name_ent + bios = var.vm_bios + sockets = var.vm_cpu_sockets + cores = var.vm_cpu_count + cpu_type = var.vm_cpu_type + memory = var.vm_mem_size + os = var.vm_os_type + qemu_agent = true + 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 + } + + network_adapters { + bridge = var.vm_bridge_interface + model = var.vm_network_card_model + vlan_tag = var.vm_vlan_tag + } + + tpm_config { + tpm_storage_pool = var.vm_tpm_storage_pool + tpm_version = var.vm_tpm_version + } + + dynamic "efi_config" { + for_each = var.vm_bios == "ovmf" ? [1] : [] + content { + efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null + efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null + pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null + } + } + + # Windows Server ISO File + boot_iso { + + iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}" + unmount = true + iso_checksum = var.iso_checksum + type = "ide" + index = 0 + } + + // Removable Media Settings + additional_iso_files { + iso_file = "${var.common_iso_storage}:iso/virtio-win.iso" + iso_storage_pool = var.common_iso_storage + cd_label = "VirtIO" + unmount = true + } + + additional_iso_files { + cd_files = [ + "${path.cwd}/scripts/${var.vm_os_family}/" + ] + cd_content = { + "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_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_guest_os_language = var.vm_os_language + vm_guest_os_keyboard = var.vm_os_keyboard + vm_guest_os_timezone = var.vm_os_timezone + }) + } + cd_label = "Unattend" + iso_storage_pool = var.common_iso_storage + unmount = true + } + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + boot_wait = var.vm_boot_wait + boot_command = var.vm_boot_command + + // Communicator Settings and Credentials + communicator = "winrm" + winrm_username = var.build_username + winrm_password = var.build_password + winrm_port = var.communicator_port + winrm_timeout = var.communicator_timeout + + template_name = local.vm_name_pro + template_description = local.build_description + +} +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = [ + "source.proxmox-iso.windows-desktop-ent" + ] + + provisioner "ansible" { + user = "${var.build_username}" + galaxy_file = "${path.cwd}/ansible/windows-requirements.yml" + galaxy_force_with_deps = true + use_proxy = false + playbook_file = "${path.cwd}/ansible/windows-playbook.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg" + ] + extra_arguments = [ + "--extra-vars", "use_proxy=false", + "--extra-vars", "ansible_connection=winrm", + "--extra-vars", "ansible_user='${var.build_username}'", + "--extra-vars", "ansible_password='${var.build_password}'", + "--extra-vars", "ansible_port='${var.communicator_port}'", + "--extra-vars", "build_username='${var.build_username}'", + ] + } + + post-processor "manifest" { + output = local.manifest_output + strip_path = true + strip_time = true + custom_data = { + ansible_username = "${var.ansible_username}" + build_username = "${var.build_username}" + build_date = "${local.build_date}" + build_version = "${local.build_version}" + common_data_source = "${var.common_data_source}" + vm_cpu_sockets = "${var.vm_cpu_sockets}" + vm_cpu_count = "${var.vm_cpu_count}" + vm_disk_size = "${var.vm_disk_size}" + vm_bios = "${var.vm_bios}" + vm_os_type = "${var.vm_os_type}" + vm_mem_size = "${var.vm_mem_size}" + vm_network_card_model = "${var.vm_network_card_model}" + } + } +} diff --git a/builds/windows/desktop/11/windows.pkrvars.hcl.example b/builds/windows/desktop/11/windows.pkrvars.hcl.example new file mode 100644 index 0000000..7d0c9ed --- /dev/null +++ b/builds/windows/desktop/11/windows.pkrvars.hcl.example @@ -0,0 +1,20 @@ +/* + DESCRIPTION: + Microsoft Windows 11 build variables. + Packer Plugin for Proxmox: 'proxmox-iso' builder. +*/ + +// Installation Operating System Metadata +vm_inst_os_key_pro = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" +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" diff --git a/scripts/windows/windows-init.ps1 b/scripts/windows/windows-init.ps1 new file mode 100644 index 0000000..e28786b --- /dev/null +++ b/scripts/windows/windows-init.ps1 @@ -0,0 +1,30 @@ +<# + .DESCRIPTION + Enables Windows Remote Management on Windows builds. +#> + +$ErrorActionPreference = 'Stop' + +# Set network connections provile to Private mode. +Write-Output 'Setting the network connection profiles to Private...' +$connectionProfile = Get-NetConnectionProfile +While ($connectionProfile.Name -eq 'Identifying...') { + Start-Sleep -Seconds 10 + $connectionProfile = Get-NetConnectionProfile +} +Set-NetConnectionProfile -Name $connectionProfile.Name -NetworkCategory Private + +# Set the Windows Remote Management configuration. +Write-Output 'Setting the Windows Remote Management configuration...' +winrm quickconfig -quiet +winrm set winrm/config/service '@{AllowUnencrypted="true"}' +winrm set winrm/config/service/auth '@{Basic="true"}' + +# Allow Windows Remote Management in the Windows Firewall. +Write-Output 'Allowing Windows Remote Management in the Windows Firewall...' +netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes +netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow + +# Reset the autologon count. +# Reference: https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-autologon-logoncount#logoncount-known-issue +Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoLogonCount -Value 0 diff --git a/scripts/windows/windows-virtio.ps1 b/scripts/windows/windows-virtio.ps1 new file mode 100644 index 0000000..0b9a105 --- /dev/null +++ b/scripts/windows/windows-virtio.ps1 @@ -0,0 +1,99 @@ +# Install Virtio Drivers + +function Enable-Virtio { +Write-Host "Installing Virtio Drivers" +# Search and Install virtio-win-gt-x64.msi Script + +# Get all file system drives +$drives = Get-PSDrive -PSProvider 'FileSystem' + +# Loop through each drive to find and run the MSI installer +foreach ($drive in $drives) { + $scriptFile = Join-Path $drive.Root 'virtio-win-gt-x64.msi' + + # Check if the MSI file exists on the current drive + if (Test-Path $scriptFile) { + # Run the MSI installer with the specified arguments + Start-Process msiexec -Wait -ArgumentList '/i', $scriptFile, '/log', 'C:\Windows\Temp\qemu-drivers.log', '/qn', '/passive', '/norestart', 'ADDLOCAL=ALL' -ErrorAction SilentlyContinue + } +} +# Search and Install virtio-win-gt-x64.msi Script +Write-Host "Installing QEMU Guest Agent" +# Get all file system drives +$drives = Get-PSDrive -PSProvider 'FileSystem' + +# Loop through each drive to find and run the MSI installer +foreach ($drive in $drives) { + $scriptFile = Join-Path $drive.Root '/guest-agent/qemu-ga-x86_64.msi' + + # Check if the MSI file exists on the current drive + if (Test-Path $scriptFile) { + # Run the MSI installer with the specified arguments + Start-Process msiexec -Wait -ArgumentList '/i', $scriptFile, '/log', 'C:\Windows\Temp\qemu-guest-agent.log', '/qn', '/passive', '/norestart', 'ADDLOCAL=ALL' -ErrorAction SilentlyContinue + } + } +} + +# Write-Host "Installing SPICE" +# # Search and Install virtio-win-guest-tools.exe + +# # Get all file system drives +# $drives = Get-PSDrive -PSProvider 'FileSystem' + +# # Loop through each drive to find and run the MSI installer +# foreach ($drive in $drives) { +# $scriptFile = Join-Path $drive.Root 'virtio-win-guest-tools.exe' + +# # Check if the MSI file exists on the current drive +# if (Test-Path $scriptFile) { +# # Run the MSI installer with the specified arguments +# Start-Process msiexec -Wait -ArgumentList '/i', $scriptFile, '/log', 'C:\Windows\Temp\qemu-drivers.log', '/qn', '/passive', '/norestart', 'ADDLOCAL=ALL' -ErrorAction SilentlyContinue +# } +# } +If (Get-service -Name QEMU-GA -ErrorAction SilentlyContinue) { + Write-Host "Starting QEMU Guest Agent" + Start-Service -Name QEMU-GA -ErrorAction SilentlyContinue +} + +If (Get-service -Name spice-agent -ErrorAction SilentlyContinue) { + Write-Host "Starting SPICE" + Start-Service -Name spice-agent -ErrorAction SilentlyContinue +} + +Function Enable-WinRM { +Write-Host "Enable WinRM" +netsh advfirewall firewall set rule group="remote administration" new enable=yes +netsh advfirewall firewall add rule name="WinRM open Port 5985" dir=in action=allow protocol=TCP localport=5985 + +winrm quickconfig -q +winrm quickconfig -transport:http +winrm set winrm/config '@{MaxTimeoutms="7200000"}' +winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}' +winrm set winrm/config/winrs '@{MaxProcessesPerShell="0"}' +winrm set winrm/config/winrs '@{MaxShellsPerUser="0"}' +winrm set winrm/config/service '@{AllowUnencrypted="true"}' +winrm set winrm/config/service/auth '@{Basic="true"}' +winrm set winrm/config/client/auth '@{Basic="true"}' + +net stop winrm +sc.exe config winrm start= auto +net start winrm + +} + +# http://support.microsoft.com/kb/154501 +Write-Host "Disabling automatic machine account password changes" +Get-WmiObject -Class Win32_UserAccount -Filter "name = 'Administrator'" | Set-WmiInstance -Arguments @{PasswordExpires = 0 } + +$path = "HKLM:\System\CurrentControlSet\Services\Netlogon\Parameters" +$key = try { + Get-Item -Path $path -ErrorAction Stop +} +catch { + New-Item -Path $path -Force +} + +Set-ItemProperty -Path $key.PSPath -Name DisablePasswordChange -Value 1 + +Enable-Virtio +Enable-WinRM From 621bbd061a08ecfb514c49b48db4605d16ef75fc Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Thu, 20 Feb 2025 23:30:04 -0600 Subject: [PATCH 06/22] feat: add centos 10 build --- .../linux/centos/10-stream/data/ks.pkrtpl.hcl | 82 +++++ .../centos/10-stream/data/network.pkrtpl.hcl | 5 + .../centos/10-stream/data/storage.pkrtpl.hcl | 73 +++++ .../linux-centos-stream.auto.pkrvars.hcl | 40 +++ .../10-stream/linux-centos-stream.pkr.hcl | 226 +++++++++++++ .../10-stream/variables-network.pkr.hcl | 36 ++ .../10-stream/variables-storage.pkr.hcl | 53 +++ .../linux/centos/10-stream/variables.pkr.hcl | 307 ++++++++++++++++++ 8 files changed, 822 insertions(+) create mode 100644 builds/linux/centos/10-stream/data/ks.pkrtpl.hcl create mode 100644 builds/linux/centos/10-stream/data/network.pkrtpl.hcl create mode 100644 builds/linux/centos/10-stream/data/storage.pkrtpl.hcl create mode 100644 builds/linux/centos/10-stream/linux-centos-stream.auto.pkrvars.hcl create mode 100644 builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl create mode 100644 builds/linux/centos/10-stream/variables-network.pkr.hcl create mode 100644 builds/linux/centos/10-stream/variables-storage.pkr.hcl create mode 100644 builds/linux/centos/10-stream/variables.pkr.hcl diff --git a/builds/linux/centos/10-stream/data/ks.pkrtpl.hcl b/builds/linux/centos/10-stream/data/ks.pkrtpl.hcl new file mode 100644 index 0000000..ff6db3b --- /dev/null +++ b/builds/linux/centos/10-stream/data/ks.pkrtpl.hcl @@ -0,0 +1,82 @@ +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# CentOS Stream 9 + +### Installs from the first attached CD-ROM/DVD on the system. +cdrom + +### Performs the kickstart installation in text mode. +### By default, kickstart installations are performed in graphical mode. +text + +### Accepts the End User License Agreement. +eula --agreed + +### Sets the language to use during installation and the default language to use on the installed system. +lang ${vm_os_language} + +### Sets the default keyboard type for the system. +keyboard ${vm_os_keyboard} + +### Configure network information for target system and activate network devices in the installer environment (optional) +### --onboot enable device at a boot time +### --device device to be activated and / or configured with the network command +### --bootproto method to obtain networking configuration for device (default dhcp) +### --noipv6 disable IPv6 on this device +${network} + +### Lock the root account. +rootpw --lock + +### The selected profile will restrict root login. +### Add a user that can login and escalate privileges. +user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel + +### Configure firewall settings for the system. +### --enabled reject incoming connections that are not in response to outbound requests +### --ssh allow sshd service through the firewall +firewall --enabled --ssh + +### Sets up the authentication options for the system. +### The SSDD profile sets sha512 to hash passwords. Passwords are shadowed by default +### See the manual page for authselect-profile for a complete list of possible options. +authselect select sssd + +### Sets the state of SELinux on the installed system. +### Defaults to enforcing. +selinux --enforcing + +### Sets the system time zone. +timezone ${vm_os_timezone} + +### Partitioning +${storage} + +### Modifies the default set of services that will run under the default runlevel. +services --enabled=NetworkManager,sshd + +### Do not configure X on the installed system. +skipx + +### Packages selection. +%packages --ignoremissing --excludedocs +@core +-iwl*firmware +%end + +### Post-installation commands. +%post +dnf makecache +dnf install epel-release -y +dnf makecache +dnf install -y sudo qemu-guest-tools +echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username} +sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers +%end + +### Reboot after the installation is complete. +### --eject attempt to eject the media before rebooting. +reboot --eject diff --git a/builds/linux/centos/10-stream/data/network.pkrtpl.hcl b/builds/linux/centos/10-stream/data/network.pkrtpl.hcl new file mode 100644 index 0000000..64aaf4f --- /dev/null +++ b/builds/linux/centos/10-stream/data/network.pkrtpl.hcl @@ -0,0 +1,5 @@ +%{ if ip != null ~} +network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)} +%{ else ~} +network --device=${device} --bootproto=dhcp +%{ endif ~} \ No newline at end of file diff --git a/builds/linux/centos/10-stream/data/storage.pkrtpl.hcl b/builds/linux/centos/10-stream/data/storage.pkrtpl.hcl new file mode 100644 index 0000000..b35af89 --- /dev/null +++ b/builds/linux/centos/10-stream/data/storage.pkrtpl.hcl @@ -0,0 +1,73 @@ +### Sets how the boot loader should be installed. +bootloader --location=mbr + +### Initialize any invalid partition tables found on disks. +zerombr + +### Removes partitions from the system, prior to creation of new partitions. +### By default, no partitions are removed. +### --all Erases all partitions from the system +### --initlabel Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture. +clearpart --all --initlabel + +### Modify partition sizes for the virtual machine hardware. +### Create primary system partitions. +%{ for partition in partitions ~} +part +%{~ if partition.volume_group != "" ~} + pv.${partition.volume_group} +%{~ else ~} +%{~ if partition.format.fstype == "swap" ~} + swap +%{~ else ~} + ${partition.mount.path} +%{~ endif ~} +%{~ if partition.format.fstype != "" ~} + --label=${partition.format.label} +%{~ if partition.format.fstype == "fat32" ~} + --fstype vfat +%{~ else ~} + --fstype ${partition.format.fstype} +%{~ endif ~} +%{~ endif ~} +%{~ endif ~} +%{~ if partition.mount.options != "" ~} + --fsoptions="${partition.mount.options}" +%{~ endif ~} +%{~ if partition.size != -1 ~} + --size=${partition.size} +%{~ else ~} + --size=100 --grow +%{ endif ~} + +%{ endfor ~} +### Create a logical volume management (LVM) group. +%{ for index, volume_group in lvm ~} +volgroup sysvg pv.${volume_group.name} + +### Modify logical volume sizes for the virtual machine hardware. +### Create logical volumes. +%{ for partition in volume_group.partitions ~} +logvol +%{~ if partition.format.fstype == "swap" ~} + swap +%{~ else ~} + ${partition.mount.path} +%{~ endif ~} + --name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label} +%{~ if partition.format.fstype == "fat32" ~} + --fstype vfat +%{~ else ~} + --fstype ${partition.format.fstype} +%{~ endif ~} +%{~ if partition.mount.options != "" ~} + --fsoptions="${partition.mount.options}" +%{~ endif ~} +%{~ if partition.size != -1 ~} + --size=${partition.size} +%{~ else ~} + --size=100 --grow +%{ endif ~} + +%{ endfor ~} +%{ endfor ~} \ No newline at end of file diff --git a/builds/linux/centos/10-stream/linux-centos-stream.auto.pkrvars.hcl b/builds/linux/centos/10-stream/linux-centos-stream.auto.pkrvars.hcl new file mode 100644 index 0000000..ecfdbb8 --- /dev/null +++ b/builds/linux/centos/10-stream/linux-centos-stream.auto.pkrvars.hcl @@ -0,0 +1,40 @@ +/* + DESCRIPTION: + CentOS Stream 10 variables used by the Packer Plugin for Proxmox (proxmox-iso). +*/ + +// Guest Operating System Metadata +vm_os_language = "en_US" +vm_os_keyboard = "us" +vm_os_timezone = "UTC" +vm_os_family = "linux" +vm_os_name = "centos-stream" +vm_os_version = "10" + +// Virtual Machine Guest Operating System Setting +vm_os_type = "l26" +vm_cloudinit = true + +// Virtual Machine Hardware Settings +vm_bios = "ovmf" +vm_cpu_count = 1 +vm_cpu_sockets = 1 +vm_cpu_type = "x86-64-v4" +vm_mem_size = 2048 +vm_disk_type = "virtio" +vm_disk_size = "32G" +vm_disk_format = "raw" +vm_disk_controller_type = "virtio-scsi-pci" +vm_network_card_model = "virtio" + +// Removable Media Settings +iso_path = "iso" +iso_file = "CentOS-Stream-10-latest-x86_64-dvd1.iso" +iso_checksum = "file:https://mirror.stream.centos.org/10-stream/BaseOS/x86_64/iso/SHA256SUM" + +// Boot Settings +vm_boot = "order=virtio0;ide2;net0" +vm_boot_wait = "5s" + +// EFI Settings +vm_firmware_path = "./OVMF.fd" diff --git a/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl b/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl new file mode 100644 index 0000000..e77c0f6 --- /dev/null +++ b/builds/linux/centos/10-stream/linux-centos-stream.pkr.hcl @@ -0,0 +1,226 @@ +/* + DESCRIPTION: + CentOS Stream 10 template using the Packer Builder for Proxmox (proxmox-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.9.1" + required_plugins { + ansible = { + source = "github.com/hashicorp/ansible" + version = "~> 1" + } + git = { + version = ">= 0.4.2" + source = "github.com/ethanmdavidson/git" + } + proxmox = { + version = ">= 1.0.6" + source = "github.com/hashicorp/proxmox" + } + } +} + +// BLOCK: data +// Defines the data sources. + +data "git-repository" "cwd" {} + +// BLOCK: locals +// Defines the local variables. + +locals { + + bios_boot_command = [ + "<up><wait>", + "<tab><wait>", + " text ${local.data_source_command}", + "<enter><wait>" + ] + + uefi_boot_command = [ + // This sends the "up arrow" key, typically used to navigate through boot menu options. + "<up>", + // This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option. + "e", + // This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration. + "<down><down><end><wait>", + // This types the string "text" followed by the value of the 'data_source_command' local variable. + // This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables. + "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. + "<enter><wait><leftCtrlOn>x<leftCtrlOff>" + ] + + build_by = "Built by: HashiCorp Packer ${packer.version}" + build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" ) + build_version = data.git-repository.cwd.head + build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}" + vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda" + manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) + manifest_path = "${path.cwd}/manifests/" + manifest_output = "${local.manifest_path}${local.manifest_date}.json" + data_source_content = { + "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { + build_username = var.build_username + build_password = var.build_password + build_password_encrypted = var.build_password_encrypted + vm_disk_type = local.vm_disk_type + vm_os_language = var.vm_os_language + vm_os_keyboard = var.vm_os_keyboard + vm_os_timezone = var.vm_os_timezone + network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", { + device = var.vm_bridge_interface + ip = var.vm_ip_address + netmask = var.vm_ip_netmask + gateway = var.vm_ip_gateway + dns = var.vm_dns_list + }) + common_data_source = var.common_data_source + # lvm needs to be here so late commands can access vg names + lvm = var.vm_disk_lvm + storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", { + device = var.vm_disk_device + swap = var.vm_disk_use_swap + partitions = var.vm_disk_partitions + lvm = var.vm_disk_lvm + vm_bios = var.vm_bios + }) + additional_packages = join(" ", var.additional_packages) + }) + } + data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg" + vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}" + boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command + vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null +} + +// BLOCK: source +// 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}" + token = "${var.proxmox_api_token_secret}" + insecure_skip_tls_verify = "${var.proxmox_insecure_connection}" + + // Proxmox Settings + node = "${var.proxmox_node}" + + // Virtual Machine Settings + vm_name = "${local.vm_name}" + bios = "${var.vm_bios}" + sockets = "${var.vm_cpu_sockets}" + cores = "${var.vm_cpu_count}" + cpu_type = "${var.vm_cpu_type}" + 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 { + efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null + efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null + 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 { + bridge = "${var.vm_bridge_interface}" + model = "${var.vm_network_card_model}" + vlan_tag = "${var.vm_vlan_tag}" + } + + // Removable Media Settings + http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null + + // Boot and Provisioning Settings + 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 + boot = var.vm_boot + boot_wait = var.vm_boot_wait + boot_command = local.boot_command + + dynamic "additional_iso_files" { + for_each = var.common_data_source == "disk" ? [1] : [] + content { + cd_files = var.common_data_source == "disk" ? local.data_source_content : null + cd_label = var.common_data_source == "disk" ? "cidata" : null + iso_storage_pool = var.common_data_source == "disk" ? "local" : null + } + } + + template_name = "${local.vm_name}" + template_description = "${local.build_description}" + + # VM Cloud Init Settings + cloud_init = var.vm_cloudinit + cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null + +} + +# Build Definition to create the VM Template +build { + sources = ["source.proxmox-iso.linux-centos-stream"] + + provisioner "ansible" { + user = "${var.build_username}" + galaxy_file = "${path.cwd}/ansible/linux-requirements.yml" + galaxy_force_with_deps = true + playbook_file = "${path.cwd}/ansible/linux-playbook.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg", + "ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python" + ] + extra_arguments = [ + "--extra-vars", "display_skipped_hosts=false", + "--extra-vars", "build_username=${var.build_username}", + "--extra-vars", "build_key='${var.build_key}'", + "--extra-vars", "ansible_username=${var.ansible_username}", + "--extra-vars", "ansible_key='${var.ansible_key}'", + "--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'", + ] + } + + post-processor "manifest" { + output = local.manifest_output + strip_path = true + strip_time = true + custom_data = { + ansible_username = "${var.ansible_username}" + build_username = "${var.build_username}" + build_date = "${local.build_date}" + build_version = "${local.build_version}" + common_data_source = "${var.common_data_source}" + vm_cpu_sockets = "${var.vm_cpu_sockets}" + vm_cpu_count = "${var.vm_cpu_count}" + vm_disk_size = "${var.vm_disk_size}" + vm_bios = "${var.vm_bios}" + vm_os_type = "${var.vm_os_type}" + vm_mem_size = "${var.vm_mem_size}" + vm_network_card_model = "${var.vm_network_card_model}" + vm_cloudinit = "${var.vm_cloudinit}" + } + } +} diff --git a/builds/linux/centos/10-stream/variables-network.pkr.hcl b/builds/linux/centos/10-stream/variables-network.pkr.hcl new file mode 100644 index 0000000..174d6da --- /dev/null +++ b/builds/linux/centos/10-stream/variables-network.pkr.hcl @@ -0,0 +1,36 @@ +/* + DESCRIPTION: + CentOS Stream 10 network variables used by the Packer Plugin for Proxmox (proxmox-iso). +*/ + +// VM Network Settings + +variable "vm_network_device" { + type = string + description = "The network device of the VM." + default = "ens192" +} + +variable "vm_ip_address" { + type = string + description = "The IP address of the VM (e.g. 172.16.100.192)." + default = null +} + +variable "vm_ip_netmask" { + type = number + description = "The netmask of the VM (e.g. 24)." + default = null +} + +variable "vm_ip_gateway" { + type = string + description = "The gateway of the VM (e.g. 172.16.100.1)." + default = null +} + +variable "vm_dns_list" { + type = list(string) + description = "The nameservers of the VM." + default = [] +} diff --git a/builds/linux/centos/10-stream/variables-storage.pkr.hcl b/builds/linux/centos/10-stream/variables-storage.pkr.hcl new file mode 100644 index 0000000..248c614 --- /dev/null +++ b/builds/linux/centos/10-stream/variables-storage.pkr.hcl @@ -0,0 +1,53 @@ +/* + DESCRIPTION: + CentOS Stream 10 storage variables used by the Packer Plugin for Proxmox (proxmox-iso). +*/ + +// VM Storage Settings + +variable "vm_disk_device" { + type = string + description = "The device for the virtual disk. (e.g. 'sda')" +} + +variable "vm_disk_use_swap" { + type = bool + description = "Whether to use a swap partition." +} + +variable "vm_disk_partitions" { + type = list(object({ + name = string + size = number + format = object({ + label = string + fstype = string + }) + mount = object({ + path = string + options = string + }) + volume_group = string + })) + description = "The disk partitions for the virtual disk." +} + +variable "vm_disk_lvm" { + type = list(object({ + name = string + partitions = list(object({ + name = string + size = number + format = object({ + label = string + fstype = string + }) + mount = object({ + path = string + options = string + }) + })) + })) + description = "The LVM configuration for the virtual disk." + default = [] +} diff --git a/builds/linux/centos/10-stream/variables.pkr.hcl b/builds/linux/centos/10-stream/variables.pkr.hcl new file mode 100644 index 0000000..5c4eedc --- /dev/null +++ b/builds/linux/centos/10-stream/variables.pkr.hcl @@ -0,0 +1,307 @@ +/* + DESCRIPTION: + CentOS 10 Stream variables using the Packer Builder for Proxmox (proxmox-iso). +*/ + +// BLOCK: variable +// Defines the input variables. + +// Proxmox Credentials + +variable "proxmox_hostname" { + type = string + description = "The FQDN or IP address of a Proxmox node. Only one node should be specified in a cluster." +} + +variable "proxmox_api_token_id" { + type = string + description = "The token to login to the Proxmox node/cluster. The format is USER@REALM!TOKENID. (e.g. packer@pam!packer_pve_token)" +} + +variable "proxmox_api_token_secret" { + type = string + description = "The secret for the API token used to login to the Proxmox API." +# sensitive = true +} + +variable "proxmox_insecure_connection" { + description = "true/false to skip Proxmox TLS certificate checks." + type = bool + default = true +} + +// Proxmox Settings + +variable "proxmox_node" { + type = string + description = "The name of the Proxmox node that Packer will build templates on." +} + +// Virtual Machine Settings + +variable "vm_os_language" { + type = string + description = "The guest operating system language." + default = "en_US" +} + +variable "vm_os_keyboard" { + type = string + description = "The guest operating system keyboard layout." + default = "us" +} + +variable "vm_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_os_family" { + type = string + description = "The guest operating system family. Used for naming. (e.g. 'linux')" +} + +variable "vm_os_name" { + type = string + description = "The guest operating system name. Used for naming. (e.g. 'ubuntu')" +} + +variable "vm_os_version" { + type = string + description = "The guest operating system version. Used for naming. (e.g. '22-04-lts')" +} + +variable "vm_os_type" { + type = string + description = "The guest operating system type. (e.g. 'l26')" +} + +variable "vm_bios" { + type = string + description = "The firmware type. Allowed values 'ovmf' or 'seabios'" + default = "ovmf" + + validation { + condition = contains(["ovmf", "seabios"], var.vm_bios) + error_message = "The vm_bios value must be 'ovmf' or 'seabios'." + } +} + +variable "vm_firmware_path" { + type = string + description = "The firmware file to be used. Needed for EFI" + default = "/usr/share/ovmf/OVMF.fd" +} + +variable "vm_efi_storage_pool" { + type = string + description = "Set the UEFI disk storage location. (e.g. 'local-lvm')" + default = "local-lvm" +} + +variable "vm_efi_type" { + type = string + description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')" + default = "4m" +} + +variable "vm_efi_pre_enrolled_keys" { + type = bool + description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)" + default = false +} + +variable "vm_cpu_count" { + type = number + description = "The number of virtual CPUs. (e.g. '2')" +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPU sockets. (e.g. '1')" +} + +variable "vm_cpu_type" { + type = string + description = "The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64." +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB. (e.g. '2048')" +} + +variable "vm_disk_controller_type" { + type = string + description = "The SCSI controller model to emulate. (e.g. 'virtio-scsi-pci')" +} + +variable "vm_disk_type" { + type = string + description = "The type of disk to emulate. (e.g. 'virtio')" +} + +variable "vm_storage_pool" { + type = string + description = "The name of the Proxmox storage pool to store the VM template. (e.g. 'local-lvm')" +} + +variable "vm_disk_size" { + type = string + description = "The size for the virtual disk in GB. (e.g. '32G')" +} + +variable "vm_disk_format" { + type = string + description = "The format of the file backing the disk. (e.g. 'qcow2')" +} + +variable "vm_network_card_model" { + type = string + description = "The model of the virtual network adapter to emulate. (e.g. 'virtio')" +} + +variable "vm_bridge_interface" { + type = string + description = "The name of the Proxmox bridge to attach the adapter to." +} + +variable "vm_vlan_tag" { + type = string + description = "If the adapter should tag packets, give the VLAN ID. (e.g. '102')" +} + +// Cloud-Init Settings + +variable "vm_cloudinit" { + type = bool + description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)" + default = false +} + +// Removable Media Settings + +variable "common_iso_storage" { + type = string + description = "The name of the source Proxmox storage location for ISO images. (e.g. 'local-lvm')" +} + +variable "iso_path" { + type = string + description = "The path on the source Proxmox storage location for ISO images. (e.g. 'iso')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')" +} + +variable "iso_checksum" { + type = string + description = "The checksum value of the ISO image provided by the vendor." +} + +// Boot Settings + +variable "common_data_source" { + type = string + description = "The provisioning data source. (e.g. 'http' or 'disk')" +} + +variable "common_http_bind_address" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + description = "The end of the HTTP port range." +} + +variable "vm_boot" { + type = string + description = "The boot order for virtual machine devices. (e.g. 'order=virtio0;ide2;net0')" +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait after booting the initial VM before typing the boot_command (e.g '10s')" +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system. (e.g. 'ubuntu')" +# sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." +# sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The encrypted password to login to the guest operating system." +# sensitive = true +} + +variable "build_key" { + type = string + description = "The SSH public key to login to the guest operating system." +# sensitive = true +} + +variable "timeout" { + description = "not sure why I need so high a timeout but here we are" + default = "90m" +} + +// Ansible Credentials + +variable "ansible_username" { + type = string + description = "The username for Ansible to login to the guest operating system. (e.g. 'ansible')" +# sensitive = true +} + +variable "ansible_key" { + type = string + description = "The public key for Ansible to login to the guest operating system." +# sensitive = true +} + +// HCP Packer Settings + +variable "common_hcp_packer_registry_enabled" { + type = bool + description = "Enable the HCP Packer registry." + default = false +} + +// Additional Settings + +variable "additional_packages" { + type = list(string) + description = "Additional packages to install." + default = [] +} 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 07/22] 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 08/22] 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 09/22] 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 10/22] 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 11/22] 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 = "<FQDN or IP of proxmox server>" proxmox_api_token_id = "name@realm!token" proxmox_api_token_secret = "<token secret>" proxmox_insecure_connection = false -// Proxmox Settings -proxmox_node = "<proxmox node name>" -proxmox_hostname = "<proxmox hostname>" +// Proxmox Specific Settings +proxmox_hostname = "<FQDN or IP of proxmox server>" +proxmox_node = "<proxmox node name>" 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 12/22] 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. "<up>", - // 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. "<tab>", "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. "<up>", - // 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. "<tab>", "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. "<enter><wait><leftCtrlOn>x<leftCtrlOff>" - ] + ] 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. "<enter><wait><leftCtrlOn>x<leftCtrlOff>" - ] + ] 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 = [ "<wait><wait><wait><esc><wait><wait><wait>", @@ -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 = [ "<wait><wait><wait><esc><wait><wait><wait>", @@ -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. "<up>", - // 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. "<tab>", "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. "<up>", - // 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. "<tab>", "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. "<enter><wait><leftCtrlOn>x<leftCtrlOff>" - ] + ] 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 13/22] 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 14/22] 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 15/22] 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 16/22] 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 17/22] 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 18/22] 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 | &check; | &check; | &check; | | | AlmaLinux | 8 | &check; | &check; | &check; | | -| CentOS Stream | 9 | &check; | &check; | | | -| Debian | 12 | &check; | | | | -| Debian | 11 | &check; | | | | -| Oracle Linux | 9 | &check; | | | | -| Oracle Linux | 8 | &check; | | | | -| Rocky Linux | 9 | &check; | | | | -| Rocky Linux | 8 | &check; | | | | -| OpenSUSE Leap | 15.6 | &check; | | | | -| OpenSUSE Leap | 15.5 | &check; | | | | -| Ubuntu Server | 24.04 LTS | &check; | | | | -| Ubuntu Server | 22.04 LTS | &check; | | | | +| CentOS Stream | 10 | &check; | &check; | &check; | &check; | +| CentOS Stream | 9 | &check; | &check; | &check; | &check; | +| Debian | 12 | &check; | &check; | &check; | &check; | +| Debian | 11 | &check; | &check; | &check; | &check; | +| OpenSUSE Leap | 15.6 | &check; | &check; | &check; | &check; | +| OpenSUSE Leap | 15.5 | &check; | &check; | &check; | &check; | +| Oracle Linux | 9 | &check; | &check; | &check; | &check; | +| Oracle Linux | 8 | &check; | &check; | &check; | &check; | +| Rocky Linux | 9 | &check; | &check; | &check; | &check; | +| Rocky Linux | 8 | &check; | &check; | &check; | &check; | +| Ubuntu Server | 24.04 LTS | &check; | &check; | &check; | &check; | +| Ubuntu Server | 22.04 LTS | &check; | &check; | &check; | &check; | | Ubuntu Server | 20.04 LTS | &check; | &check; | &check; | &check; | +| Windows Desktop | 11 | | | &check; | 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: - <details> <summary>CentOS Stream 9</summary> - 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 ``` </details> @@ -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 = "<Proxmox Storage Location>" // 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 = "<FQDN or IP of proxmox server>" proxmox_api_token_id = "name@realm!token" proxmox_api_token_secret = "<token secret>" proxmox_insecure_connection = false -// Proxmox Settings -proxmox_node = "<proxmox node name>" +// Proxmox Specific Settings +proxmox_hostname = "<FQDN or IP of proxmox server>" +proxmox_node = "<proxmox node name>" ``` 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 19/22] 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 From 7e0db92a8ac0565d7d33ec6b00632227f3958daf Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:55:19 -0500 Subject: [PATCH 20/22] chore: change default storage layout --- builds/linux-storage.pkrvars.hcl.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builds/linux-storage.pkrvars.hcl.example b/builds/linux-storage.pkrvars.hcl.example index a451147..541af28 100644 --- a/builds/linux-storage.pkrvars.hcl.example +++ b/builds/linux-storage.pkrvars.hcl.example @@ -8,6 +8,7 @@ - Use a size value of -1 to use all remaining space on disk. */ +/* // This section is an example when you want to build a VM with the BIOS bootloader // using a single partition that consumes the entire VM disk. @@ -35,6 +36,7 @@ vm_disk_partitions = [ volume_group = "", }, ] +*/ /* // This section is an example when you want to build a VM with the UEFI bootloader @@ -244,7 +246,6 @@ vm_disk_lvm = [ ] */ -/* // This section is an example when you want to build a VM with the EFI firmware // using LVM with a volume layout that follows CIS hardening guidelines. @@ -415,4 +416,3 @@ vm_disk_lvm = [ ], } ] -*/ From f92af475bd81969d4c89233f19a47b04df05c8c9 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <ajschroeder@hotmail.com> Date: Tue, 10 Jun 2025 22:03:28 +0000 Subject: [PATCH 21/22] fix: ignore ansible-lint output --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 444098a..a270b36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Ansible and ansible-lint +**/.ansible + !**/template_* **/credentials* From aed0138d0d4751f7a1f511fc8c4e91d8c2134514 Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Sun, 15 Jun 2025 08:06:28 -0500 Subject: [PATCH 22/22] refactor: windows vars file to keep current with rest of builds --- .../desktop/11/windows.auto.pkrvars.hcl | 43 ------------------- .../desktop/11/windows.pkrvars.hcl.example | 38 +++++++++++++++- 2 files changed, 37 insertions(+), 44 deletions(-) delete mode 100644 builds/windows/desktop/11/windows.auto.pkrvars.hcl diff --git a/builds/windows/desktop/11/windows.auto.pkrvars.hcl b/builds/windows/desktop/11/windows.auto.pkrvars.hcl deleted file mode 100644 index c38a40a..0000000 --- a/builds/windows/desktop/11/windows.auto.pkrvars.hcl +++ /dev/null @@ -1,43 +0,0 @@ -/* - DESCRIPTION: - Microsoft Windows 11 variables used by the Packer Plugin for Proxmox (proxmox-iso). -*/ - -// Guest Operating System Metadata -vm_os_language = "en_US" -vm_os_keyboard = "us" -vm_os_timezone = "UTC" - -// Virtual Machine Guest Operating System Setting -vm_os_type = "win11" - -// Machine type -// Q35 less resource overhead and newer chipset -vm_machine_type = "q35" - -// Virtual Machine Hardware Settings -vm_bios = "ovmf" -vm_cpu_count = 2 -vm_cpu_sockets = 1 -vm_cpu_type = "x86-64-v2-AES" -vm_mem_size = 4096 -vm_disk_type = "virtio" -vm_disk_size = "32G" -vm_disk_format = "raw" -vm_disk_controller_type = "virtio-scsi-single" -vm_network_card_model = "virtio" - -// Removable Media Settings -iso_path = "iso" -iso_file = "22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso" -iso_checksum = "" - -// Boot Settings -vm_boot_order = "order=virtio0;ide2;net0" - -// EFI Settings -vm_efi_storage_pool = "pool0" -vm_firmware_path = "./OVMF.fd" - -// TPM Settings -vm_tpm_storage_pool = "pool0" diff --git a/builds/windows/desktop/11/windows.pkrvars.hcl.example b/builds/windows/desktop/11/windows.pkrvars.hcl.example index a5398f8..94f97d4 100644 --- a/builds/windows/desktop/11/windows.pkrvars.hcl.example +++ b/builds/windows/desktop/11/windows.pkrvars.hcl.example @@ -8,7 +8,9 @@ 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" +// There doesn't appear to be a Windows 11 Pro evaluation ISO +// If you need to build Windows 11 Pro templates, you'll need the multi-edition ISO +vm_inst_os_image_pro = "Windows 11 Enterprise Evaluation" 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" @@ -22,3 +24,37 @@ vm_os_name = "desktop" vm_os_version = "11" vm_os_edition_pro = "pro" vm_os_edition_ent = "ent" + +// Virtual Machine Guest Operating System Setting +vm_os_type = "win11" + +// Machine type +// Q35 less resource overhead and newer chipset +vm_machine_type = "q35" + +// Virtual Machine Hardware Settings +vm_bios = "ovmf" +vm_cpu_count = 2 +vm_cpu_sockets = 1 +vm_cpu_type = "x86-64-v2-AES" +vm_mem_size = 4096 +vm_disk_type = "virtio" +vm_disk_size = "32G" +vm_disk_format = "raw" +vm_disk_controller_type = "virtio-scsi-single" +vm_network_card_model = "virtio" + +// Removable Media Settings +iso_path = "iso" +iso_file = "22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso" +iso_checksum = "" + +// Boot Settings +vm_boot_order = "order=virtio0;ide2;net0" + +// EFI Settings +vm_efi_storage_pool = "pool0" +vm_firmware_path = "./OVMF.fd" + +// TPM Settings +vm_tpm_storage_pool = "pool0"