Improved on the post-install provisioning

This commit is contained in:
Gregory Ballantine 2024-04-21 01:54:33 -04:00
parent a051724f38
commit 4e00aa8ba7
11 changed files with 64 additions and 7 deletions

View File

@ -11,6 +11,7 @@ variable "proxmox_apitoken" {
source "proxmox-iso" "almalinux-9" { source "proxmox-iso" "almalinux-9" {
template_name = "almalinux-9" template_name = "almalinux-9"
template_description = "Almalinux 9.3, generated on ${timestamp()}" template_description = "Almalinux 9.3, generated on ${timestamp()}"
vm_id = "204"
boot_wait = "10s" boot_wait = "10s"
boot_key_interval = "200ms" boot_key_interval = "200ms"
boot_command = ["<tab><wait1s>", " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/almalinux-9-server.ks<enter><wait5m>"] boot_command = ["<tab><wait1s>", " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/almalinux-9-server.ks<enter><wait5m>"]
@ -40,6 +41,7 @@ source "proxmox-iso" "almalinux-9" {
username = "${var.proxmox_apiuser}" username = "${var.proxmox_apiuser}"
password = "${var.proxmox_apitoken}" password = "${var.proxmox_apitoken}"
node = "geonosis" node = "geonosis"
pool = "Templates"
iso_url = "https://repo.almalinux.org/almalinux/9.3/isos/x86_64/AlmaLinux-9.3-x86_64-boot.iso" iso_url = "https://repo.almalinux.org/almalinux/9.3/isos/x86_64/AlmaLinux-9.3-x86_64-boot.iso"
iso_checksum = "sha256:af5377a1d16bbe599ea91a8761ad645f2f54687075802bdc0c0703ee610182e9" iso_checksum = "sha256:af5377a1d16bbe599ea91a8761ad645f2f54687075802bdc0c0703ee610182e9"
@ -54,4 +56,8 @@ source "proxmox-iso" "almalinux-9" {
build { build {
sources = ["source.proxmox-iso.almalinux-9"] sources = ["source.proxmox-iso.almalinux-9"]
provisioner "shell" {
script = "scripts/rhel-setup.sh"
}
} }

View File

@ -11,9 +11,10 @@ variable "proxmox_apitoken" {
source "proxmox-iso" "debian-12" { source "proxmox-iso" "debian-12" {
template_name = "debian-12" template_name = "debian-12"
template_description = "Debian 12.5, generated on ${timestamp()}" template_description = "Debian 12.5, generated on ${timestamp()}"
vm_id = "203"
boot_wait = "10s" boot_wait = "10s"
boot_key_interval = "200ms" boot_key_interval = "200ms"
boot_command = ["<esc><wait1s>", "auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian.cfg", "<enter><wait6m>"] boot_command = ["<esc><wait1s>", "auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian.cfg", "<enter><wait>"]
http_directory = "http" http_directory = "http"
http_port_max = "8089" http_port_max = "8089"
@ -40,6 +41,7 @@ source "proxmox-iso" "debian-12" {
username = "${var.proxmox_apiuser}" username = "${var.proxmox_apiuser}"
password = "${var.proxmox_apitoken}" password = "${var.proxmox_apitoken}"
node = "geonosis" node = "geonosis"
pool = "Templates"
iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso" iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso"
iso_checksum = "sha256:013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f" iso_checksum = "sha256:013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f"
@ -54,4 +56,8 @@ source "proxmox-iso" "debian-12" {
build { build {
sources = ["source.proxmox-iso.debian-12"] sources = ["source.proxmox-iso.debian-12"]
provisioner "shell" {
script = "scripts/debian-setup.sh"
}
} }

View File

@ -11,9 +11,10 @@ variable "proxmox_apitoken" {
source "proxmox-iso" "freebsd-14" { source "proxmox-iso" "freebsd-14" {
template_name = "freebsd-14" template_name = "freebsd-14"
template_description = "FreeBSD 14.0, generated on ${timestamp()}" template_description = "FreeBSD 14.0, generated on ${timestamp()}"
vm_id = "202"
boot_wait = "10s" boot_wait = "10s"
boot_key_interval = "200ms" boot_key_interval = "200ms"
boot_command = ["<enter>", "<wait15s>", "<enter><wait1s>", "<enter><wait1s>", "freebsd", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait5s>", "<right><enter><wait1s>", "<enter><wait1s>", "<enter><wait4s>", "<enter><wait1s>", "<enter><wait1s>", " <enter><wait1s>", "<left><enter><wait1s>", "<enter><wait75s>", "packer<enter><wait1s>", "packer<enter><wait1s>", "<down><enter><wait1s>", "95<up><enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<down><down><down> <enter><wait1s>", "<down><down><down><down><down><down><down><down> <enter><wait1s>", "<enter><wait1s>", "xadmin<enter>", "Remote admin user<enter>", "<enter>", "<enter>", "wheel<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "packer<enter>", "packer<enter>", "<enter>", "<enter>", "<enter><wait1s>", "<enter><wait1s>", "<left><enter><wait1s>", "pkg update && pkg install -y sudo qemu-guest-agent<enter><wait3s>", "y<enter><wait40s>", "echo '%wheel ALL=(ALL:ALL) ALL' > /usr/local/etc/sudoers.d/wheel<enter><wait1s>", "echo 'qemu_guest_agent_enable=\"YES\"' >> /etc/rc.conf<enter><wait1s>", "exit<enter><wait1s>", "<enter><wait40s>"] boot_command = ["<enter>", "<wait15s>", "<enter><wait1s>", "<enter><wait1s>", "freebsd", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait5s>", "<right><enter><wait1s>", "<enter><wait1s>", "<enter><wait4s>", "<enter><wait1s>", "<enter><wait1s>", " <enter><wait1s>", "<left><enter><wait1s>", "<enter><wait75s>", "packer<enter><wait1s>", "packer<enter><wait1s>", "<down><enter><wait1s>", "95<up><enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<enter><wait1s>", "<down><down><down> <enter><wait1s>", "<down><down><down><down><down><down><down><down> <enter><wait1s>", "<enter><wait1s>", "xadmin<enter>", "Remote admin user<enter>", "<enter>", "<enter>", "wheel<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "<enter>", "packer<enter>", "packer<enter>", "<enter>", "<enter>", "<enter><wait1s>", "<enter><wait1s>", "<left><enter><wait1s>", "pkg update && pkg install -y bash sudo qemu-guest-agent<enter><wait3s>", "y<enter><wait40s>", "echo 'xadmin ALL=(ALL:ALL) NOPASSWD:ALL' > /usr/local/etc/sudoers.d/xadmin<enter><wait1s>", "echo 'qemu_guest_agent_enable=\"YES\"' >> /etc/rc.conf<enter><wait1s>", "exit<enter><wait1s>", "<enter><wait40s>"]
os = "other" os = "other"
cores = "2" cores = "2"
@ -36,6 +37,7 @@ source "proxmox-iso" "freebsd-14" {
username = "${var.proxmox_apiuser}" username = "${var.proxmox_apiuser}"
password = "${var.proxmox_apitoken}" password = "${var.proxmox_apitoken}"
node = "geonosis" 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_url = "https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/14.0/FreeBSD-14.0-RELEASE-amd64-bootonly.iso"
iso_checksum = "sha256:71db8160a2339634bd9fbabbf10dd868148ebc9e1b08c1d8c4e5b954d30941ec" iso_checksum = "sha256:71db8160a2339634bd9fbabbf10dd868148ebc9e1b08c1d8c4e5b954d30941ec"
@ -50,4 +52,8 @@ source "proxmox-iso" "freebsd-14" {
build { build {
sources = ["source.proxmox-iso.freebsd-14"] sources = ["source.proxmox-iso.freebsd-14"]
provisioner "shell" {
script = "scripts/freebsd-setup.sh"
}
} }

View File

@ -11,6 +11,7 @@ variable "proxmox_apitoken" {
source "proxmox-iso" "rocky-9" { source "proxmox-iso" "rocky-9" {
template_name = "rocky-9" template_name = "rocky-9"
template_description = "Rocky Linux 9.3, generated on ${timestamp()}" template_description = "Rocky Linux 9.3, generated on ${timestamp()}"
vm_id = "201"
boot_wait = "10s" boot_wait = "10s"
boot_key_interval = "200ms" boot_key_interval = "200ms"
boot_command = ["<tab><wait1s>", " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rocky-9-server.ks<enter><wait5m>"] boot_command = ["<tab><wait1s>", " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rocky-9-server.ks<enter><wait5m>"]
@ -40,6 +41,7 @@ source "proxmox-iso" "rocky-9" {
username = "${var.proxmox_apiuser}" username = "${var.proxmox_apiuser}"
password = "${var.proxmox_apitoken}" password = "${var.proxmox_apitoken}"
node = "geonosis" node = "geonosis"
pool = "Templates"
iso_url = "https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-9.3-x86_64-boot.iso" iso_url = "https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-9.3-x86_64-boot.iso"
iso_checksum = "sha256:eb096f0518e310f722d5ebd4c69f0322df4fc152c6189f93c5c797dc25f3d2e1" iso_checksum = "sha256:eb096f0518e310f722d5ebd4c69f0322df4fc152c6189f93c5c797dc25f3d2e1"
@ -54,4 +56,8 @@ source "proxmox-iso" "rocky-9" {
build { build {
sources = ["source.proxmox-iso.rocky-9"] sources = ["source.proxmox-iso.rocky-9"]
provisioner "shell" {
script = "scripts/rhel-setup.sh"
}
} }

View File

@ -10,7 +10,8 @@ variable "proxmox_apitoken" {
source "proxmox-iso" "ubuntu-22" { source "proxmox-iso" "ubuntu-22" {
template_name = "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_wait = "10s"
boot_key_interval = "200ms" boot_key_interval = "200ms"
boot_command = [ boot_command = [
@ -53,7 +54,8 @@ source "proxmox-iso" "ubuntu-22" {
insecure_skip_tls_verify = true insecure_skip_tls_verify = true
username = "${var.proxmox_apiuser}" username = "${var.proxmox_apiuser}"
password = "${var.proxmox_apitoken}" 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_url = "https://releases.ubuntu.com/22.04.4/ubuntu-22.04.4-live-server-amd64.iso"
iso_checksum = "sha256:45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2" iso_checksum = "sha256:45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2"
@ -68,4 +70,8 @@ source "proxmox-iso" "ubuntu-22" {
build { build {
sources = ["source.proxmox-iso.ubuntu-22"] sources = ["source.proxmox-iso.ubuntu-22"]
provisioner "shell" {
script = "scripts/debian-setup.sh"
}
} }

View File

@ -40,6 +40,7 @@ reboot --eject
%packages %packages
@base @base
@core @core
bash
nfs-utils nfs-utils
sudo sudo
@ -53,7 +54,7 @@ dnf -y install epel-release
dnf -y install wget vim yum-plugin-versionlock qemu-guest-agent 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 systemctl enable qemu-guest-agent

View File

@ -135,6 +135,7 @@ tasksel tasksel/first multiselect standard
# Individual additional packages to install # Individual additional packages to install
d-i pkgsel/include string \ d-i pkgsel/include string \
apt-transport-https \ apt-transport-https \
bash \
curl \ curl \
dnsutils \ dnsutils \
openssh-server \ openssh-server \
@ -158,4 +159,5 @@ d-i finish-install/reboot_in_progress note
#d-i preseed/early_command string anna-install some-udeb #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. # 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 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;

View File

@ -40,6 +40,7 @@ reboot --eject
%packages %packages
@base @base
@core @core
bash
nfs-utils nfs-utils
sudo sudo
@ -53,7 +54,7 @@ dnf -y install epel-release
dnf -y install wget vim yum-plugin-versionlock qemu-guest-agent 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 systemctl enable qemu-guest-agent

9
scripts/debian-setup.sh Normal file
View File

@ -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

7
scripts/freebsd-setup.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# FreeBSD steps
sudo pkg update
sudo pkg upgrade -y
sudo pkg install -y vim py39-salt

7
scripts/rhel-setup.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
sudo dnf update -y
sudo dnf install -y vim
wget -O - https://bootstrap.saltstack.com | sudo sh