From 4e00aa8ba7071b286a521fc721a8631c56f09866 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Sun, 21 Apr 2024 01:54:33 -0400 Subject: [PATCH] Improved on the post-install provisioning --- Almalinux-9/almalinux-9.pkr.hcl | 6 ++++++ Debian-12/debian-12.pkr.hcl | 8 +++++++- FreeBSD-14/freebsd-14.pkr.hcl | 8 +++++++- Rocky-9/rocky-9.pkr.hcl | 6 ++++++ Ubuntu-22/ubuntu-22.pkr.hcl | 10 ++++++++-- http/almalinux-9-server.ks | 3 ++- http/debian.cfg | 4 +++- http/rocky-9-server.ks | 3 ++- scripts/debian-setup.sh | 9 +++++++++ scripts/freebsd-setup.sh | 7 +++++++ scripts/rhel-setup.sh | 7 +++++++ 11 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 scripts/debian-setup.sh create mode 100644 scripts/freebsd-setup.sh create mode 100644 scripts/rhel-setup.sh diff --git a/Almalinux-9/almalinux-9.pkr.hcl b/Almalinux-9/almalinux-9.pkr.hcl index 3e417ce..faf5304 100644 --- a/Almalinux-9/almalinux-9.pkr.hcl +++ b/Almalinux-9/almalinux-9.pkr.hcl @@ -11,6 +11,7 @@ variable "proxmox_apitoken" { source "proxmox-iso" "almalinux-9" { template_name = "almalinux-9" template_description = "Almalinux 9.3, generated on ${timestamp()}" + vm_id = "204" boot_wait = "10s" boot_key_interval = "200ms" boot_command = ["", " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/almalinux-9-server.ks"] @@ -40,6 +41,7 @@ source "proxmox-iso" "almalinux-9" { username = "${var.proxmox_apiuser}" password = "${var.proxmox_apitoken}" node = "geonosis" + pool = "Templates" iso_url = "https://repo.almalinux.org/almalinux/9.3/isos/x86_64/AlmaLinux-9.3-x86_64-boot.iso" iso_checksum = "sha256:af5377a1d16bbe599ea91a8761ad645f2f54687075802bdc0c0703ee610182e9" @@ -54,4 +56,8 @@ source "proxmox-iso" "almalinux-9" { build { sources = ["source.proxmox-iso.almalinux-9"] + + provisioner "shell" { + script = "scripts/rhel-setup.sh" + } } diff --git a/Debian-12/debian-12.pkr.hcl b/Debian-12/debian-12.pkr.hcl index f344f59..8b7a327 100644 --- a/Debian-12/debian-12.pkr.hcl +++ b/Debian-12/debian-12.pkr.hcl @@ -11,9 +11,10 @@ variable "proxmox_apitoken" { source "proxmox-iso" "debian-12" { template_name = "debian-12" template_description = "Debian 12.5, generated on ${timestamp()}" + vm_id = "203" boot_wait = "10s" boot_key_interval = "200ms" - boot_command = ["", "auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian.cfg", ""] + boot_command = ["", "auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian.cfg", ""] http_directory = "http" http_port_max = "8089" @@ -40,6 +41,7 @@ source "proxmox-iso" "debian-12" { username = "${var.proxmox_apiuser}" password = "${var.proxmox_apitoken}" node = "geonosis" + pool = "Templates" iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso" iso_checksum = "sha256:013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f" @@ -54,4 +56,8 @@ source "proxmox-iso" "debian-12" { build { sources = ["source.proxmox-iso.debian-12"] + + provisioner "shell" { + script = "scripts/debian-setup.sh" + } } diff --git a/FreeBSD-14/freebsd-14.pkr.hcl b/FreeBSD-14/freebsd-14.pkr.hcl index 634bc22..463b42f 100644 --- a/FreeBSD-14/freebsd-14.pkr.hcl +++ b/FreeBSD-14/freebsd-14.pkr.hcl @@ -11,9 +11,10 @@ variable "proxmox_apitoken" { source "proxmox-iso" "freebsd-14" { template_name = "freebsd-14" template_description = "FreeBSD 14.0, generated on ${timestamp()}" + vm_id = "202" boot_wait = "10s" boot_key_interval = "200ms" - boot_command = ["", "", "", "", "freebsd", "", "", "", "", "", "", "", "", "", "", "", " ", "", "", "packer", "packer", "", "95", "", "", "", "", " ", " ", "", "xadmin", "Remote admin user", "", "", "wheel", "", "", "", "", "", "", "", "packer", "packer", "", "", "", "", "", "pkg update && pkg install -y sudo qemu-guest-agent", "y", "echo '%wheel ALL=(ALL:ALL) ALL' > /usr/local/etc/sudoers.d/wheel", "echo 'qemu_guest_agent_enable=\"YES\"' >> /etc/rc.conf", "exit", ""] + boot_command = ["", "", "", "", "freebsd", "", "", "", "", "", "", "", "", "", "", "", " ", "", "", "packer", "packer", "", "95", "", "", "", "", " ", " ", "", "xadmin", "Remote admin user", "", "", "wheel", "", "", "", "", "", "", "", "packer", "packer", "", "", "", "", "", "pkg update && pkg install -y bash sudo qemu-guest-agent", "y", "echo 'xadmin ALL=(ALL:ALL) NOPASSWD:ALL' > /usr/local/etc/sudoers.d/xadmin", "echo 'qemu_guest_agent_enable=\"YES\"' >> /etc/rc.conf", "exit", ""] os = "other" cores = "2" @@ -36,6 +37,7 @@ source "proxmox-iso" "freebsd-14" { username = "${var.proxmox_apiuser}" password = "${var.proxmox_apitoken}" node = "geonosis" + pool = "Templates" iso_url = "https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/14.0/FreeBSD-14.0-RELEASE-amd64-bootonly.iso" iso_checksum = "sha256:71db8160a2339634bd9fbabbf10dd868148ebc9e1b08c1d8c4e5b954d30941ec" @@ -50,4 +52,8 @@ source "proxmox-iso" "freebsd-14" { build { sources = ["source.proxmox-iso.freebsd-14"] + + provisioner "shell" { + script = "scripts/freebsd-setup.sh" + } } diff --git a/Rocky-9/rocky-9.pkr.hcl b/Rocky-9/rocky-9.pkr.hcl index 4130664..7c0ac8c 100644 --- a/Rocky-9/rocky-9.pkr.hcl +++ b/Rocky-9/rocky-9.pkr.hcl @@ -11,6 +11,7 @@ variable "proxmox_apitoken" { source "proxmox-iso" "rocky-9" { template_name = "rocky-9" template_description = "Rocky Linux 9.3, generated on ${timestamp()}" + vm_id = "201" boot_wait = "10s" boot_key_interval = "200ms" boot_command = ["", " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rocky-9-server.ks"] @@ -40,6 +41,7 @@ source "proxmox-iso" "rocky-9" { username = "${var.proxmox_apiuser}" password = "${var.proxmox_apitoken}" node = "geonosis" + pool = "Templates" iso_url = "https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-9.3-x86_64-boot.iso" iso_checksum = "sha256:eb096f0518e310f722d5ebd4c69f0322df4fc152c6189f93c5c797dc25f3d2e1" @@ -54,4 +56,8 @@ source "proxmox-iso" "rocky-9" { build { sources = ["source.proxmox-iso.rocky-9"] + + provisioner "shell" { + script = "scripts/rhel-setup.sh" + } } diff --git a/Ubuntu-22/ubuntu-22.pkr.hcl b/Ubuntu-22/ubuntu-22.pkr.hcl index 0915c4f..2c74668 100644 --- a/Ubuntu-22/ubuntu-22.pkr.hcl +++ b/Ubuntu-22/ubuntu-22.pkr.hcl @@ -10,7 +10,8 @@ variable "proxmox_apitoken" { source "proxmox-iso" "ubuntu-22" { template_name = "ubuntu-22" - template_description = "Rocky Linux 9.3, generated on ${timestamp()}" + template_description = "Ubuntu 22.04, generated on ${timestamp()}" + vm_id = "205" boot_wait = "10s" boot_key_interval = "200ms" boot_command = [ @@ -53,7 +54,8 @@ source "proxmox-iso" "ubuntu-22" { insecure_skip_tls_verify = true username = "${var.proxmox_apiuser}" password = "${var.proxmox_apitoken}" - node = "kamino" + node = "geonosis" + pool = "Templates" iso_url = "https://releases.ubuntu.com/22.04.4/ubuntu-22.04.4-live-server-amd64.iso" iso_checksum = "sha256:45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2" @@ -68,4 +70,8 @@ source "proxmox-iso" "ubuntu-22" { build { sources = ["source.proxmox-iso.ubuntu-22"] + + provisioner "shell" { + script = "scripts/debian-setup.sh" + } } diff --git a/http/almalinux-9-server.ks b/http/almalinux-9-server.ks index 1fc5416..4ee0b9d 100644 --- a/http/almalinux-9-server.ks +++ b/http/almalinux-9-server.ks @@ -40,6 +40,7 @@ reboot --eject %packages @base @core +bash nfs-utils sudo @@ -53,7 +54,7 @@ dnf -y install epel-release dnf -y install wget vim yum-plugin-versionlock qemu-guest-agent -usermod -aG wheel xadmin +echo 'xadmin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/xadmin systemctl enable qemu-guest-agent diff --git a/http/debian.cfg b/http/debian.cfg index 9c98cd0..a41e666 100644 --- a/http/debian.cfg +++ b/http/debian.cfg @@ -135,6 +135,7 @@ tasksel tasksel/first multiselect standard # Individual additional packages to install d-i pkgsel/include string \ apt-transport-https \ +bash \ curl \ dnsutils \ openssh-server \ @@ -158,4 +159,5 @@ d-i finish-install/reboot_in_progress note #d-i preseed/early_command string anna-install some-udeb # This command is run just before the install finishes, but when there is still a usable /target directory. #d-i preseed/late_command string in-target wget -O /root/post-install.sh http://tarsonis.metaunix.net/scripts/post-install.sh; in-target chmod +x /root/post-install.sh; in-target /root/post-install.sh -d-i preseed/late_command string in-target usermod -aG sudo xadmin; in-target systemctl enable qemu-guest-agent +d-i preseed/late_command string in-target systemctl enable qemu-guest-agent; \ +echo 'xadmin ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/xadmin; diff --git a/http/rocky-9-server.ks b/http/rocky-9-server.ks index 1fc5416..4ee0b9d 100644 --- a/http/rocky-9-server.ks +++ b/http/rocky-9-server.ks @@ -40,6 +40,7 @@ reboot --eject %packages @base @core +bash nfs-utils sudo @@ -53,7 +54,7 @@ dnf -y install epel-release dnf -y install wget vim yum-plugin-versionlock qemu-guest-agent -usermod -aG wheel xadmin +echo 'xadmin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/xadmin systemctl enable qemu-guest-agent diff --git a/scripts/debian-setup.sh b/scripts/debian-setup.sh new file mode 100644 index 0000000..27e3933 --- /dev/null +++ b/scripts/debian-setup.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Debian/Ubuntu steps +sudo apt update +sudo apt upgrade -y + +sudo apt install -y vim + +wget -O - https://bootstrap.saltstack.com | sudo sh diff --git a/scripts/freebsd-setup.sh b/scripts/freebsd-setup.sh new file mode 100644 index 0000000..655c251 --- /dev/null +++ b/scripts/freebsd-setup.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# FreeBSD steps +sudo pkg update +sudo pkg upgrade -y + +sudo pkg install -y vim py39-salt diff --git a/scripts/rhel-setup.sh b/scripts/rhel-setup.sh new file mode 100644 index 0000000..129c39a --- /dev/null +++ b/scripts/rhel-setup.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +sudo dnf update -y + +sudo dnf install -y vim + +wget -O - https://bootstrap.saltstack.com | sudo sh