feat: added build for Ubuntu 24.04
This commit is contained in:
@@ -2,9 +2,11 @@
|
|||||||
- name: "Configure SSH for Public Key Authentication"
|
- name: "Configure SSH for Public Key Authentication"
|
||||||
shell: |
|
shell: |
|
||||||
sudo sed -i 's/.*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
sudo sed -i 's/.*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||||
- name: "Restarting the SSH daemon."
|
|
||||||
shell: |
|
- name: Restarting the SSH daemon
|
||||||
sudo systemctl restart sshd
|
ansible.builtin.service:
|
||||||
|
name: ssh
|
||||||
|
state: restarted
|
||||||
|
|
||||||
- name: Remove cloud-init files
|
- name: Remove cloud-init files
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -18,7 +20,7 @@
|
|||||||
- /etc/netplan/00-installer-config.yaml
|
- /etc/netplan/00-installer-config.yaml
|
||||||
when:
|
when:
|
||||||
- cloud_init | bool
|
- cloud_init | bool
|
||||||
- ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04"
|
- ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04" or ansible_distribution_version == "24.04"
|
||||||
|
|
||||||
- name: Disable cloud-init if configured to
|
- name: Disable cloud-init if configured to
|
||||||
block:
|
block:
|
||||||
@@ -38,7 +40,7 @@
|
|||||||
- 'etc_cloud_folder.stat.exists'
|
- 'etc_cloud_folder.stat.exists'
|
||||||
when:
|
when:
|
||||||
- not cloud_init | bool
|
- not cloud_init | bool
|
||||||
- ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04"
|
- ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04" or ansible_distribution_version == "24.04"
|
||||||
|
|
||||||
- name: Copy cloud-init PVE default file
|
- name: Copy cloud-init PVE default file
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -51,7 +53,7 @@
|
|||||||
shell: |
|
shell: |
|
||||||
sed -i -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/" /etc/default/grub
|
sed -i -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/" /etc/default/grub
|
||||||
update-grub
|
update-grub
|
||||||
when: ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04"
|
when: ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04" or ansible_distribution_version == "24.04"
|
||||||
|
|
||||||
- name: Creating SSH key regeneration service file
|
- name: Creating SSH key regeneration service file
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -84,4 +86,3 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
when: not cloud_init | bool
|
when: not cloud_init | bool
|
||||||
|
|
||||||
...
|
|
||||||
|
|||||||
69
build.sh
69
build.sh
@@ -258,6 +258,69 @@ menu_option_8() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu_option_9() {
|
menu_option_9() {
|
||||||
|
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/24-04-lts/
|
||||||
|
echo -e "\nCONFIRM: Build a Ubuntu Server 24.04 LTS Template for Proxmox?"
|
||||||
|
echo -e "\nContinue? (y/n)"
|
||||||
|
read -r REPLY
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Build a Ubuntu Server 24.04 LTS Template for Proxmox. ###
|
||||||
|
echo "Building a Ubuntu Server 24.04 LTS 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...."
|
||||||
|
packer build -force \
|
||||||
|
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||||
|
"$INPUT_PATH"
|
||||||
|
|
||||||
|
### All done. ###
|
||||||
|
echo "Done."
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_option_10() {
|
||||||
|
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/24-04-lts/
|
||||||
|
echo -e "\nCONFIRM: Build a Ubuntu Server 24.04 LTS (cloud-init) Template for Proxmox?"
|
||||||
|
echo -e "\nContinue? (y/n)"
|
||||||
|
read -r REPLY
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Build a Ubuntu Server 24.04 LTS Template for Proxmox. ###
|
||||||
|
echo "Building a Ubuntu Server 24.04 LTS (cloud-init) 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...."
|
||||||
|
packer build -force \
|
||||||
|
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||||
|
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||||
|
-var "vm_cloud_init_enable=true" \
|
||||||
|
"$INPUT_PATH"
|
||||||
|
|
||||||
|
### All done. ###
|
||||||
|
echo "Done."
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_option_11() {
|
||||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/opensuse/leap-15-5/
|
INPUT_PATH="$SCRIPT_PATH"/builds/linux/opensuse/leap-15-5/
|
||||||
echo -e "\nCONFIRM: Build a OpenSUSE Leap 15.5 Template for Proxmox?"
|
echo -e "\nCONFIRM: Build a OpenSUSE Leap 15.5 Template for Proxmox?"
|
||||||
echo -e "\nContinue? (y/n)"
|
echo -e "\nContinue? (y/n)"
|
||||||
@@ -328,7 +391,9 @@ until [ "$selection" = "0" ]; do
|
|||||||
echo " 6 - Ubuntu Server 20.04 LTS (cloud-init)"
|
echo " 6 - Ubuntu Server 20.04 LTS (cloud-init)"
|
||||||
echo " 7 - Ubuntu Server 22.04 LTS"
|
echo " 7 - Ubuntu Server 22.04 LTS"
|
||||||
echo " 8 - Ubuntu Server 22.04 LTS (cloud-init)"
|
echo " 8 - Ubuntu Server 22.04 LTS (cloud-init)"
|
||||||
echo " 9 - OpenSUSE Leap 15.5"
|
echo " 9 - Ubuntu Server 24.04 LTS"
|
||||||
|
echo " 10 - Ubuntu Server 24.04 LTS (cloud-init)"
|
||||||
|
echo " 11 - OpenSUSE Leap 15.5"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Other:"
|
echo " Other:"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -347,6 +412,8 @@ until [ "$selection" = "0" ]; do
|
|||||||
7 ) clear ; menu_option_7 ; press_enter ;;
|
7 ) clear ; menu_option_7 ; press_enter ;;
|
||||||
8 ) clear ; menu_option_8 ; press_enter ;;
|
8 ) clear ; menu_option_8 ; press_enter ;;
|
||||||
9 ) clear ; menu_option_9 ; press_enter ;;
|
9 ) clear ; menu_option_9 ; press_enter ;;
|
||||||
|
10) clear ; menu_option_10 ; press_enter ;;
|
||||||
|
11) clear ; menu_option_11 ; press_enter ;;
|
||||||
[Ii] ) clear ; info ; press_enter ;;
|
[Ii] ) clear ; info ; press_enter ;;
|
||||||
[Qq] ) clear ; exit ;;
|
[Qq] ) clear ; exit ;;
|
||||||
* ) clear ; incorrect_selection ; press_enter ;;
|
* ) clear ; incorrect_selection ; press_enter ;;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
Ubuntu Server 22.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso).
|
Ubuntu Server 22.04 LTS template using the Packer Builder for Proxmox (proxmox-iso).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// BLOCK: packer
|
// BLOCK: packer
|
||||||
|
|||||||
0
builds/linux/ubuntu/24-04-lts/data/meta-data
Normal file
0
builds/linux/ubuntu/24-04-lts/data/meta-data
Normal file
109
builds/linux/ubuntu/24-04-lts/data/storage.pkrtpl.hcl
Normal file
109
builds/linux/ubuntu/24-04-lts/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
%{~ if length(partitions) == 1 && partitions[0].name == "autopart" ~}
|
||||||
|
%{~ if partitions[0].format.fstype == "lvm" ~}
|
||||||
|
storage:
|
||||||
|
layout:
|
||||||
|
name: lvm
|
||||||
|
%{~ endif ~}
|
||||||
|
%{~ if partitions[0].format.fstype == "simple" ~}
|
||||||
|
storage:
|
||||||
|
layout:
|
||||||
|
name: direct
|
||||||
|
%{~ endif ~}
|
||||||
|
%{~ if partitions[0].format.fstype == "" ~}
|
||||||
|
storage:
|
||||||
|
layout:
|
||||||
|
name: direct
|
||||||
|
%{~ endif ~}
|
||||||
|
%{~ else ~}
|
||||||
|
storage:
|
||||||
|
config:
|
||||||
|
- ptable: gpt
|
||||||
|
path: /dev/${device}
|
||||||
|
wipe: superblock
|
||||||
|
preserve: false
|
||||||
|
name: ''
|
||||||
|
%{ if vm_bios == "ovmf" ~}
|
||||||
|
grub_device: false
|
||||||
|
%{ endif ~}
|
||||||
|
%{ if vm_bios == "seabios" ~}
|
||||||
|
grub_device: true
|
||||||
|
%{ endif ~}
|
||||||
|
type: disk
|
||||||
|
id: disk-${device}
|
||||||
|
# BIOS boot partition
|
||||||
|
%{ for index, partition in partitions ~}
|
||||||
|
- device: disk-${device}
|
||||||
|
%{ if partition.size != -1 ~}
|
||||||
|
size: ${partition.size}M
|
||||||
|
%{ else ~}
|
||||||
|
size: ${partition.size}
|
||||||
|
%{ endif ~}
|
||||||
|
wipe: superblock
|
||||||
|
preserve: false
|
||||||
|
%{ if partition.name == "bios_grub" && vm_bios == "seabios" && index == 0 ~}
|
||||||
|
flag: bios_grub
|
||||||
|
grub_device: false
|
||||||
|
%{ endif ~}
|
||||||
|
%{ if partition.mount.path == "/boot/efi" && index == 0 ~}
|
||||||
|
flag: boot
|
||||||
|
grub_device: true
|
||||||
|
%{ endif ~}
|
||||||
|
type: partition
|
||||||
|
id: partition-${partition.name}
|
||||||
|
%{ if partition.format.fstype != "" ~}
|
||||||
|
- id: format-${partition.name}
|
||||||
|
type: format
|
||||||
|
volume: partition-${partition.name}
|
||||||
|
label: ${partition.format.label}
|
||||||
|
fstype: ${partition.format.fstype}
|
||||||
|
%{ endif ~}
|
||||||
|
# Don't create a mount for the GRUB partition when using BIOS
|
||||||
|
%{ if partition.volume_group == "" && partition.name != "bios_grub" ~}
|
||||||
|
- id: mount-${partition.name}
|
||||||
|
type: mount
|
||||||
|
%{ if partition.mount.path == "" ~}
|
||||||
|
path: none
|
||||||
|
%{ else ~}
|
||||||
|
path: ${partition.mount.path}
|
||||||
|
%{ endif ~}
|
||||||
|
device: format-${partition.name}
|
||||||
|
%{ if partition.mount.options != "" ~}
|
||||||
|
options: ${partition.mount.options}
|
||||||
|
%{ endif ~}
|
||||||
|
%{ endif ~}
|
||||||
|
%{ endfor ~}
|
||||||
|
%{ for index, volume_group in lvm ~}
|
||||||
|
- id: volgroup-${volume_group.name}
|
||||||
|
type: lvm_volgroup
|
||||||
|
name: ${volume_group.name}
|
||||||
|
devices:
|
||||||
|
%{ for index, partition in partitions ~}
|
||||||
|
%{ if lookup(partition, "volume_group", "") == volume_group.name ~}
|
||||||
|
- partition-${partition.name}
|
||||||
|
%{ endif ~}
|
||||||
|
%{ endfor ~}
|
||||||
|
%{ for index, partition in volume_group.partitions ~}
|
||||||
|
- id: partition-${partition.name}
|
||||||
|
type: lvm_partition
|
||||||
|
name: ${partition.name}
|
||||||
|
size: ${partition.size}M
|
||||||
|
volgroup: volgroup-${volume_group.name}
|
||||||
|
- id: format-${partition.name}
|
||||||
|
type: format
|
||||||
|
volume: partition-${partition.name}
|
||||||
|
label: ${partition.format.label}
|
||||||
|
fstype: ${partition.format.fstype}
|
||||||
|
- id: mount-${partition.name}
|
||||||
|
type: mount
|
||||||
|
%{ if partition.mount.path == "" ~}
|
||||||
|
path: none
|
||||||
|
%{ else ~}
|
||||||
|
path: ${partition.mount.path}
|
||||||
|
%{ endif ~}
|
||||||
|
device: format-${partition.name}
|
||||||
|
%{ if partition.mount.options != "" ~}
|
||||||
|
options: ${partition.mount.options}
|
||||||
|
%{ endif ~}
|
||||||
|
%{ endfor ~}
|
||||||
|
%{ endfor ~}
|
||||||
|
%{~ endif ~}
|
||||||
27
builds/linux/ubuntu/24-04-lts/data/user-data.pkrtpl.hcl
Normal file
27
builds/linux/ubuntu/24-04-lts/data/user-data.pkrtpl.hcl
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#cloud-config
|
||||||
|
autoinstall:
|
||||||
|
version: 1
|
||||||
|
early-commands:
|
||||||
|
- sudo systemctl stop ssh
|
||||||
|
locale: ${vm_os_language}
|
||||||
|
keyboard:
|
||||||
|
layout: ${vm_os_keyboard}
|
||||||
|
${storage}
|
||||||
|
identity:
|
||||||
|
hostname: ubuntu-server
|
||||||
|
username: ${build_username}
|
||||||
|
password: ${build_password_encrypted}
|
||||||
|
ssh:
|
||||||
|
install-server: true
|
||||||
|
allow-pw: true
|
||||||
|
packages:
|
||||||
|
- openssh-server
|
||||||
|
- qemu-guest-agent
|
||||||
|
- cloud-init
|
||||||
|
user-data:
|
||||||
|
disable_root: false
|
||||||
|
timezone: ${vm_os_timezone}
|
||||||
|
late-commands:
|
||||||
|
- sed -i -e 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config
|
||||||
|
- echo '${build_username} ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/${build_username}
|
||||||
|
- curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/${build_username}
|
||||||
45
builds/linux/ubuntu/24-04-lts/linux-ubuntu.auto.pkrvars.hcl
Normal file
45
builds/linux/ubuntu/24-04-lts/linux-ubuntu.auto.pkrvars.hcl
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
DESCRIPTION:
|
||||||
|
Ubuntu Server 24.04 LTS 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 = "ubuntu"
|
||||||
|
vm_os_version = "24.04-lts"
|
||||||
|
|
||||||
|
// Virtual Machine Guest Operating System Setting
|
||||||
|
vm_os_type = "l26"
|
||||||
|
|
||||||
|
// Virtual Machine Hardware Settings
|
||||||
|
vm_bios = "seabios"
|
||||||
|
vm_cpu_count = 1
|
||||||
|
vm_cpu_sockets = 1
|
||||||
|
vm_cpu_type = "kvm64"
|
||||||
|
vm_mem_size = 2048
|
||||||
|
vm_disk_type = "virtio"
|
||||||
|
vm_disk_size = "32G"
|
||||||
|
vm_disk_format = "raw"
|
||||||
|
vm_storage_pool = "vm-data"
|
||||||
|
vm_disk_controller_type = "virtio-scsi-pci"
|
||||||
|
vm_network_card_model = "virtio"
|
||||||
|
vm_bridge_interface = "vmbr0"
|
||||||
|
vm_vlan_tag = "102"
|
||||||
|
|
||||||
|
// Removable Media Settings
|
||||||
|
iso_path = "iso"
|
||||||
|
iso_file = "ubuntu-24.04-live-server-amd64.iso"
|
||||||
|
iso_checksum = "8762f7e74e4d64d72fceb5f70682e6b069932deedb4949c6975d0f0fe0a91be3"
|
||||||
|
|
||||||
|
// Boot Settings
|
||||||
|
vm_boot = "order=virtio0;ide2;net0"
|
||||||
|
vm_boot_wait = "5s"
|
||||||
|
|
||||||
|
// EFI Settings
|
||||||
|
vm_firmware_path = "./OVMF.fd"
|
||||||
|
vm_efi_storage_pool = "vm-data"
|
||||||
|
vm_efi_pre_enrolled_keys = false
|
||||||
|
vm_efi_type = "4m"
|
||||||
198
builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkr.hcl
Normal file
198
builds/linux/ubuntu/24-04-lts/linux-ubuntu.pkr.hcl
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
/*
|
||||||
|
DESCRIPTION:
|
||||||
|
Ubuntu Server 24.04 LTS 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 {
|
||||||
|
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_cloud_init_enable}"
|
||||||
|
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 = {
|
||||||
|
"/meta-data" = file("${abspath(path.root)}/data/meta-data")
|
||||||
|
"/user-data" = templatefile("${abspath(path.root)}/data/user-data.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
|
||||||
|
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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
data_source_command = var.common_data_source == "http" ? "ds=\"nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/\"" : "ds=\"nocloud\""
|
||||||
|
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||||
|
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||||
|
}
|
||||||
|
|
||||||
|
// BLOCK: source
|
||||||
|
// 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}"
|
||||||
|
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 = [
|
||||||
|
"c<wait5>",
|
||||||
|
"linux /casper/vmlinuz --- autoinstall ${local.data_source_command}",
|
||||||
|
"<enter><wait10>",
|
||||||
|
"initrd /casper/initrd",
|
||||||
|
"<enter><wait10>",
|
||||||
|
"boot",
|
||||||
|
"<enter>"
|
||||||
|
]
|
||||||
|
|
||||||
|
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_cloud_init_enable
|
||||||
|
cloud_init_storage_pool = var.vm_cloud_init_enable == true ? var.vm_storage_pool : null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build Definition to create the VM Template
|
||||||
|
build {
|
||||||
|
sources = ["source.proxmox-iso.ubuntu"]
|
||||||
|
|
||||||
|
provisioner "ansible" {
|
||||||
|
user = "${var.build_username}"
|
||||||
|
playbook_file = "${path.cwd}/ansible/main.yml"
|
||||||
|
roles_path = "${path.cwd}/ansible/roles"
|
||||||
|
ansible_env_vars = [
|
||||||
|
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg"
|
||||||
|
]
|
||||||
|
extra_arguments = [
|
||||||
|
"--extra-vars", "display_skipped_hosts=false",
|
||||||
|
"--extra-vars", "BUILD_USERNAME=${var.build_username}",
|
||||||
|
"--extra-vars", "BUILD_SECRET='${var.build_key}'",
|
||||||
|
"--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}",
|
||||||
|
"--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'",
|
||||||
|
"--extra-vars", "cloud_init='${var.vm_cloud_init_enable}'",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
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_cloud_init_enable = "${var.vm_cloud_init_enable}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
53
builds/linux/ubuntu/24-04-lts/variables-storage.pkr.hcl
Normal file
53
builds/linux/ubuntu/24-04-lts/variables-storage.pkr.hcl
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
DESCRIPTION:
|
||||||
|
Ubuntu Server 24.04 LTS 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 = []
|
||||||
|
}
|
||||||
297
builds/linux/ubuntu/24-04-lts/variables.pkr.hcl
Normal file
297
builds/linux/ubuntu/24-04-lts/variables.pkr.hcl
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
/*
|
||||||
|
DESCRIPTION:
|
||||||
|
Ubuntu Server 24.04 LTS 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')"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "vm_efi_type" {
|
||||||
|
type = string
|
||||||
|
description = "Specifies the version of the OVMF firmware to be used. (e.g. '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)"
|
||||||
|
}
|
||||||
|
|
||||||
|
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_cloud_init_enable" {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user