Skip to content

Commit 0ecb8ab

Browse files
author
Matt Reeves
committedAug 2, 2024
Merge branch 'main' into renovate/ghcr.io-linuxserver-kasm
2 parents 3bb4522 + 209e551 commit 0ecb8ab

File tree

13 files changed

+226
-66
lines changed

13 files changed

+226
-66
lines changed
 

‎.gitignore

Lines changed: 2 additions & 0 deletions
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

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Currently migrating [Auto-Homelab](https://git.mafyuh.dev/mafyuh/Auto-Homelab),
33

44
ToDo
55
- [ ] Update Readme
6-
- [x] Migrate all containers to use this repo (DB migrations)
6+
- [ ] Update Issue Templates
7+
- [x] Migrate all containers to use this repo
78
- [x] Get OpenTofu migrated to this repo
89
- [ ] Get Kubernetes repo migrated over
910
- [ ] Re-bootstrap Flux

‎ansible/playbooks/alias.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- hosts: all
3+
become: true
4+
tasks:
5+
- name: Add alias for docker compose up -d in .bashrc
6+
lineinfile:
7+
path: "/home/{{ ansible_user }}/.bashrc"
8+
line: "alias dcu='docker compose up -d'"
9+
state: present
10+
11+
- name: Add alias for docker compose down in .bashrc
12+
lineinfile:
13+
path: "/home/{{ ansible_user }}/.bashrc"
14+
line: "alias dcd='docker compose down'"
15+
state: present

‎ansible/playbooks/apt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- hosts: "*"
2-
become: yes
2+
become: true
33
tasks:
44
- name: apt
55
apt:

‎docker/AI/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.8"
22

33
services:
44
ollama:
5-
image: ollama/ollama:0.3.1
5+
image: ollama/ollama:0.3.2
66
container_name: ollama
77
restart: unless-stopped
88
volumes:

‎docker/authentik/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
volumes:
3333
- redis:/data
3434
server:
35-
image: ghcr.io/goauthentik/server@sha256:a98f95518269d01bb812eb0e12c6647f3d08a36e37b9fdbdccf9345d4431b9f0
35+
image: ghcr.io/goauthentik/server@sha256:f79b6cf35b29a8591136afb633ddd46da303e9cd2ca82c7cdfbd020a780e15e8
3636
restart: unless-stopped
3737
command: server
3838
environment:
@@ -53,7 +53,7 @@ services:
5353
- postgresql
5454
- redis
5555
worker:
56-
image: ghcr.io/goauthentik/server@sha256:a98f95518269d01bb812eb0e12c6647f3d08a36e37b9fdbdccf9345d4431b9f0
56+
image: ghcr.io/goauthentik/server@sha256:f79b6cf35b29a8591136afb633ddd46da303e9cd2ca82c7cdfbd020a780e15e8
5757
restart: unless-stopped
5858
command: worker
5959
environment:

‎docker/downloaders/docker-compose.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
datasource_list: [ConfigDrive, NoCloud]
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
35+
## See https://git.mafyuh.dev/mafyuh/iac/src/branch/main/terraform/ubuntu22-template2.tf
36+
clone_vm_id = "8101"
37+
38+
vm_id = "9999"
39+
vm_name = "ubuntu-server-jammy"
40+
template_description = "Custom Ubuntu Server see https://git.mafyuh.dev/mafyuh/iac/src/branch/main/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl"
41+
42+
# VM System Settings
43+
qemu_agent = true
44+
45+
# VM Hard Disk Settings
46+
scsi_controller = "virtio-scsi-pci"
47+
48+
disks {
49+
disk_size = "4G"
50+
format = "raw"
51+
storage_pool = "Fast500Gb"
52+
type = "virtio"
53+
}
54+
55+
# VM CPU Settings
56+
cores = "2"
57+
cpu_type = "x86-64-v2-AES"
58+
59+
# VM Memory Settings
60+
memory = "2048"
61+
62+
# VM Network Settings
63+
network_adapters {
64+
model = "virtio"
65+
bridge = "vmbr0"
66+
firewall = "false"
67+
}
68+
69+
70+
ssh_username = "mafyuh"
71+
# WSL Filesystem
72+
ssh_private_key_file = "~/.ssh/id_rsa"
73+
}
74+
75+
76+
build {
77+
78+
name = "ubuntu-server-jammy"
79+
sources = ["source.proxmox-clone.ubuntu-server-jammy"]
80+
81+
## Cleanup for re-template
82+
provisioner "shell" {
83+
inline = [
84+
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
85+
"sudo rm /etc/ssh/ssh_host_*",
86+
"sudo truncate -s 0 /etc/machine-id",
87+
"sudo apt -y autoremove --purge",
88+
"sudo apt -y clean",
89+
"sudo apt -y autoclean",
90+
"sudo cloud-init clean",
91+
"sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg",
92+
"sudo rm -f /etc/netplan/00-installer-config.yaml",
93+
"sudo sync"
94+
]
95+
}
96+
97+
98+
provisioner "file" {
99+
source = "files/pve.cfg"
100+
destination = "/tmp/pve.cfg"
101+
}
102+
103+
104+
provisioner "shell" {
105+
inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ]
106+
}
107+
108+
# Install Commonly Used Things - add alias's - set git config
109+
provisioner "shell" {
110+
inline = [
111+
"sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common qemu-guest-agent net-tools",
112+
"curl -fsSL https://get.docker.com | sudo sh",
113+
"echo \"alias dcu='docker compose up -d'\" >> ~/.bashrc",
114+
"echo \"alias dcd='docker compose down'\" >> ~/.bashrc",
115+
"git config --global user.name \"Mafyuh\"",
116+
"git config --global user.email \"matt@mafyuh.com\"",
117+
"sudo apt-get -y update"
118+
]
119+
}
120+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
datasource_list: [ConfigDrive, NoCloud]

