Skip to content

Commit b253a12

Browse files
committedFeb 1, 2025
major overhaul, preparing for kubernetes migration
1 parent 57b8c88 commit b253a12

24 files changed

+649
-575
lines changed
 

‎.forgejo/workflows/tofu.yml

+9-30
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,33 @@ jobs:
2323
access_token: ${{ secrets.BW_ACCESS_TOKEN }}
2424
base_url: https://vault.bitwarden.com
2525
secrets: |
26-
c65f8886-f6fb-4c17-bc79-b208000604bf > arrbuntu_ip_address
2726
2dae51bd-bd65-474c-971c-b20800f22afa > aws_access_key_id
2827
287c852d-f2b5-467d-bfc4-b20800f25f52 > aws_secret_access_key
29-
a54974b8-c6b3-4df7-9042-b20800064050 > downloaders_ip_address
3028
3b222376-ccd9-4f44-a4b4-b222001af68a > grafana_auth
3129
030fbb6a-3b6d-40dc-9c26-b222001b0fb6 > grafana_url
32-
dacbeafa-c671-4b9c-9334-b2080006f75b > init_password
33-
9ceabbd0-6492-4674-9bab-b2080006e333 > init_username
34-
0bc3c1a3-fc48-48ce-85c5-b2080007136a > kasm_ip
35-
63ca1819-5090-4e30-9dba-b20800072718 > kasm_ssh_ip
36-
47ef68aa-32a9-45b0-835d-b2080006ce38 > npm_ip_address
37-
d0c7f3ec-8277-4b1b-9a1b-b2080006b842 > prox_ip_address
38-
17ab7869-c7a1-4ece-8c64-b20800075213 > pve2_ip_address
3930
f8f85ab2-5f6d-46a7-9e06-b20800076d26 > s3_endpoint
40-
68f1d77d-4e96-498a-9464-b208000679a4 > ssh_password
41-
d0762ced-73de-4f30-aa1c-b20800069536 > ssh_username
42-
d8017351-7a11-42e6-9e8d-b208000739b8 > ubu_ip_address
43-
1d250f4a-ae18-4e19-934c-b2080005e132 > virtual_environment_api
44-
a4ed343a-bb92-4beb-a421-b2080005bf98 > virtual_environment_endpoint
45-
af0ed579-05f8-405f-b0f3-b208000620ca > vlan_gateway
31+
b6dac092-df23-4e28-8449-b2770059096d > kube_config
4632
4733
4834
- name: Create tfvars file
4935
working-directory: ./terraform
5036
run: |
5137
cat <<EOF > terraform.tfvars
52-
arrbuntu_ip_address = "${{ steps.bitwarden-secrets.outputs.arrbuntu_ip_address }}"
5338
aws_access_key_id = "${{ steps.bitwarden-secrets.outputs.aws_access_key_id }}"
5439
aws_secret_access_key = "${{ steps.bitwarden-secrets.outputs.aws_secret_access_key }}"
55-
downloaders_ip_address = "${{ steps.bitwarden-secrets.outputs.downloaders_ip_address }}"
5640
grafana_auth = "${{ steps.bitwarden-secrets.outputs.grafana_auth }}"
5741
grafana_url = "${{ steps.bitwarden-secrets.outputs.grafana_url }}"
58-
init_password = "${{ steps.bitwarden-secrets.outputs.init_password }}"
59-
init_username = "${{ steps.bitwarden-secrets.outputs.init_username }}"
60-
kasm_ip = "${{ steps.bitwarden-secrets.outputs.kasm_ip }}"
61-
kasm_ssh_ip = "${{ steps.bitwarden-secrets.outputs.kasm_ssh_ip }}"
62-
npm_ip_address = "${{ steps.bitwarden-secrets.outputs.npm_ip_address }}"
63-
prox_ip_address = "${{ steps.bitwarden-secrets.outputs.prox_ip_address }}"
64-
pve2_ip_address = "${{ steps.bitwarden-secrets.outputs.pve2_ip_address }}"
6542
s3_endpoint = "${{ steps.bitwarden-secrets.outputs.s3_endpoint }}"
66-
ssh_password = "${{ steps.bitwarden-secrets.outputs.ssh_password }}"
67-
ssh_username = "${{ steps.bitwarden-secrets.outputs.ssh_username }}"
68-
ubu_ip_address = "${{ steps.bitwarden-secrets.outputs.ubu_ip_address }}"
69-
virtual_environment_api = "${{ steps.bitwarden-secrets.outputs.virtual_environment_api }}"
70-
virtual_environment_endpoint = "${{ steps.bitwarden-secrets.outputs.virtual_environment_endpoint }}"
71-
vlan_gateway = "${{ steps.bitwarden-secrets.outputs.vlan_gateway }}"
7243
EOF
7344
45+
- name: Make Kube directory
46+
run: |
47+
mkdir ~/.kube
48+
49+
- name: Create Kube Config
50+
run: |
51+
printf "%s" "${{ steps.bitwarden-secrets.outputs.kube_config }}" > ~/.kube/config
52+
7453
- name: Setup OpenTofu
7554
uses: https://github.com/opentofu/setup-opentofu@v1.0.5
7655

