From 1959a667d42c52fee9eae02466afe3b2622c2549 Mon Sep 17 00:00:00 2001 From: rblundon Date: Tue, 16 Sep 2025 21:55:49 -0500 Subject: [PATCH] create ubuntu small packer config --- ansible/playbooks/deploy-fastpass-4step.yml | 1 + .../templates/kubernetes.repo.j2 | 1 + .../04-vm-templates/ubuntu-24.04.03/LICENSE | 21 +++ .../fedora-42-large-plus.pkrvars.hcl | 28 ++++ .../fedora-42-large.pkrvars.hcl | 28 ++++ .../fedora-42-medium.pkrvars.hcl | 28 ++++ .../fedora-42-xlarge-plus.pkrvars.hcl | 28 ++++ .../fedora-42-xlarge.pkrvars.hcl | 28 ++++ .../ubuntu-24.04.03/files/99-pve.cfg | 1 + .../ubuntu-24.04.03/files/ansible.pub | 1 + .../ubuntu-24.04.03/http/ks.cfg | 74 +++++++++ .../ubuntu-24.04.03/http/meta-data | 0 .../ubuntu-24.04.03/http/user-data | 30 ++++ .../ubuntu-24.04.03/proxmox.pkvars.hcl | 15 ++ .../ubuntu-24.04.03/scripts/cleanup.sh | 12 ++ .../ubuntu-24.04.03/scripts/setup.yml | 51 +++++++ .../ubuntu-24.04.03/ubuntu-24.04.hcl | 133 ++++++++++++++++ .../ubuntu-24.04.03/ubuntu-small.pkrvars.hcl | 27 ++++ .../ubuntu-24.04.03/variables.pkr.hcl | 144 ++++++++++++++++++ .../variables.pkrvars-xlarge.hcl | 35 +++++ 20 files changed, 686 insertions(+) create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/LICENSE create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large-plus.pkrvars.hcl create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large.pkrvars.hcl create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-medium.pkrvars.hcl create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge-plus.pkrvars.hcl create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge.pkrvars.hcl create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/files/99-pve.cfg create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/files/ansible.pub create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/http/ks.cfg create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/http/meta-data create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/http/user-data create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/proxmox.pkvars.hcl create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/scripts/cleanup.sh create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/scripts/setup.yml create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-24.04.hcl create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-small.pkrvars.hcl create mode 100644 infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkr.hcl create mode 100755 infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkrvars-xlarge.hcl diff --git a/ansible/playbooks/deploy-fastpass-4step.yml b/ansible/playbooks/deploy-fastpass-4step.yml index 4e2d10e..5ff3528 100644 --- a/ansible/playbooks/deploy-fastpass-4step.yml +++ b/ansible/playbooks/deploy-fastpass-4step.yml @@ -42,3 +42,4 @@ ansible.builtin.command: kubectl get pods -A delegate_to: localhost + diff --git a/ansible/playbooks/roles/kubernetes-prerequisites/templates/kubernetes.repo.j2 b/ansible/playbooks/roles/kubernetes-prerequisites/templates/kubernetes.repo.j2 index ab9b7ee..e3f9280 100644 --- a/ansible/playbooks/roles/kubernetes-prerequisites/templates/kubernetes.repo.j2 +++ b/ansible/playbooks/roles/kubernetes-prerequisites/templates/kubernetes.repo.j2 @@ -5,3 +5,4 @@ enabled=1 gpgcheck=1 gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version | default('1.33') | regex_replace('^v?(.*)$', '\\1') | regex_replace('^(\\d+\\.\\d+).*$', '\\1') }}/rpm/repodata/repomd.xml.key + diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/LICENSE b/infra-config/04-vm-templates/ubuntu-24.04.03/LICENSE new file mode 100644 index 0000000..c3c2cb7 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 eaksel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large-plus.pkrvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large-plus.pkrvars.hcl new file mode 100755 index 0000000..3d63aa9 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large-plus.pkrvars.hcl @@ -0,0 +1,28 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "fedora-42-large-plus" +vm_id = "9104" +vm_cpu_sockets = "1" +vm_cpu_cores = "4" +vm_mem_size = "4096" +vm_disk_size = "48" + +proxmox_bridge = "vmbr0" +#proxmox_vlan = "71" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "Fedora-Server-netinst-x86_64-42-1.1.iso" +iso_checksum = "231f3e0d1dc8f565c01a9f641b3d16c49cae44530074bc2047fe2373a721c82f" +iso_checksum_type = "sha256" + +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large.pkrvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large.pkrvars.hcl new file mode 100755 index 0000000..3eb23e2 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-large.pkrvars.hcl @@ -0,0 +1,28 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "fedora-42-large" +vm_id = "9103" +vm_cpu_sockets = "1" +vm_cpu_cores = "4" +vm_mem_size = "4096" +vm_disk_size = "32" + +proxmox_bridge = "vmbr0" +#proxmox_vlan = "71" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "Fedora-Server-netinst-x86_64-42-1.1.iso" +iso_checksum = "231f3e0d1dc8f565c01a9f641b3d16c49cae44530074bc2047fe2373a721c82f" +iso_checksum_type = "sha256" + +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-medium.pkrvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-medium.pkrvars.hcl new file mode 100755 index 0000000..dfbc5e2 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-medium.pkrvars.hcl @@ -0,0 +1,28 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "fedora-42-medium" +vm_id = "9102" +vm_cpu_sockets = "1" +vm_cpu_cores = "2" +vm_mem_size = "4096" +vm_disk_size = "16" + +proxmox_bridge = "vmbr0" +#proxmox_vlan = "71" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "Fedora-Server-netinst-x86_64-42-1.1.iso" +iso_checksum = "231f3e0d1dc8f565c01a9f641b3d16c49cae44530074bc2047fe2373a721c82f" +iso_checksum_type = "sha256" + +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge-plus.pkrvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge-plus.pkrvars.hcl new file mode 100755 index 0000000..928f26a --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge-plus.pkrvars.hcl @@ -0,0 +1,28 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "fedora-42-xlarge-plus" +vm_id = "9106" +vm_cpu_sockets = "1" +vm_cpu_cores = "4" +vm_mem_size = "8192" +vm_disk_size = "128" + +proxmox_bridge = "vmbr0" +#proxmox_vlan = "71" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "Fedora-Server-netinst-x86_64-42-1.1.iso" +iso_checksum = "231f3e0d1dc8f565c01a9f641b3d16c49cae44530074bc2047fe2373a721c82f" +iso_checksum_type = "sha256" + +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge.pkrvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge.pkrvars.hcl new file mode 100755 index 0000000..d1ebd2f --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/fedora-42-xlarge.pkrvars.hcl @@ -0,0 +1,28 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "fedora-42-xlarge" +vm_id = "9105" +vm_cpu_sockets = "1" +vm_cpu_cores = "4" +vm_mem_size = "8192" +vm_disk_size = "64" + +proxmox_bridge = "vmbr0" +#proxmox_vlan = "71" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "Fedora-Server-netinst-x86_64-42-1.1.iso" +iso_checksum = "231f3e0d1dc8f565c01a9f641b3d16c49cae44530074bc2047fe2373a721c82f" +iso_checksum_type = "sha256" + +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/files/99-pve.cfg b/infra-config/04-vm-templates/ubuntu-24.04.03/files/99-pve.cfg new file mode 100644 index 0000000..a78672c --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/files/99-pve.cfg @@ -0,0 +1 @@ +datasource_list: [ConfigDrive, NoCloud] \ No newline at end of file diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/files/ansible.pub b/infra-config/04-vm-templates/ubuntu-24.04.03/files/ansible.pub new file mode 100644 index 0000000..1586a14 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/files/ansible.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINnSM/9fO8rz/amqkyoGUzUKNNzzmtSXPwOCr1O9zKNO ansible diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/http/ks.cfg b/infra-config/04-vm-templates/ubuntu-24.04.03/http/ks.cfg new file mode 100644 index 0000000..37ed7a0 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/http/ks.cfg @@ -0,0 +1,74 @@ +# Kickstart file for Fedora 41 Server (Text-based Installation) +# +# For use with the Fedora Server netinstall ISO. +# Boot the installer with: +# linux /isolinux/vmlinuz inst.ks=http:////ks.cfg +# +# For a local file on a USB drive, you can use: +# linux /isolinux/vmlinuz inst.ks=hd:LABEL=:/ks.cfg + +# Use text mode install +text + +# Disable Initial Setup on first boot +firstboot --disable + +# Keyboard layout +keyboard --vckeymap=us --xlayouts='us' + +# System language +lang en_US.UTF-8 + +# Installation source +url --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-42&arch=x86_64 + + +# Network information +network --bootproto=dhcp --device=link --activate +network --hostname=fedora.localdomain + +# Root password +rootpw $5$CXpezfLKTajPP7yI$VM8STd3QaHBTKMe2DLTmK5p.lEGbUYYZV8jGG3nxX2/ --iscrypted + +# SELinux configuration +selinux --enforcing + +# Do not configure the X Window System +skipx + +# System timezone +timezone US/Chicago --utc + +# Add a user named wed +user --groups=wheel --name=wed --password=$5$UOpZHG55fWCHlNSp$nFnpaVLb9enbQTebHo4SKBqolGr39SMYo2ZshHCe2d3 --iscrypted --gecos="wed" + +# System bootloader configuration +bootloader --location=mbr --append="crashkernel=auto" + +# Clear the Master Boot Record +zerombr + +# Remove partitions +clearpart --all --initlabel + +# Automatically create partitions using LVM +autopart --type=lvm + +# Reboot after successful installation +reboot + +%packages --ignoremissing +qemu-guest-agent +python3-libdnf5 +#Make sure that this package gets installed because if you use DHCP this is how Promxox and then Packer will know the IP address to connect to +#@^Infrastructure Server +%end + +%post --nochroot --logfile=/mnt/sysimage/root/ks-post.log +# Disable quiet boot and splash screen +sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/etc/default/grub +sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/boot/grub2/grubenv + +# Passwordless sudo for the user 'wed' +echo "wed ALL=(ALL) NOPASSWD: ALL" >> /mnt/sysimage/etc/sudoers.d/wed +%end diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/http/meta-data b/infra-config/04-vm-templates/ubuntu-24.04.03/http/meta-data new file mode 100644 index 0000000..e69de29 diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/http/user-data b/infra-config/04-vm-templates/ubuntu-24.04.03/http/user-data new file mode 100644 index 0000000..a0552b4 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/http/user-data @@ -0,0 +1,30 @@ +#cloud-config +autoinstall: + version: 1 + locale: en_US + keyboard: + layout: us + ssh: + install-server: true + allow-pw: true + disable_root: true + ssh_quiet_keygen: true + allow_public_ssh_keys: true + packages: + - qemu-guest-agent + - sudo + storage: + layout: + name: direct + swap: + size: 0 + user-data: + package_upgrade: false + timezone: America/Chicago + users: + - name: wed + # passwd: "$6$rounds=4096$4SY5kMDOITTy3R6s$vgp01IwfMWJRYxY1pa.D6xS.TEzGkMpVqxZtxPQrYuHzvywq2sSw/Z.yEmG3hsWnERCorBbN7tdMttVTcj4u61" + groups: [adm, sudo] + lock-passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash \ No newline at end of file diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/proxmox.pkvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/proxmox.pkvars.hcl new file mode 100644 index 0000000..b109202 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/proxmox.pkvars.hcl @@ -0,0 +1,15 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Credentials + +proxmox_username = "root@pam" +ssh_username = "wed" + +# Proxmox Objects +proxmox_node = "fantasyland" +proxmox_domain = "local.mk-labs.cloud" +proxmox_vm_storage_pool = "templates" +#proxmox_insecure_connection = false # Default: true +proxmox_iso_storage_pool = "local" diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/scripts/cleanup.sh b/infra-config/04-vm-templates/ubuntu-24.04.03/scripts/cleanup.sh new file mode 100644 index 0000000..050e71b --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/scripts/cleanup.sh @@ -0,0 +1,12 @@ +#!/bin/bash -eux + +pip uninstall -y ansible + +dnf clean all + +# Zero out the rest of the free space using dd, then delete the written file. +#dd if=/dev/zero of=/EMPTY bs=1M +#rm -f /EMPTY + +# Add `sync` so Packer doesn't quit too early, before the large file is deleted. +sync diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/scripts/setup.yml b/infra-config/04-vm-templates/ubuntu-24.04.03/scripts/setup.yml new file mode 100644 index 0000000..a4a7df0 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/scripts/setup.yml @@ -0,0 +1,51 @@ +--- +- name: "Setup.yml" + hosts: localhost + gather_facts: yes + become: yes + tasks: + - name: Colorize root shell prompt + lineinfile: + path: /root/.bashrc + line: 'export PS1="\[\033[38;5;11m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h:\[$(tput sgr0)\]\[\033[38;5;6m\][\w]:\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"' + state: present + + - name: Alias vi to vim + lineinfile: + path: /root/.bashrc + line: "alias vi='vim'" + state: present + + - name: Create vim configuration file + file: + path: /root/.vimrc + state: touch + owner: root + group: root + mode: 0644 + + - name: Configure vim + blockinfile: + path: /root/.vimrc + block: | + set nocompatible + set number + set autoindent + syntax on + highlight Comment ctermfg=LightCyan + marker: "" + state: present + + - name: Disable GSSAPIAuthentication + lineinfile: + path: /etc/ssh/sshd_config + regexp: "^GSSAPIAuthentication" + line: "GSSAPIAuthentication no" + state: present + + - name: Update CA bundle (RedHat) + get_url: + url: https://curl.haxx.se/ca/cacert.pem + dest: /etc/pki/tls/certs/ca-bundle.crt + force: yes + when: ansible_os_family == "RedHat" diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-24.04.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-24.04.hcl new file mode 100755 index 0000000..ff88fec --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-24.04.hcl @@ -0,0 +1,133 @@ +################################################################################## +# LOCALS +################################################################################## + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +packer { + required_plugins { +# ansible = { +# version = ">= 1.1.3" +# source = "github.com/hashicorp/ansible" +# } + name = { + version = "~> 1" + source = "github.com/hashicorp/proxmox" + } + } +} + +################################################################################## +# SOURCE +################################################################################## + +source "proxmox-iso" "ubuntu-24.04.03" { + boot_iso { + type = "scsi" + iso_file = "${var.proxmox_iso_storage_pool}:iso/${var.iso_file}" + unmount = true + #iso_checksum = "sha512:33c08e56c83d13007e4a5511b9bf2c4926c4aa12fd5dd56d493c0653aecbab380988c5bf1671dbaea75c582827797d98c4a611f7fb2b131fbde2c677d5258ec9" + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum}" + } + + os = "l26" + bios = "ovmf" + vm_id = "${var.vm_id}" + + efi_config { + efi_storage_pool = "${var.proxmox_vm_storage_pool}" + efi_type = "4m" + #pre_enrolled_keys = true + } + + http_directory = "http" + + # VM Cloud-Init Settings + cloud_init = true + cloud_init_storage_pool = "local-lvm" + + boot_command = [ + "", + "e", + "", + "", + "autoinstall ds=nocloud-net\\;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ---", + "" + ] + + boot_wait = "${var.vm_boot_wait}" + + sockets = "${var.vm_cpu_sockets}" + cores = "${var.vm_cpu_cores}" + cpu_type = "host" + memory = "${var.vm_mem_size}" + scsi_controller = "virtio-scsi-single" + + disks { + storage_pool = "${var.proxmox_vm_storage_pool}" + disk_size = "${var.vm_disk_size}G" + } + + network_adapters { + model = "virtio" + bridge = "${var.proxmox_bridge}" +# vlan_tag = "${var.proxmox_vlan}" + firewall = "true" + } + + node = "${var.proxmox_node}" + username = "${var.proxmox_username}" + password = "${var.proxmox_password}" + proxmox_url = "https://${var.proxmox_node}.${var.proxmox_domain}:8006/api2/json" + ssh_timeout = "15m" + ssh_username = "${var.ssh_username}" + ssh_password = "${var.ssh_password}" + template_description = "Fedora 41-1.4, generated on ${timestamp()}" + template_name = "${var.vm_name}" +} + +################################################################################## +# BUILD +################################################################################## +# inline = ["dnf -y update", "dnf -y install python-pip", "python3 -m pip install --upgrade pip", "alternatives --set python /usr/bin/python3", "pip3 install ansible"] + +build { + +# name = "ubuntu-24.04.03" + sources = ["proxmox-iso.ubuntu-24.04.03"] + + # Provisioning the VM Template for Cloud-Init Integration in Proxmox #1 + provisioner "shell" { + inline = [ + "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done", + "sudo rm /etc/ssh/ssh_host_*", + "sudo truncate -s 0 /etc/machine-id", + "sudo apt -y autoremove --purge", + "sudo apt -y clean", + "sudo apt -y autoclean", + "sudo cloud-init clean", + "sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg", + "sudo rm -f /etc/netplan/00-installer-config.yaml", + "sudo sync" + "mkdir /home/wed/.ssh", + "chown wed:wed /home/wed/.ssh", + "cat /tmp/ansible.pub > /home/wed/.ssh/authorized_keys", + "chmod 600 /home/wed/.ssh/authorized_keys", + "chown wed:wed /home/wed/.ssh/authorized_keys", + "rm /tmp/ansible.pub" + ] + } + + # Provisioning the VM Template for Cloud-Init Integration in Proxmox #2 + provisioner "file" { + source = "files/99-pve.cfg" + destination = "/tmp/99-pve.cfg" + } + + # Provisioning the VM Template for Cloud-Init Integration in Proxmox #3 + provisioner "shell" { + inline = [ "sudo cp /tmp/99-pve.cfg /etc/cloud/cloud.cfg.d/99-pve.cfg" ] + } +} diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-small.pkrvars.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-small.pkrvars.hcl new file mode 100755 index 0000000..95dc687 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/ubuntu-small.pkrvars.hcl @@ -0,0 +1,27 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "ubuntu-24.04-small" +vm_id = "9201" +vm_cpu_sockets = "1" +vm_cpu_cores = "2" +vm_mem_size = "2048" +vm_disk_size = "8" + +proxmox_bridge = "vmbr0" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "ubuntu-24.04.3-live-server-amd64.iso" +iso_checksum = "c3514bf0056180d09376462a7a1b4f213c1d6e8ea67fae5c25099c6fd3d8274b" +iso_checksum_type = "sha256" + +# Scripts + +#shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkr.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkr.hcl new file mode 100644 index 0000000..db10c79 --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkr.hcl @@ -0,0 +1,144 @@ +# Proxmox variable definitions + +variable "proxmox_username" { + type = string + description = "The username for authenticating to Proxmox." + default = "" + sensitive = true +} + +variable "proxmox_password" { + type = string + description = "The plaintext password for authenticating to Proxmox." + default = "" + sensitive = true +} + +variable "proxmox_node" { + type = string + description = "The Proxmox node to store the templates on." + default = "" +} + +variable "proxmox_domain" { + type = string + description = "The domain the Proxmox node resizes in." + default = "" +} + +variable "proxmox_insecure_verify" { + type = bool + description = "If true, does not validate the proxmox server's TLS certificate." + default = true +} + +variable "proxmox_vm_storage_pool" { + type = string + description = "The storage pool where the VM will live." + default = "" +} + +# Virtual Machine variables + +variable "vm_name" { + type = string + description = "The template vm name" + default = "" +} + +variable "vm_id" { + type = number + description = "The ID of virtual machine." +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPUs sockets." + default = "1" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket." + default = "1" +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB." +} + +variable "vm_disk_size" { + type = number + description = "The size of the primary virtual disk in GiB." +} + +variable "proxmox_bridge" { + type = string + description = "The Proxmox bridge the NIC connects to." +} + +#variable "proxmox_vlan" { +# type = number +# description = "The VLAN the NIC is on." +#} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot (in seconds)." + default = "" +} + +variable "shell_scripts" { + type = list(string) + description = "A list of scripts." + default = [] +} + +# ISO Objects + +variable "proxmox_iso_storage_pool" { + type = string + description = "The storage pool where the ISO is located." + default = "" +} + +variable "iso_url" { + type = string + description = "The url to retrieve the iso image" + default = "" + } + +variable "iso_file" { + type = string + description = "The file name of the guest operating system ISO image installation media." + default = "" +} + +variable "iso_checksum" { + type = string + description = "The checksum of the ISO image." + default = "" +} + +variable "iso_checksum_type" { + type = string + description = "The checksum type of the ISO image. Ex: sha256" + default = "" +} + +# SSH info + +variable "ssh_username" { + type = string + description = "The username to use to authenticate over SSH." + default = "" + sensitive = true +} + +variable "ssh_password" { + type = string + description = "The plaintext password to use to authenticate over SSH." + default = "" + sensitive = true +} diff --git a/infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkrvars-xlarge.hcl b/infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkrvars-xlarge.hcl new file mode 100755 index 0000000..43b34ad --- /dev/null +++ b/infra-config/04-vm-templates/ubuntu-24.04.03/variables.pkrvars-xlarge.hcl @@ -0,0 +1,35 @@ +################################################################################## +# VARIABLES +################################################################################## + +# HTTP Settings + +http_directory = "http" + +# Virtual Machine Settings + +vm_name = "centos9-large" +vm_guest_os_type = "centos8_64Guest" +vm_version = 19 +vm_firmware = "efi" +vm_cdrom_type = "sata" +vm_cpu_sockets = 1 +vm_cpu_cores = 1 +vm_mem_size = 2048 +vm_disk_size = 102400 +thin_provision = true +disk_eagerly_scrub = false +vm_disk_controller_type = ["pvscsi"] +vm_network_card = "vmxnet3" +vm_boot_wait = "5s" +ssh_username = "wed" +ssh_password = "1mag!ne3R" + +# ISO Objects + +iso_checksum = "ca03867ab88fbe565b91ae518e6f7f83debe6415234f29ff2cc5634052840ce8" +iso_checksum_type = "sha256" +iso_url = "https://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso" +# Scripts + +shell_scripts = ["scripts/cleanup.sh"]