Skip to content

Commit d2fc0ae

Browse files
author
Matt Reeves
committedAug 1, 2024
Merge branch 'main' into renovate/ollama-ollama-0.x
2 parents 65b2f3c + 6ad6414 commit d2fc0ae

File tree

8 files changed

+193
-10
lines changed

8 files changed

+193
-10
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ terraform.rc
4242
## Kubernetes
4343
/kubernetes/cluster/apps/staging
4444

45+
## Packer
46+
credentials.pkr.hcl

‎docker/downloaders/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.9'
22
services:
33
sabnzbd:
4-
image: ghcr.io/linuxserver/sabnzbd@sha256:d6a2a967d47b495c5342bc23de76d35eeb2f3ceb53c7be51885ad25f95dffe9b
4+
image: ghcr.io/linuxserver/sabnzbd@sha256:dda700370ad4281d8ffda4fbdad8ac3f720a2829936eafc794fca652095ed4be
55
container_name: sabnzbd
66
environment:
77
- PUID=1000

‎packer/ubuntu-jammy/files/pve.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
datasource_list: [ConfigDrive, NoCloud]
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
packer {
2+
required_plugins {
3+
name = {
4+
version = "~> 1"
5+
source = "github.com/hashicorp/proxmox"
6+
}
7+
}
8+
}
9+
10+
variable "proxmox_api_url" {
11+
type = string
12+
}
13+
14+
variable "proxmox_api_token_id" {
15+
type = string
16+
}
17+
18+
variable "proxmox_api_token_secret" {
19+
type = string
20+
sensitive = true
21+
}
22+
23+
# Resource Definiation for the VM Template
24+
source "proxmox-clone" "ubuntu-server-jammy" {
25+
26+
# Proxmox Connection Settings
27+
proxmox_url = "${var.proxmox_api_url}"
28+
username = "${var.proxmox_api_token_id}"
29+
token = "${var.proxmox_api_token_secret}"
30+
insecure_skip_tls_verify = true
31+
32+
# VM General Settings
33+
node = "pve2"
34+
clone_vm_id = "8101"
35+
vm_id = "9636"
36+
vm_name = "ubuntu-server-jammy"
37+
template_description = "Ubuntu Server jammy Image"
38+
39+
# VM System Settings
40+
qemu_agent = true
41+
42+
# VM Hard Disk Settings
43+
scsi_controller = "virtio-scsi-pci"
44+
45+
disks {
46+
disk_size = "5G"
47+
format = "raw"
48+
storage_pool = "Fast500Gb"
49+
type = "virtio"
50+
}
51+
52+
# VM CPU Settings
53+
cores = "2"
54+
cpu_type = "x86-64-v2-AES"
55+
56+
# VM Memory Settings
57+
memory = "2048"
58+
59+
# VM Network Settings
60+
network_adapters {
61+
model = "virtio"
62+
bridge = "vmbr0"
63+
firewall = "false"
64+
}
65+
66+
67+
ssh_username = "mafyuh"
68+
ssh_private_key_file = "~/.ssh/id_rsa"
69+
}
70+
71+
72+
build {
73+
74+
name = "ubuntu-server-jammy"
75+
sources = ["source.proxmox-clone.ubuntu-server-jammy"]
76+
77+
78+
provisioner "shell" {
79+
inline = [
80+
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
81+
"sudo rm /etc/ssh/ssh_host_*",
82+
"sudo truncate -s 0 /etc/machine-id",
83+
"sudo apt -y autoremove --purge",
84+
"sudo apt -y clean",
85+
"sudo apt -y autoclean",
86+
"sudo cloud-init clean",
87+
"sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg",
88+
"sudo rm -f /etc/netplan/00-installer-config.yaml",
89+
"sudo sync"
90+
]
91+
}
92+
93+
94+
provisioner "file" {
95+
source = "files/pve.cfg"
96+
destination = "/tmp/pve.cfg"
97+
}
98+
99+
100+
provisioner "shell" {
101+
inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ]
102+
}
103+
104+
# Provisioning the VM Template with Docker Installation #4
105+
provisioner "shell" {
106+
inline = [
107+
"sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common qemu-guest-agent net-tools",
108+
"curl -fsSL https://get.docker.com | sudo sh",
109+
"echo \"alias dcu='docker compose up -d'\" >> ~/.bashrc",
110+
"echo \"alias dcd='docker compose down'\" >> ~/.bashrc",
111+
"git config --global user.name \"Mafyuh\"",
112+
"git config --global user.email \"matt@mafyuh.com\"",
113+
"sudo apt-get -y update"
114+
]
115+
}
116+
}

‎packer/ubuntu-noble/files/pve.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
datasource_list: [ConfigDrive, NoCloud]

