tidy up
This commit is contained in:
0
zz_archived/packer/docker/README.md
Normal file
0
zz_archived/packer/docker/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
image_url = "https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
|
||||
checksum_url = "https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2.SHA256"
|
||||
|
||||
host_ssh_user = "michael"
|
||||
host_ssh_address = "server.balsillie.net"
|
||||
host_ssh_private_key = "/home/michael/.ssh/conf.d/home/michael_server_copy.key"
|
||||
host_ssh_known_hosts = "/home/michael/.ssh/known_hosts_server"
|
||||
|
||||
guest_hostname = "arch-minimal-template"
|
||||
cpu_count = 2
|
||||
memory = 2048
|
||||
domain_type = "kvm"
|
||||
arch = "x86_64"
|
||||
chipset = "pc-q35-6.1"
|
||||
loader_type = "pflash"
|
||||
loader_path = "/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd"
|
||||
secure_boot = false
|
||||
nvram_template = "/usr/share/edk2-ovmf/x64/OVMF_VARS.fd"
|
||||
nvram_path_base = "/var/lib/libvirt/qemu/nvram"
|
||||
|
||||
volume_name = "arch_minimal_template"
|
||||
volume_pool = "default"
|
||||
volume_capacity = "30G"
|
||||
|
||||
bridge_name = "br21"
|
||||
|
||||
ssh_source = "192.168.20.0/24"
|
||||
|
||||
guest_ssh_user = "arch"
|
||||
guest_ssh_port = 22
|
||||
guest_ssh_private_key = "/home/michael/.ssh/conf.d/home/arch@arch_template.key"
|
||||
guest_ssh_public_key = "~/.ssh/conf.d/home/arch@arch_template.key.pub"
|
||||
|
||||
network_address = "192.168.21.200/24"
|
||||
network_gateway = "192.168.20.254"
|
||||
network_nameserver = "192.168.30.20"
|
||||
network_domain = "balsillie.net"
|
150
zz_archived/packer/libvirt/arch/arch-minimal.build.pkr.hcl
Normal file
150
zz_archived/packer/libvirt/arch/arch-minimal.build.pkr.hcl
Normal file
@ -0,0 +1,150 @@
|
||||
# -------------------------------------------------------------------------
|
||||
# Name: vm-libvirt-arch-minimal
|
||||
# Desc: Create a minimal Arch Linux VM install on a libvirt/kvm hypervisor.
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
#--------------------
|
||||
# Requirements block.
|
||||
#--------------------
|
||||
|
||||
packer {
|
||||
required_plugins {
|
||||
libvirt = {
|
||||
version = ">= 0.3.4"
|
||||
source = "github.com/thomasklein94/libvirt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------
|
||||
# Variables block.
|
||||
# ----------------
|
||||
|
||||
data "http" "image_checksum" {
|
||||
url = var.checksum_url
|
||||
}
|
||||
|
||||
locals {
|
||||
image_checksum = split(" ",data.http.image_checksum.body)[0]
|
||||
libvirt_uri = "qemu+ssh://${var.host_ssh_user}@${var.host_ssh_address}/system?keyfile=${var.host_ssh_private_key}&no_verify=1"
|
||||
nvram_path = "${var.nvram_path_base}/${var.guest_hostname}_VARS.fd"
|
||||
cidata_name = "${var.volume_name}_cidata"
|
||||
}
|
||||
|
||||
#---------------
|
||||
# Sources block.
|
||||
#---------------
|
||||
|
||||
source "libvirt" "arch-minimal" {
|
||||
libvirt_uri = local.libvirt_uri
|
||||
domain_name = var.guest_hostname
|
||||
vcpu = var.cpu_count
|
||||
memory = var.memory
|
||||
boot_devices = ["hd"]
|
||||
shutdown_mode = "guest"
|
||||
domain_type = var.domain_type
|
||||
arch = var.arch
|
||||
chipset = var.chipset
|
||||
loader_type = var.loader_type
|
||||
loader_path = var.loader_path
|
||||
// nvram_template = var.nvram_template
|
||||
// nvram_path = local.nvram_path
|
||||
nvram_template = local.nvram_path
|
||||
nvram_path = var.nvram_template
|
||||
secure_boot = var.secure_boot
|
||||
|
||||
volume {
|
||||
alias = "artifact"
|
||||
name = var.volume_name
|
||||
pool = var.volume_pool
|
||||
readonly = false
|
||||
target_dev = "vda"
|
||||
bus = "virtio"
|
||||
format = "qcow2"
|
||||
size = "2G"
|
||||
capacity = var.volume_capacity
|
||||
source {
|
||||
type = "external"
|
||||
urls = [var.image_url]
|
||||
checksum = local.image_checksum
|
||||
// checksum = "f237ada9ba61431f6aebb066d2b3f0b5b432ea21da6034d98248725df1417545"
|
||||
}
|
||||
}
|
||||
|
||||
volume {
|
||||
alias = "cidata"
|
||||
name = local.cidata_name
|
||||
pool = var.volume_pool
|
||||
readonly = true
|
||||
source {
|
||||
type = "cloud-init"
|
||||
|
||||
meta_data = jsonencode({
|
||||
"instance-id" = "${var.guest_hostname}"
|
||||
"hostname" = "${var.guest_hostname}"
|
||||
})
|
||||
|
||||
user_data = format("#cloud-config\n%s", jsonencode({
|
||||
"packages" = [
|
||||
"qemu-guest-agent",
|
||||
"ufw"
|
||||
]
|
||||
"runcmd" = [
|
||||
["systemctl", "enable", "--now", "qemu-guest-agent"],
|
||||
["ufw", "enable"],
|
||||
["ufw", "allow", "from", "${var.ssh_source}", "to", "port", "22", "proto", "tcp"],
|
||||
["systemctl", "enable", "--now", "ufw"]
|
||||
]
|
||||
}))
|
||||
|
||||
network_config = jsonencode({
|
||||
renderer = "networkd"
|
||||
version = 2
|
||||
ethernets = {
|
||||
eth0 = {
|
||||
match = {
|
||||
name = "en*"
|
||||
}
|
||||
dhcp4 = false
|
||||
addresses = ["${var.network_address}"]
|
||||
gateway4 = "${var.network_gateway}"
|
||||
nameservers = {
|
||||
addresses = ["${var.network_nameserver}"]
|
||||
search = ["${var.network_domain}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
artifact_volume_alias = "artifact"
|
||||
|
||||
network_interface {
|
||||
type = "bridge"
|
||||
bridge = var.bridge_name
|
||||
model = "virtio"
|
||||
alias = "default-network"
|
||||
}
|
||||
network_address_source = "agent"
|
||||
|
||||
graphics {
|
||||
type = "vnc"
|
||||
port = 5902
|
||||
}
|
||||
|
||||
communicator {
|
||||
ssh_username = var.guest_ssh_user
|
||||
ssh_port = var.guest_ssh_port
|
||||
ssh_private_key_file = var.guest_ssh_private_key
|
||||
}
|
||||
communicator_interface = "default-network"
|
||||
}
|
||||
|
||||
#-------------
|
||||
# Build block.
|
||||
#-------------
|
||||
|
||||
build {
|
||||
sources = ["source.libvirt.arch-minimal"]
|
||||
}
|
161
zz_archived/packer/libvirt/arch/arch-minimal.variables.pkr.hcl
Normal file
161
zz_archived/packer/libvirt/arch/arch-minimal.variables.pkr.hcl
Normal file
@ -0,0 +1,161 @@
|
||||
variable "image_url" {
|
||||
type = string
|
||||
description = "The URL to retrieve the backing image from."
|
||||
}
|
||||
|
||||
variable "checksum_url" {
|
||||
type = string
|
||||
description = "The URL to retrieve the checksum value of the backing image from."
|
||||
}
|
||||
|
||||
variable "cpu_count" {
|
||||
type = number
|
||||
description = "Number of vCPUs to create guest with."
|
||||
}
|
||||
|
||||
variable "memory" {
|
||||
type = number
|
||||
description = "Amount of RAM in MiB to create guest with."
|
||||
}
|
||||
|
||||
variable "domain_type" {
|
||||
type = string
|
||||
description = "Type of hypervisor to use."
|
||||
default = "kvm"
|
||||
}
|
||||
|
||||
variable "arch" {
|
||||
type = string
|
||||
description = "Domain architecture."
|
||||
default = "x86_64"
|
||||
}
|
||||
|
||||
variable "chipset" {
|
||||
type = string
|
||||
description = "Libvirt Machine Type Value for domain XML's machine type."
|
||||
default = "q35"
|
||||
}
|
||||
|
||||
variable "loader_type" {
|
||||
type = string
|
||||
description = "Where loader should be stored in guest. rom or pflash"
|
||||
default = "pflash"
|
||||
}
|
||||
|
||||
variable "loader_path" {
|
||||
type = string
|
||||
description = "File path where the OVMF firmware files are stored on the host."
|
||||
}
|
||||
|
||||
variable "secure_boot" {
|
||||
type = bool
|
||||
description = "Whether to enable secure boot."
|
||||
}
|
||||
|
||||
variable "nvram_template" {
|
||||
type = string
|
||||
description = "File path where the OVMF_VARS template file is stored on the host."
|
||||
}
|
||||
|
||||
variable "nvram_path_base" {
|
||||
type = string
|
||||
description = "Parent dir where the guest OVMF_VARS copy will be stored. No trailing /"
|
||||
}
|
||||
|
||||
variable "volume_name" {
|
||||
type = string
|
||||
description = "Name of the final template image artifact."
|
||||
}
|
||||
|
||||
variable "volume_pool" {
|
||||
type = string
|
||||
description = "Host storage pool where the template image will be kept."
|
||||
}
|
||||
|
||||
variable "volume_capacity" {
|
||||
type = string
|
||||
description = "Size of the template image drive."
|
||||
}
|
||||
|
||||
variable "bridge_name" {
|
||||
type = string
|
||||
description = "Name of the bridge netdev on the host."
|
||||
}
|
||||
|
||||
variable "guest_ssh_user" {
|
||||
type = string
|
||||
description = "User account for connecing to the guest VM, eg for provisioners."
|
||||
}
|
||||
|
||||
variable "guest_ssh_pass" {
|
||||
type = string
|
||||
sensitive = true
|
||||
description = "Password for SSH connection to the guest VM."
|
||||
default = "placeholder"
|
||||
}
|
||||
|
||||
variable "guest_ssh_port" {
|
||||
type = number
|
||||
description = "SSH port for connecting to the guest VM."
|
||||
default = 22
|
||||
}
|
||||
|
||||
variable "guest_ssh_private_key" {
|
||||
type = string
|
||||
description = "File path to the private key used for SSH pubkey auth to the guest VM."
|
||||
}
|
||||
|
||||
variable "guest_ssh_public_key" {
|
||||
type = string
|
||||
description = "File path to the public key to be added to authoried_keys on the guest VM during cloud-init."
|
||||
}
|
||||
|
||||
variable "guest_hostname" {
|
||||
type = string
|
||||
description = "The hostname of the virtual machine"
|
||||
}
|
||||
|
||||
variable "ssh_source" {
|
||||
type = string
|
||||
description = "The subnet that will be added to the firewall SSH exception during cloud-init."
|
||||
}
|
||||
|
||||
variable "host_ssh_user" {
|
||||
type = string
|
||||
description = "The user to connect to the hypervisor as, used to construct the libvirt URI."
|
||||
}
|
||||
|
||||
variable "host_ssh_address" {
|
||||
type = string
|
||||
description = "The address of the hypervisor, used to construct the libvirt URI."
|
||||
}
|
||||
|
||||
variable "host_ssh_private_key" {
|
||||
type = string
|
||||
description = "File path to the SSH key used to authenticate to the hypervisor host."
|
||||
}
|
||||
|
||||
variable "host_ssh_known_hosts" {
|
||||
type = string
|
||||
description = "File path to the known_hosts file for validating the hypervisor host connection."
|
||||
}
|
||||
|
||||
variable "network_address" {
|
||||
type = string
|
||||
description = "Network address assigned to the guest."
|
||||
}
|
||||
|
||||
variable "network_gateway" {
|
||||
type = string
|
||||
description = "Default gateway assigned to the guest."
|
||||
}
|
||||
|
||||
variable "network_nameserver" {
|
||||
type = string
|
||||
description = "DNS/Nameserver assigned to the guest."
|
||||
}
|
||||
|
||||
variable "network_domain" {
|
||||
type = string
|
||||
description = "Search domain assigned to the guest."
|
||||
}
|
0
zz_archived/packer/proxmox/README.md
Normal file
0
zz_archived/packer/proxmox/README.md
Normal file
1
zz_archived/packer/proxmox/rocky/files/99-pve.cfg
Normal file
1
zz_archived/packer/proxmox/rocky/files/99-pve.cfg
Normal file
@ -0,0 +1 @@
|
||||
datasource_list: [ConfigDrive, NoCloud]
|
0
zz_archived/packer/proxmox/rocky/http/meta-data
Normal file
0
zz_archived/packer/proxmox/rocky/http/meta-data
Normal file
32
zz_archived/packer/proxmox/rocky/http/user-data
Normal file
32
zz_archived/packer/proxmox/rocky/http/user-data
Normal file
@ -0,0 +1,32 @@
|
||||
#cloud-config
|
||||
autoinstall:
|
||||
version: 1
|
||||
locale: en_NZ
|
||||
keyboard:
|
||||
layout: en
|
||||
ssh:
|
||||
install-server: true
|
||||
allow-pw: false
|
||||
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: true
|
||||
timezone: Pacific/Auckland
|
||||
users:
|
||||
- name: ladmin
|
||||
groups: [adm, sudo]
|
||||
lock-passwd: false
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
passwd: "qx9efm7k"
|
||||
ssh_authorized_keys:
|
||||
- your-ssh-key
|
168
zz_archived/packer/proxmox/rocky/rocky-minimal.pkr.hcl
Normal file
168
zz_archived/packer/proxmox/rocky/rocky-minimal.pkr.hcl
Normal file
@ -0,0 +1,168 @@
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# Name: vm-proxmox-rocky-minimal
|
||||
# Desc: Create a minimal Rocky Linux VM install on Proxmox.
|
||||
# ----------------------------------------------------------
|
||||
|
||||
|
||||
# ----------------
|
||||
# Template begin.
|
||||
# ----------------
|
||||
|
||||
|
||||
# -----------------
|
||||
# Variables block.
|
||||
# -----------------
|
||||
|
||||
|
||||
variable "proxmox_api_url" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_secret" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
|
||||
# --------------
|
||||
# Source block.
|
||||
# --------------
|
||||
|
||||
# Resource Definiation for the VM Template
|
||||
|
||||
source "proxmox" "rocky-minimal" {
|
||||
|
||||
# Proxmox Connection Settings
|
||||
proxmox_url = "${var.proxmox_api_url}"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
# (Optional) Skip TLS Verification
|
||||
insecure_skip_tls_verify = true
|
||||
|
||||
# VM General Settings
|
||||
node = "lab"
|
||||
vm_id = "100"
|
||||
vm_name = "rocky-minimal"
|
||||
template_description = "Rocky minimal image."
|
||||
|
||||
# VM OS Settings
|
||||
# (Option 1) Local ISO File
|
||||
iso_file = "local:iso/Rocky-8.5-x86_64-boot.iso"
|
||||
# - or -
|
||||
# (Option 2) Download ISO
|
||||
# iso_url = "https://releases.ubuntu.com/20.04/ubuntu-20.04.3-live-server-amd64.iso"
|
||||
# iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
|
||||
iso_storage_pool = "local"
|
||||
unmount_iso = true
|
||||
|
||||
# VM System Settings
|
||||
qemu_agent = true
|
||||
|
||||
# VM Hard Disk Settings
|
||||
scsi_controller = "virtio-scsi-pci"
|
||||
|
||||
disks {
|
||||
disk_size = "40G"
|
||||
format = "raw"
|
||||
storage_pool = "nvme"
|
||||
storage_pool_type = "zfspool"
|
||||
type = "virtio"
|
||||
}
|
||||
|
||||
# VM CPU Settings
|
||||
cores = "2"
|
||||
|
||||
# VM Memory Settings
|
||||
memory = "4096"
|
||||
|
||||
# VM Network Settings
|
||||
network_adapters {
|
||||
model = "virtio"
|
||||
bridge = "vmbr20"
|
||||
firewall = "false"
|
||||
}
|
||||
|
||||
# VM Cloud-Init Settings
|
||||
cloud_init = true
|
||||
cloud_init_storage_pool = "local-lvm"
|
||||
|
||||
# PACKER Boot Commands
|
||||
boot_command = [
|
||||
"<esc><wait><esc><wait>",
|
||||
"<f6><wait><esc><wait>",
|
||||
"<bs><bs><bs><bs><bs>",
|
||||
"autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ",
|
||||
"--- <enter>"
|
||||
]
|
||||
boot = "c"
|
||||
boot_wait = "5s"
|
||||
|
||||
# PACKER Autoinstall Settings
|
||||
http_directory = "http"
|
||||
# (Optional) Bind IP Address and Port
|
||||
# http_bind_address = "0.0.0.0"
|
||||
# http_port_min = 8802
|
||||
# http_port_max = 8802
|
||||
|
||||
ssh_username = "ladmin"
|
||||
|
||||
# (Option 1) Add your Password here
|
||||
# ssh_password = "your-password"
|
||||
# - or -
|
||||
# (Option 2) Add your Private SSH KEY file here
|
||||
# ssh_private_key_file = "~/.ssh/id_rsa"
|
||||
|
||||
# Raise the timeout, when installation takes longer
|
||||
ssh_timeout = "20m"
|
||||
}
|
||||
|
||||
|
||||
# -------------
|
||||
# Build block.
|
||||
# -------------
|
||||
|
||||
|
||||
build {
|
||||
|
||||
name = "rocky-minimal"
|
||||
sources = ["source.proxmox.rocky-minimal"]
|
||||
|
||||
# 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 sync"
|
||||
]
|
||||
}
|
||||
|
||||
# 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" ]
|
||||
}
|
||||
|
||||
# Add additional provisioning scripts here
|
||||
# ...
|
||||
}
|
||||
|
||||
|
||||
# --------------
|
||||
# Template end.
|
||||
# --------------
|
Reference in New Issue
Block a user