‎automations/README.md

Whitespace-only changes.

‎docker/README.md

+1-301
Large diffs are not rendered by default.

‎packer/debian/debian-11-2.pkr.hcl

+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" "debian2" {
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+
36+
clone_vm_id = "8105"
37+
38+
vm_id = "9999"
39+
vm_name = "debian-template"
40+
template_description = "Debian Bullseye"
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 = "3G"
50+
format = "raw"
51+
storage_pool = "Fast500Gb"
52+
type = "scsi"
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 = "debian"
79+
sources = ["source.proxmox-clone.debian2"]
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 /var/lib/dbus/machine-id",
92+
"sudo rm -f /var/lib/systemd/random-seed",
93+
"sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg",
94+
"sudo rm -f /etc/netplan/00-installer-config.yaml",
95+
"sudo sync"
96+
]
97+
}
98+
99+
provisioner "file" {
100+
source = "files/pve.cfg"
101+
destination = "/tmp/pve.cfg"
102+
}
103+
104+
provisioner "shell" {
105+
inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ]
106+
}
107+
108+
109+
provisioner "shell" {
110+
inline = [
111+
"sudo apt-get update",
112+
"sudo apt-get -y upgrade"
113+
]
114+
}
115+
116+
}

‎packer/debian/debian-11.pkr.hcl

+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" "debian" {
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 = "prox"
34+
35+
36+
clone_vm_id = "8104"
37+
38+
vm_id = "9998"
39+
vm_name = "debian-template"
40+
template_description = "Debian Bullseye"
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 = "3G"
50+
format = "raw"
51+
storage_pool = "Fast2Tb"
52+
type = "scsi"
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 = "debian"
79+
sources = ["source.proxmox-clone.debian"]
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 /var/lib/dbus/machine-id",
92+
"sudo rm -f /var/lib/systemd/random-seed",
93+
"sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg",
94+
"sudo rm -f /etc/netplan/00-installer-config.yaml",
95+
"sudo sync"
96+
]
97+
}
98+
99+
provisioner "file" {
100+
source = "files/pve.cfg"
101+
destination = "/tmp/pve.cfg"
102+
}
103+
104+
provisioner "shell" {
105+
inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ]
106+
}
107+
108+
109+
provisioner "shell" {
110+
inline = [
111+
"sudo apt-get update",
112+
"sudo apt-get -y upgrade"
113+
]
114+
}
115+
116+
}

‎packer/debian/files/pve.cfg

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