‎terraform/cloud-init.tf

Lines changed: 7 additions & 8 deletions
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,15 @@ 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
6366
- timedatectl set-timezone America/New_York
6467
- systemctl enable qemu-guest-agent
6568
- systemctl start qemu-guest-agent
66-
- curl -fsSL https://get.docker.com | sudo sh
69+
- apt upgrade -y
6770
- 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
7271
- echo "done" > /tmp/cloud-config.done
7372
EOF
7473

‎terraform/kasm.tf

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,76 @@
11
resource "proxmox_virtual_environment_vm" "Kasm" {
2+
# VM General Settings
3+
node_name = "pve2"
4+
vm_id = 333
5+
name = "Kasm"
6+
description = "kasm"
7+
tags = ["tofu", "ubuntu-22", "iac-repo"]
8+
started = true
29

3-
# VM General Settings
4-
node_name = "pve2"
5-
vm_id = 333
6-
name = "Kasm"
7-
description = "kasm"
8-
tags = ["tofu", "ubuntu-22", "auto-homelab-repo"]
9-
started = true
10+
agent {
11+
enabled = true
12+
}
1013

11-
agent {
12-
enabled = true
13-
}
14+
clone {
15+
vm_id = 9999
16+
}
17+
18+
# VM CPU Settings
19+
cpu {
20+
cores = 4
21+
type = "host"
22+
architecture = "x86_64"
23+
}
24+
25+
# VM Memory Settings
26+
memory {
27+
dedicated = 4096
28+
}
1429

15-
clone {
16-
vm_id = 8101
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+
# VM Network Settings
31+
network_device {
32+
bridge = "vmbr0"
33+
vlan_id = 1
34+
}
3035

31-
# VM Network Settings
32-
network_device {
33-
bridge = "vmbr0"
34-
vlan_id = 1
35-
}
36+
# VM Disk Settings
37+
disk {
38+
datastore_id = "local-lvm"
39+
size = 100
40+
interface = "scsi0"
41+
}
3642

37-
# VM Disk Settings
38-
disk {
39-
datastore_id = "local-lvm"
40-
size = 100
41-
interface = "scsi0"
43+
initialization {
44+
ip_config {
45+
ipv4 {
46+
address = var.kasm_ip
47+
gateway = var.vlan_gateway
48+
}
4249
}
4350

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-
}
51+
user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id
52+
}
5353

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-
}
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+
}
6262

63+
provisioner "remote-exec" {
64+
inline = [
65+
"cd /home/mafyuh/iac/docker/kasm",
66+
"git pull",
67+
"docker compose up -d"
68+
]
69+
connection {
70+
type = "ssh"
71+
user = "mafyuh"
72+
private_key = file("/home/mafyuh/.ssh/id_rsa")
73+
host = var.kasm_ssh_ip
74+
}
6375
}
76+
}

‎terraform/vars.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ variable "init_username" {
4444

4545
variable "init_password" {
4646
type = string
47+
}
48+
49+
variable "kasm_ip" {
50+
type = string
51+
}
52+
53+
variable "kasm_ssh_ip" {
54+
type = string
4755
}

0 commit comments

Comments
 (0)
Please sign in to comment.