‎terraform/cloud-init.tf

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ data "local_file" "ssh_public_key" {
22
filename = "/home/mafyuh/.ssh/main_key.pub"
33
}
44

5+
data "local_file" "ssh_public_key_2" {
6+
filename = "/home/mafyuh/.ssh/id_rsa.pub"
7+
}
8+
59
resource "proxmox_virtual_environment_file" "cloud_config" {
610
content_type = "snippets"
711
datastore_id = "Slow4tb"
@@ -19,6 +23,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
1923
shell: /bin/bash
2024
ssh_authorized_keys:
2125
- ${trimspace(data.local_file.ssh_public_key.content)}
26+
- ${trimspace(data.local_file.ssh_public_key_2.content)}
2227
sudo: ALL=(ALL) NOPASSWD:ALL
2328
runcmd:
2429
- apt update
@@ -30,8 +35,6 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
3035
- su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac'
3136
- su - mafyuh -c 'git config --global user.name "Mafyuh"'
3237
- su - mafyuh -c 'git config --global user.email "matt@mafyuh.com"'
33-
- su - mafyuh -c 'echo "alias dcu=\'docker compose up -d\'" >> /home/mafyuh/.bashrc
34-
- su - mafyuh -c 'echo "alias dcd=\'docker compose down\'" >> /home/mafyuh/.bashrc
3538
- echo "done" > /tmp/cloud-config.done
3639
EOF
3740

@@ -56,19 +59,16 @@ resource "proxmox_virtual_environment_file" "cloud_config2" {
5659
shell: /bin/bash
5760
ssh_authorized_keys:
5861
- ${trimspace(data.local_file.ssh_public_key.content)}
62+
- ${trimspace(data.local_file.ssh_public_key_2.content)}
5963
sudo: ALL=(ALL) NOPASSWD:ALL
6064
runcmd:
6165
- apt update
62-
- apt install -y qemu-guest-agent net-tools nfs-common
66+
- apt install -y qemu-guest-agent
6367
- timedatectl set-timezone America/New_York
6468
- systemctl enable qemu-guest-agent
6569
- systemctl start qemu-guest-agent
66-
- curl -fsSL https://get.docker.com | sudo sh
70+
- apt upgrade -y
6771
- su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac'
68-
- su - mafyuh -c 'git config --global user.name "Mafyuh"'
69-
- su - mafyuh -c 'git config --global user.email "matt@mafyuh.com"'
70-
- su - mafyuh -c 'echo "alias dcu=\'docker compose up -d\'" >> /home/mafyuh/.bashrc
71-
- su - mafyuh -c 'echo "alias dcd=\'docker compose down\'" >> /home/mafyuh/.bashrc
7272
- echo "done" > /tmp/cloud-config.done
7373
EOF
7474

‎terraform/kasm.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resource "proxmox_virtual_environment_vm" "Kasm" {
55
vm_id = 333
66
name = "Kasm"
77
description = "kasm"
8-
tags = ["tofu", "ubuntu-22", "auto-homelab-repo"]
8+
tags = ["tofu", "ubuntu-22", "iac-repo"]
99
started = true
1010

1111
agent {

‎terraform/test.tf

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
resource "proxmox_virtual_environment_vm" "test" {
2+
3+
# VM General Settings
4+
node_name = "pve2"
5+
vm_id = 335
6+
name = "test"
7+
description = "test"
8+
tags = ["tofu", "ubuntu-22", "iac-repo"]
9+
started = true
10+
11+
agent {
12+
enabled = true
13+
}
14+
15+
clone {
16+
vm_id = 9636
17+
}
18+
19+
# VM CPU Settings
20+
cpu {
21+
cores = 4
22+
type = "host"
23+
architecture = "x86_64"
24+
}
25+
26+
# VM Memory Settings
27+
memory {
28+
dedicated = 4096
29+
}
30+
31+
# VM Network Settings
32+
network_device {
33+
bridge = "vmbr0"
34+
vlan_id = 1
35+
}
36+
37+
# VM Disk Settings
38+
disk {
39+
datastore_id = "Fast500Gb"
40+
size = 10
41+
interface = "scsi0"
42+
}
43+
44+
initialization {
45+
ip_config {
46+
ipv4 {
47+
address = "dhcp"
48+
}
49+
}
50+
51+
user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id
52+
}
53+
54+
lifecycle {
55+
ignore_changes = [
56+
initialization[0].user_account[0].keys,
57+
initialization[0].user_account[0].password,
58+
initialization[0].user_account[0].username,
59+
initialization[0].user_data_file_id
60+
]
61+
}
62+
63+
}

0 commit comments

Comments
 (0)
Please sign in to comment.