‎terraform/README.md

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[![OpenTofu](https://img.shields.io/badge/OpenTofu-v1.7.1-blue)](https://github.com/opentofu/opentofu)
2-
3-
41
<div align="center">
52

63
# IaC
@@ -10,9 +7,5 @@ Infrastructure as Code (IaC) for my homelab using OpenTofu.
107
</div>
118

129

13-
## Overview
14-
15-
This repository manages the infrastructure for my homelab using OpenTofu and Proxmox.
16-
1710

1811

‎terraform/flux/main.tf

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
data "bitwarden-secrets_secret" "git_flux_password" {
2+
id = "e507c0be-cc1e-4d5b-90a7-b2710067c651"
3+
}
4+
5+
provider "flux" {
6+
kubernetes = {
7+
config_path = "~/.kube/config"
8+
}
9+
git = {
10+
url = "https://git.mafyuh.dev/mafyuh/k3s"
11+
http = {
12+
username = "mafyuh"
13+
password = data.bitwarden-secrets_secret.git_flux_password.value
14+
}
15+
}
16+
}
17+
18+
resource "flux_bootstrap_git" "flux" {
19+
path = "cluster/production"
20+
}

‎terraform/flux/provider.tf

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_providers {
3+
flux = {
4+
source = "fluxcd/flux"
5+
version = "1.4.0"
6+
}
7+
bitwarden-secrets = {
8+
source = "sebastiaan-dev/bitwarden-secrets"
9+
version = "0.1.2"
10+
}
11+
}
12+
}

‎terraform/main.tf

+26-24
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,53 @@ terraform {
2424
source = "bpg/proxmox"
2525
version = "0.70.0"
2626
}
27+
bitwarden-secrets = {
28+
source = "sebastiaan-dev/bitwarden-secrets"
29+
version = "0.1.2"
30+
}
31+
flux = {
32+
source = "fluxcd/flux"
33+
version = "1.4.0"
34+
}
2735
}
2836
}
2937

38+
provider "bitwarden-secrets" {
39+
access_token = var.access_token
40+
}
41+
42+
3043
provider "proxmox" {
31-
endpoint = var.virtual_environment_endpoint
32-
password = var.ssh_password
44+
endpoint = data.bitwarden-secrets_secret.virtual_environment_endpoint.value
45+
password = data.bitwarden-secrets_secret.ssh_password.value
3346
username = "root@pam"
3447
insecure = true
3548

3649
ssh {
3750
agent = true
3851
username = "root"
39-
password = var.ssh_password
52+
password = data.bitwarden-secrets_secret.ssh_password.value
4053

4154
node {
4255
name = "prox"
43-
address = var.prox_ip_address
56+
address = data.bitwarden-secrets_secret.prox_ip_address.value
4457
}
4558

4659
node {
4760
name = "pve2"
48-
address = var.pve2_ip_address
61+
address = data.bitwarden-secrets_secret.pve2_ip_address.value
4962
}
5063
}
5164
}
5265

5366
module "proxmox" {
5467
source = "./proxmox"
68+
69+
providers = {
70+
proxmox = proxmox
71+
}
72+
}
5573

56-
virtual_environment_endpoint = var.virtual_environment_endpoint
57-
virtual_environment_api = var.virtual_environment_api
58-
arrbuntu_ip_address = var.arrbuntu_ip_address
59-
vlan_gateway = var.vlan_gateway
60-
downloaders_ip_address = var.downloaders_ip_address
61-
ssh_password = var.ssh_password
62-
ssh_username = var.ssh_username
63-
prox_ip_address = var.prox_ip_address
64-
npm_ip_address = var.npm_ip_address
65-
init_username = var.init_username
66-
init_password = var.init_password
67-
kasm_ip = var.kasm_ip
68-
kasm_ssh_ip = var.kasm_ssh_ip
69-
ubu_ip_address = var.ubu_ip_address
70-
pve2_ip_address = var.pve2_ip_address
71-
s3_endpoint = var.s3_endpoint
72-
aws_secret_access_key = var.aws_secret_access_key
73-
aws_access_key_id = var.aws_access_key_id
74-
}
74+
module "flux" {
75+
source = "./flux"
76+
}

‎terraform/proxmox/arrbuntu.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ resource "proxmox_virtual_environment_vm" "Arrbuntu" {
88
tags = ["tofu", "ubuntu-22", "auto-homelab-repo", "infrastructure"]
99

1010
agent {
11-
enabled = true # read 'Qemu guest agent' section, change to true only when ready
11+
enabled = true
1212
}
1313

1414
clone {
@@ -47,8 +47,8 @@ resource "proxmox_virtual_environment_vm" "Arrbuntu" {
4747
initialization {
4848
ip_config {
4949
ipv4 {
50-
address = var.arrbuntu_ip_address
51-
gateway = var.vlan_gateway
50+
address = data.bitwarden-secrets_secret.arrbuntu_ip.value
51+
gateway = data.bitwarden-secrets_secret.vlan_gateway.value
5252
}
5353
}
5454

‎terraform/proxmox/debian-base.tf

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
resource "proxmox_virtual_environment_vm" "Debian-Base" {
2+
name = "debian-base"
3+
node_name = "prox"
4+
vm_id = 8104
5+
tags = ["tofu"]
6+
template = true
7+
started = false
8+
9+
disk {
10+
datastore_id = "Fast2Tb"
11+
# See https://www.reddit.com/r/Proxmox/comments/1058ko7/comment/j3s4vli/ for how to inject qemu into base image
12+
# virt-customize -a debian-11-generic-amd64-20241202-1949.img --install qemu-guest-agent
13+
file_id = "local:iso/debian-11-generic-amd64-20241202-1949.img"
14+
interface = "virtio0"
15+
size = 3
16+
}
17+
18+
agent {
19+
enabled = true
20+
}
21+
22+
initialization {
23+
ip_config {
24+
ipv4 {
25+
address = "dhcp"
26+
}
27+
}
28+
}
29+
30+
serial_device {}
31+
32+
network_device {
33+
bridge = "vmbr0"
34+
}
35+
36+
vga {
37+
type = "serial0"
38+
}
39+
40+
cpu {
41+
cores = 2
42+
type = "host"
43+
architecture = "x86_64"
44+
}
45+
}

‎terraform/proxmox/debian-base2.tf

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
resource "proxmox_virtual_environment_vm" "Debian-Base2" {
2+
name = "debian-base"
3+
node_name = "pve2"
4+
vm_id = 8105
5+
tags = ["tofu"]
6+
template = true
7+
started = false
8+
9+
disk {
10+
datastore_id = "Fast500Gb"
11+
# See https://www.reddit.com/r/Proxmox/comments/1058ko7/comment/j3s4vli/ for how to inject qemu into base image
12+
# virt-customize -a debian-11-generic-amd64-20241202-1949.img --install qemu-guest-agent
13+
file_id = "local:iso/debian-11-generic-amd64-20241202-1949.img"
14+
interface = "virtio0"
15+
size = 3
16+
}
17+
18+
agent {
19+
enabled = true
20+
}
21+
22+
initialization {
23+
ip_config {
24+
ipv4 {
25+
address = "dhcp"
26+
}
27+
}
28+
}
29+
30+
serial_device {}
31+
32+
network_device {
33+
bridge = "vmbr0"
34+
}
35+
36+
vga {
37+
type = "serial0"
38+
}
39+
40+
cpu {
41+
cores = 2
42+
type = "host"
43+
architecture = "x86_64"
44+
}
45+
}

‎terraform/proxmox/k3s-master1.tf

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
resource "proxmox_virtual_environment_vm" "K3s-Master1" {
2+
3+
# VM General Settings
4+
node_name = "prox"
5+
vm_id = 329
6+
name = "K3s-Master1"
7+
description = "Kubernetes master"
8+
tags = ["tofu", "debian", "infrastructure", "k3s"]
9+
started = true
10+
11+
agent {
12+
enabled = true # read 'Qemu guest agent' section, change to true only when ready
13+
}
14+
15+
clone {
16+
vm_id = 9998
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 = 8192
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 = "Fast2Tb"
40+
size = 300
41+
interface = "virtio0"
42+
}
43+
44+
vga {
45+
type = "serial0"
46+
}
47+
48+
initialization {
49+
ip_config {
50+
ipv4 {
51+
address = "dhcp"
52+
}
53+
}
54+
55+
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
56+
}
57+
58+
lifecycle {
59+
ignore_changes = [
60+
initialization[0].user_account[0].keys,
61+
initialization[0].user_account[0].password,
62+
initialization[0].user_account[0].username,
63+
initialization[0].user_data_file_id
64+
]
65+
}
66+
67+
}

‎terraform/proxmox/k3s-master2.tf

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
resource "proxmox_virtual_environment_vm" "K3s-Master2" {
2+
3+
# VM General Settings
4+
node_name = "pve2"
5+
vm_id = 321
6+
name = "K3s-Master2"
7+
description = "Kubernetes Master"
8+
tags = ["tofu", "debian", "infrastructure", "k3s"]
9+
started = true
10+
11+
agent {
12+
enabled = true # read 'Qemu guest agent' section, change to true only when ready
13+
}
14+
15+
clone {
16+
vm_id = 9999
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 = 8192
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 = 100
41+
interface = "virtio0"
42+
}
43+
44+
vga {
45+
type = "serial0"
46+
}
47+
48+
initialization {
49+
ip_config {
50+
ipv4 {
51+
address = "dhcp"
52+
}
53+
}
54+
55+
user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id
56+
}
57+
58+
lifecycle {
59+
ignore_changes = [
60+
initialization[0].user_account[0].keys,
61+
initialization[0].user_account[0].password,
62+
initialization[0].user_account[0].username,
63+
initialization[0].user_data_file_id
64+
]
65+
}
66+
67+
}

‎terraform/proxmox/k3s-master3.tf

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
resource "proxmox_virtual_environment_vm" "K3s-Master3" {
2+
3+
# VM General Settings
4+
node_name = "prox"
5+
vm_id = 330
6+
name = "K3s-Master3"
7+
description = "Kubernetes master"
8+
tags = ["tofu", "debian", "infrastructure", "k3s"]
9+
started = true
10+
11+
agent {
12+
enabled = true # read 'Qemu guest agent' section, change to true only when ready
13+
}
14+
15+
clone {
16+
vm_id = 9998
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 = 8192
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 = "Fast2Tb"
40+
size = 100
41+
interface = "virtio0"
42+
}
43+
44+
vga {
45+
type = "serial0"
46+
}
47+
48+
initialization {
49+
ip_config {
50+
ipv4 {
51+
address = "dhcp"
52+
}
53+
}
54+
55+
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
56+
}
57+
58+
lifecycle {
59+
ignore_changes = [
60+
initialization[0].user_account[0].keys,
61+
initialization[0].user_account[0].password,
62+
initialization[0].user_account[0].username,
63+
initialization[0].user_data_file_id
64+
]
65+
}
66+
67+
}

‎terraform/proxmox/kasm.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ resource "proxmox_virtual_environment_vm" "Kasm" {
4444
initialization {
4545
ip_config {
4646
ipv4 {
47-
address = var.kasm_ip
48-
gateway = var.vlan_gateway
47+
address = data.bitwarden-secrets_secret.kasm_ip.value
48+
gateway = data.bitwarden-secrets_secret.vlan_gateway.value
4949
}
5050
}
5151

‎terraform/proxmox/npm.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ resource "proxmox_virtual_environment_vm" "NPM" {
4747
initialization {
4848
ip_config {
4949
ipv4 {
50-
address = var.npm_ip_address
51-
gateway = var.vlan_gateway
50+
address = data.bitwarden-secrets_secret.npm_ip_address.value
51+
gateway = data.bitwarden-secrets_secret.vlan_gateway.value
5252
}
5353
}
5454

‎terraform/proxmox/provider.tf

+4-23
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,9 @@ terraform {
44
source = "bpg/proxmox"
55
version = "0.70.0"
66
}
7-
}
8-
}
9-
10-
provider "proxmox" {
11-
endpoint = var.virtual_environment_endpoint
12-
password = var.ssh_password
13-
username = "root@pam"
14-
insecure = true
15-
16-
ssh {
17-
agent = true
18-
username = "root"
19-
password = var.ssh_password
20-
21-
node {
22-
name = "prox"
23-
address = var.prox_ip_address
24-
}
25-
26-
node {
27-
name = "pve2"
28-
address = var.pve2_ip_address
7+
bitwarden-secrets = {
8+
source = "sebastiaan-dev/bitwarden-secrets"
9+
version = "0.1.2"
2910
}
3011
}
31-
}
12+
}

‎terraform/proxmox/secrets.tf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
data "bitwarden-secrets_secret" "npm_ip_address" {
2+
id = "47ef68aa-32a9-45b0-835d-b2080006ce38"
3+
}
4+
5+
data "bitwarden-secrets_secret" "kasm_ip" {
6+
id = "0bc3c1a3-fc48-48ce-85c5-b2080007136a"
7+
}
8+
9+
data "bitwarden-secrets_secret" "vlan_gateway" {
10+
id = "af0ed579-05f8-405f-b0f3-b208000620ca"
11+
}
12+
13+
data "bitwarden-secrets_secret" "ubu_ip" {
14+
id = "d8017351-7a11-42e6-9e8d-b208000739b8"
15+
}
16+
17+
data "bitwarden-secrets_secret" "arrbuntu_ip" {
18+
id = "c65f8886-f6fb-4c17-bc79-b208000604bf"
19+
}

‎terraform/proxmox/ubu.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ resource "proxmox_virtual_environment_vm" "Ubu" {
4747
initialization {
4848
ip_config {
4949
ipv4 {
50-
address = var.ubu_ip_address
51-
gateway = var.vlan_gateway
50+
address = data.bitwarden-secrets_secret.ubu_ip.value
51+
gateway = data.bitwarden-secrets_secret.vlan_gateway.value
5252
}
5353
}
5454

‎terraform/proxmox/variables.tf

-93
This file was deleted.

‎terraform/secrets.tf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
data "bitwarden-secrets_secret" "virtual_environment_endpoint" {
2+
id = "a4ed343a-bb92-4beb-a421-b2080005bf98"
3+
}
4+
5+
data "bitwarden-secrets_secret" "virtual_environment_api" {
6+
id = "1d250f4a-ae18-4e19-934c-b2080005e132"
7+
}
8+
9+
data "bitwarden-secrets_secret" "ssh_password" {
10+
id = "68f1d77d-4e96-498a-9464-b208000679a4"
11+
}
12+
13+
data "bitwarden-secrets_secret" "prox_ip_address" {
14+
id = "d0c7f3ec-8277-4b1b-9a1b-b2080006b842"
15+
}
16+
17+
data "bitwarden-secrets_secret" "pve2_ip_address" {
18+
id = "17ab7869-c7a1-4ece-8c64-b20800075213"
19+
}

‎terraform/variables.tf

+6-88
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,8 @@
1-
# Define each required variable
2-
variable "arrbuntu_ip_address" {
3-
description = "IP address for Arrbuntu VM"
4-
type = string
5-
}
6-
7-
variable "init_username" {
8-
description = "Username for initial configuration"
9-
type = string
10-
}
11-
12-
variable "downloaders_ip_address" {
13-
description = "IP address for Downloaders VM"
14-
type = string
15-
}
16-
17-
variable "npm_ip_address" {
18-
description = "IP address for NPM VM"
19-
type = string
20-
}
21-
22-
variable "prox_ip_address" {
23-
description = "IP address for Proxmox server"
24-
type = string
25-
}
26-
27-
variable "kasm_ssh_ip" {
28-
description = "IP address for Kasm SSH"
29-
type = string
30-
}
31-
32-
variable "aws_secret_access_key" {
33-
description = "AWS Secret Access Key"
34-
type = string
35-
sensitive = true
36-
}
37-
38-
variable "vlan_gateway" {
39-
description = "Gateway IP for VLAN"
40-
type = string
41-
}
42-
43-
variable "virtual_environment_endpoint" {
44-
description = "Endpoint for virtual environment API"
45-
type = string
46-
}
47-
48-
variable "kasm_ip" {
49-
description = "IP address for Kasm"
50-
type = string
51-
}
52-
53-
variable "ssh_username" {
54-
description = "Username for SSH access"
55-
type = string
56-
}
57-
58-
variable "init_password" {
59-
description = "Password for initial configuration"
60-
type = string
61-
sensitive = true
62-
}
63-
64-
variable "aws_access_key_id" {
65-
description = "AWS Access Key ID"
66-
type = string
67-
}
68-
69-
variable "pve2_ip_address" {
70-
description = "IP address for PVE2 Proxmox server"
71-
type = string
72-
}
73-
741
variable "s3_endpoint" {
752
description = "Endpoint for S3 storage"
763
type = string
774
}
785

79-
variable "ubu_ip_address" {
80-
description = "IP address for Ubu VM"
81-
type = string
82-
}
83-
84-
variable "virtual_environment_api" {
85-
description = "API endpoint for virtual environment"
86-
type = string
87-
}
88-
89-
variable "ssh_password" {
90-
description = "Password for SSH access"
91-
type = string
92-
sensitive = true
93-
}
946

957
variable "grafana_auth" {
968
description = "Service Account token"
@@ -102,4 +14,10 @@ variable "grafana_url" {
10214
description = "Grafana Url"
10315
type = string
10416
sensitive = true
17+
}
18+
19+
variable "access_token" {
20+
description = "Access Token for BWS"
21+
type = string
22+
sensitive = true
10523
}

0 commit comments

Comments
 (0)
Please sign in to comment.