From 8a29978386af30c0bb8833716a7889d9527ff246 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Wed, 31 Jul 2024 21:01:17 -0400 Subject: [PATCH 01/12] add alias, fix apt playbook --- ansible/playbooks/alias.yml | 15 +++++++++++++++ ansible/playbooks/apt.yml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ansible/playbooks/alias.yml diff --git a/ansible/playbooks/alias.yml b/ansible/playbooks/alias.yml new file mode 100644 index 0000000..4d46e62 --- /dev/null +++ b/ansible/playbooks/alias.yml @@ -0,0 +1,15 @@ +--- +- hosts: all + become: true + tasks: + - name: Add alias for docker compose up -d in .bashrc + lineinfile: + path: "/home/{{ ansible_user }}/.bashrc" + line: "alias dcu='docker compose up -d'" + state: present + + - name: Add alias for docker compose down in .bashrc + lineinfile: + path: "/home/{{ ansible_user }}/.bashrc" + line: "alias dcd='docker compose down'" + state: present \ No newline at end of file diff --git a/ansible/playbooks/apt.yml b/ansible/playbooks/apt.yml index 05311be..673acbe 100644 --- a/ansible/playbooks/apt.yml +++ b/ansible/playbooks/apt.yml @@ -1,5 +1,5 @@ - hosts: "*" - become: yes + become: true tasks: - name: apt apt: From 94ad15a83d2ff8905d9cb2faff20cdb1aaa3d1ed Mon Sep 17 00:00:00 2001 From: mafyuh Date: Wed, 31 Jul 2024 21:15:05 -0400 Subject: [PATCH 02/12] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 61d6502..97ba441 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Currently migrating [Auto-Homelab](https://git.mafyuh.dev/mafyuh/Auto-Homelab), ToDo - [ ] Update Readme -- [x] Migrate all containers to use this repo (DB migrations) +- [ ] Update Issue Templates +- [x] Migrate all containers to use this repo - [x] Get OpenTofu migrated to this repo - [ ] Get Kubernetes repo migrated over - [ ] Re-bootstrap Flux From f8575efb8c9bd64524423b3c2afa08eb6f1fc0b8 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Wed, 31 Jul 2024 21:23:37 -0400 Subject: [PATCH 03/12] fixing kasm --- terraform/kasm.tf | 3 ++- terraform/vars.tf | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/terraform/kasm.tf b/terraform/kasm.tf index c5cd0c8..8cd1f6f 100644 --- a/terraform/kasm.tf +++ b/terraform/kasm.tf @@ -44,7 +44,8 @@ resource "proxmox_virtual_environment_vm" "Kasm" { initialization { ip_config { ipv4 { - address = "dhcp" + address = var.kasm_ip + gateway = var.vlan_gateway } } diff --git a/terraform/vars.tf b/terraform/vars.tf index 3462ab1..47448eb 100644 --- a/terraform/vars.tf +++ b/terraform/vars.tf @@ -44,4 +44,8 @@ variable "init_username" { variable "init_password" { type = string +} + +variable "kasm_ip" { + type = string } \ No newline at end of file From 65b2f3cd08a54affec3c26a3ac6bd992f0fcac21 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 1 Aug 2024 02:00:33 +0000 Subject: [PATCH 04/12] :arrow_up: Update ollama/ollama Docker tag to v0.3.2 --- docker/AI/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/AI/docker-compose.yml b/docker/AI/docker-compose.yml index e713044..c2cdc88 100644 --- a/docker/AI/docker-compose.yml +++ b/docker/AI/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: ollama: - image: ollama/ollama:0.3.1 + image: ollama/ollama:0.3.2 container_name: ollama restart: unless-stopped volumes: From abbf6faaebea36d6548a66b5ea1b9e0a2d70b9f3 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 1 Aug 2024 03:00:29 +0000 Subject: [PATCH 05/12] :arrow_up: Update ghcr.io/linuxserver/sabnzbd Docker digest to dda7003 --- docker/downloaders/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/downloaders/docker-compose.yml b/docker/downloaders/docker-compose.yml index 07042d0..50c698a 100644 --- a/docker/downloaders/docker-compose.yml +++ b/docker/downloaders/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.9' services: sabnzbd: - image: ghcr.io/linuxserver/sabnzbd@sha256:d6a2a967d47b495c5342bc23de76d35eeb2f3ceb53c7be51885ad25f95dffe9b + image: ghcr.io/linuxserver/sabnzbd@sha256:dda700370ad4281d8ffda4fbdad8ac3f720a2829936eafc794fca652095ed4be container_name: sabnzbd environment: - PUID=1000 From 81c394163445a3d9c54f9c8a31c41660a54cc84f Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Wed, 31 Jul 2024 23:45:46 -0400 Subject: [PATCH 06/12] test packer --- .gitignore | 2 + packer/ubuntu-noble/files/pve.cfg | 1 + packer/ubuntu-noble/ubuntu-jammy.pkr.hcl | 116 +++++++++++++++++++++++ terraform/cloud-init.tf | 4 - terraform/kasm.tf | 2 +- 5 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 packer/ubuntu-noble/files/pve.cfg create mode 100644 packer/ubuntu-noble/ubuntu-jammy.pkr.hcl diff --git a/.gitignore b/.gitignore index bb05696..29ffce3 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ terraform.rc ## Kubernetes /kubernetes/cluster/apps/staging +## Packer +credentials.pkr.hcl diff --git a/packer/ubuntu-noble/files/pve.cfg b/packer/ubuntu-noble/files/pve.cfg new file mode 100644 index 0000000..a78672c --- /dev/null +++ b/packer/ubuntu-noble/files/pve.cfg @@ -0,0 +1 @@ +datasource_list: [ConfigDrive, NoCloud] \ No newline at end of file diff --git a/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl b/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl new file mode 100644 index 0000000..cfe46fa --- /dev/null +++ b/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl @@ -0,0 +1,116 @@ +packer { + required_plugins { + name = { + version = "~> 1" + source = "github.com/hashicorp/proxmox" + } + } +} + +variable "proxmox_api_url" { + type = string +} + +variable "proxmox_api_token_id" { + type = string +} + +variable "proxmox_api_token_secret" { + type = string + sensitive = true +} + +# Resource Definiation for the VM Template +source "proxmox-clone" "ubuntu-server-jammy" { + + # Proxmox Connection Settings + proxmox_url = "${var.proxmox_api_url}" + username = "${var.proxmox_api_token_id}" + token = "${var.proxmox_api_token_secret}" + insecure_skip_tls_verify = true + + # VM General Settings + node = "prox" + clone_vm_id = "8101" + vm_id = "9636" + vm_name = "ubuntu-server-jammy" + template_description = "Ubuntu Server jammy Image" + + # VM System Settings + qemu_agent = true + + # VM Hard Disk Settings + scsi_controller = "virtio-scsi-pci" + + disks { + disk_size = "5G" + format = "raw" + storage_pool = "Fast2Tb" + type = "virtio" + } + + # VM CPU Settings + cores = "2" + cpu_type = "x86-64-v2-AES" + + # VM Memory Settings + memory = "2048" + + # VM Network Settings + network_adapters { + model = "virtio" + bridge = "vmbr0" + firewall = "false" + } + + # VM Cloud-Init Settings + cloud_init = true + cloud_init_storage_pool = "local-lvm" + + ssh_username = "mafyuh" + ssh_private_key_file = "~/.ssh/id_rsa" +} + +# Build Definition to create the VM Template +build { + + name = "ubuntu-server-jammy" + sources = ["source.proxmox-clone.ubuntu-server-jammy"] + + # 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" + ] + } + + # Provisioning the VM Template for Cloud-Init Integration in Proxmox #2 + provisioner "file" { + source = "ubuntu-noble/files/pve.cfg" + destination = "/tmp/pve.cfg" + } + + # Provisioning the VM Template for Cloud-Init Integration in Proxmox #3 + provisioner "shell" { + inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ] + } + + # Provisioning the VM Template with Docker Installation #4 + provisioner "shell" { + inline = [ + "sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common qemu-guest-agent net-tools", + "curl -fsSL https://get.docker.com | sudo sh", + "echo \"alias dcu='docker compose up -d'\" >> ~/.bashrc", + "sudo apt-get -y update" + ] + } +} \ No newline at end of file diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index ae35cdd..83c3f65 100644 --- a/terraform/cloud-init.tf +++ b/terraform/cloud-init.tf @@ -30,8 +30,6 @@ resource "proxmox_virtual_environment_file" "cloud_config" { - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac' - su - mafyuh -c 'git config --global user.name "Mafyuh"' - su - mafyuh -c 'git config --global user.email "matt@mafyuh.com"' - - su - mafyuh -c 'echo "alias dcu=\'docker compose up -d\'" >> /home/mafyuh/.bashrc - - su - mafyuh -c 'echo "alias dcd=\'docker compose down\'" >> /home/mafyuh/.bashrc - echo "done" > /tmp/cloud-config.done EOF @@ -67,8 +65,6 @@ resource "proxmox_virtual_environment_file" "cloud_config2" { - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac' - su - mafyuh -c 'git config --global user.name "Mafyuh"' - su - mafyuh -c 'git config --global user.email "matt@mafyuh.com"' - - su - mafyuh -c 'echo "alias dcu=\'docker compose up -d\'" >> /home/mafyuh/.bashrc - - su - mafyuh -c 'echo "alias dcd=\'docker compose down\'" >> /home/mafyuh/.bashrc - echo "done" > /tmp/cloud-config.done EOF diff --git a/terraform/kasm.tf b/terraform/kasm.tf index 8cd1f6f..82ba43b 100644 --- a/terraform/kasm.tf +++ b/terraform/kasm.tf @@ -5,7 +5,7 @@ resource "proxmox_virtual_environment_vm" "Kasm" { vm_id = 333 name = "Kasm" description = "kasm" - tags = ["tofu", "ubuntu-22", "auto-homelab-repo"] + tags = ["tofu", "ubuntu-22", "iac-repo"] started = true agent { From ee6e38b07d4766bdc22b2b0f0cbd7b4fb84956f7 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Thu, 1 Aug 2024 00:33:14 -0400 Subject: [PATCH 07/12] working packer template with terraform clones --- packer/ubuntu-noble/ubuntu-jammy.pkr.hcl | 24 ++++----- terraform/cloud-init.tf | 12 +++-- terraform/test.tf | 63 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 terraform/test.tf diff --git a/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl b/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl index cfe46fa..dd9bf2f 100644 --- a/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl +++ b/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl @@ -30,7 +30,7 @@ source "proxmox-clone" "ubuntu-server-jammy" { insecure_skip_tls_verify = true # VM General Settings - node = "prox" + node = "pve2" clone_vm_id = "8101" vm_id = "9636" vm_name = "ubuntu-server-jammy" @@ -45,7 +45,7 @@ source "proxmox-clone" "ubuntu-server-jammy" { disks { disk_size = "5G" format = "raw" - storage_pool = "Fast2Tb" + storage_pool = "Fast500Gb" type = "virtio" } @@ -61,23 +61,20 @@ source "proxmox-clone" "ubuntu-server-jammy" { model = "virtio" bridge = "vmbr0" firewall = "false" - } - - # VM Cloud-Init Settings - cloud_init = true - cloud_init_storage_pool = "local-lvm" + } + ssh_username = "mafyuh" ssh_private_key_file = "~/.ssh/id_rsa" } -# Build Definition to create the VM Template + build { name = "ubuntu-server-jammy" sources = ["source.proxmox-clone.ubuntu-server-jammy"] - # 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", @@ -93,13 +90,13 @@ build { ] } - # Provisioning the VM Template for Cloud-Init Integration in Proxmox #2 + provisioner "file" { - source = "ubuntu-noble/files/pve.cfg" + source = "files/pve.cfg" destination = "/tmp/pve.cfg" } - # Provisioning the VM Template for Cloud-Init Integration in Proxmox #3 + provisioner "shell" { inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ] } @@ -110,6 +107,9 @@ build { "sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common qemu-guest-agent net-tools", "curl -fsSL https://get.docker.com | sudo sh", "echo \"alias dcu='docker compose up -d'\" >> ~/.bashrc", + "echo \"alias dcd='docker compose down'\" >> ~/.bashrc", + "git config --global user.name \"Mafyuh\"", + "git config --global user.email \"matt@mafyuh.com\"", "sudo apt-get -y update" ] } diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index 83c3f65..46d742e 100644 --- a/terraform/cloud-init.tf +++ b/terraform/cloud-init.tf @@ -2,6 +2,10 @@ data "local_file" "ssh_public_key" { filename = "/home/mafyuh/.ssh/main_key.pub" } +data "local_file" "ssh_public_key_2" { + filename = "/home/mafyuh/.ssh/id_rsa.pub" +} + resource "proxmox_virtual_environment_file" "cloud_config" { content_type = "snippets" datastore_id = "Slow4tb" @@ -19,6 +23,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" { shell: /bin/bash ssh_authorized_keys: - ${trimspace(data.local_file.ssh_public_key.content)} + - ${trimspace(data.local_file.ssh_public_key_2.content)} sudo: ALL=(ALL) NOPASSWD:ALL runcmd: - apt update @@ -54,17 +59,16 @@ resource "proxmox_virtual_environment_file" "cloud_config2" { shell: /bin/bash ssh_authorized_keys: - ${trimspace(data.local_file.ssh_public_key.content)} + - ${trimspace(data.local_file.ssh_public_key_2.content)} sudo: ALL=(ALL) NOPASSWD:ALL runcmd: - apt update - - apt install -y qemu-guest-agent net-tools nfs-common + - apt install -y qemu-guest-agent - timedatectl set-timezone America/New_York - systemctl enable qemu-guest-agent - systemctl start qemu-guest-agent - - curl -fsSL https://get.docker.com | sudo sh + - apt upgrade -y - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac' - - su - mafyuh -c 'git config --global user.name "Mafyuh"' - - su - mafyuh -c 'git config --global user.email "matt@mafyuh.com"' - echo "done" > /tmp/cloud-config.done EOF diff --git a/terraform/test.tf b/terraform/test.tf new file mode 100644 index 0000000..87c0ac6 --- /dev/null +++ b/terraform/test.tf @@ -0,0 +1,63 @@ +resource "proxmox_virtual_environment_vm" "test" { + + # VM General Settings + node_name = "pve2" + vm_id = 335 + name = "test" + description = "test" + tags = ["tofu", "ubuntu-22", "iac-repo"] + started = true + + agent { + enabled = true + } + + clone { + vm_id = 9636 + } + + # VM CPU Settings + cpu { + cores = 4 + type = "host" + architecture = "x86_64" + } + + # VM Memory Settings + memory { + dedicated = 4096 + } + + # VM Network Settings + network_device { + bridge = "vmbr0" + vlan_id = 1 + } + + # VM Disk Settings + disk { + datastore_id = "Fast500Gb" + size = 10 + interface = "scsi0" + } + + initialization { + ip_config { + ipv4 { + address = "dhcp" + } + } + + user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id + } + + lifecycle { + ignore_changes = [ + initialization[0].user_account[0].keys, + initialization[0].user_account[0].password, + initialization[0].user_account[0].username, + initialization[0].user_data_file_id + ] + } + +} From 6ad64146c6d0360c9d5db55788e400b4a82becc7 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Thu, 1 Aug 2024 00:34:26 -0400 Subject: [PATCH 08/12] renaming folders --- packer/ubuntu-jammy/files/pve.cfg | 1 + packer/{ubuntu-noble => ubuntu-jammy}/ubuntu-jammy.pkr.hcl | 0 2 files changed, 1 insertion(+) create mode 100644 packer/ubuntu-jammy/files/pve.cfg rename packer/{ubuntu-noble => ubuntu-jammy}/ubuntu-jammy.pkr.hcl (100%) diff --git a/packer/ubuntu-jammy/files/pve.cfg b/packer/ubuntu-jammy/files/pve.cfg new file mode 100644 index 0000000..a78672c --- /dev/null +++ b/packer/ubuntu-jammy/files/pve.cfg @@ -0,0 +1 @@ +datasource_list: [ConfigDrive, NoCloud] \ No newline at end of file diff --git a/packer/ubuntu-noble/ubuntu-jammy.pkr.hcl b/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl similarity index 100% rename from packer/ubuntu-noble/ubuntu-jammy.pkr.hcl rename to packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl From a7ac8d678ca61581e767c8a5843ffc81076170db Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Thu, 1 Aug 2024 21:36:12 -0400 Subject: [PATCH 09/12] testing --- docker/scripts/kasm.sh | 7 ++ packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl | 14 ++- terraform/cloud-init.tf | 1 - terraform/kasm.tf | 122 ++++++++++++----------- terraform/test.tf | 63 ------------ terraform/vars.tf | 4 + 6 files changed, 86 insertions(+), 125 deletions(-) create mode 100644 docker/scripts/kasm.sh delete mode 100644 terraform/test.tf diff --git a/docker/scripts/kasm.sh b/docker/scripts/kasm.sh new file mode 100644 index 0000000..ebd90e1 --- /dev/null +++ b/docker/scripts/kasm.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Navigate to the directory +cd /home/mafyuh/iac/docker/kasm + +# Run the command +dcu diff --git a/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl b/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl index dd9bf2f..ee624ed 100644 --- a/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl +++ b/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl @@ -31,10 +31,13 @@ source "proxmox-clone" "ubuntu-server-jammy" { # VM General Settings node = "pve2" + + ## See https://git.mafyuh.dev/mafyuh/iac/src/branch/main/terraform/ubuntu22-template2.tf clone_vm_id = "8101" - vm_id = "9636" + + vm_id = "9999" vm_name = "ubuntu-server-jammy" - template_description = "Ubuntu Server jammy Image" + template_description = "Custom Ubuntu Server see https://git.mafyuh.dev/mafyuh/iac/src/branch/main/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl" # VM System Settings qemu_agent = true @@ -43,7 +46,7 @@ source "proxmox-clone" "ubuntu-server-jammy" { scsi_controller = "virtio-scsi-pci" disks { - disk_size = "5G" + disk_size = "4G" format = "raw" storage_pool = "Fast500Gb" type = "virtio" @@ -65,6 +68,7 @@ source "proxmox-clone" "ubuntu-server-jammy" { ssh_username = "mafyuh" + # WSL Filesystem ssh_private_key_file = "~/.ssh/id_rsa" } @@ -74,7 +78,7 @@ build { name = "ubuntu-server-jammy" sources = ["source.proxmox-clone.ubuntu-server-jammy"] - + ## Cleanup for re-template provisioner "shell" { inline = [ "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done", @@ -101,7 +105,7 @@ build { inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ] } - # Provisioning the VM Template with Docker Installation #4 + # Install Commonly Used Things - add alias's - set git config provisioner "shell" { inline = [ "sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common qemu-guest-agent net-tools", diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index 46d742e..f322133 100644 --- a/terraform/cloud-init.tf +++ b/terraform/cloud-init.tf @@ -63,7 +63,6 @@ resource "proxmox_virtual_environment_file" "cloud_config2" { sudo: ALL=(ALL) NOPASSWD:ALL runcmd: - apt update - - apt install -y qemu-guest-agent - timedatectl set-timezone America/New_York - systemctl enable qemu-guest-agent - systemctl start qemu-guest-agent diff --git a/terraform/kasm.tf b/terraform/kasm.tf index 82ba43b..ad4c440 100644 --- a/terraform/kasm.tf +++ b/terraform/kasm.tf @@ -1,64 +1,74 @@ resource "proxmox_virtual_environment_vm" "Kasm" { + # VM General Settings + node_name = "pve2" + vm_id = 333 + name = "Kasm" + description = "kasm" + tags = ["tofu", "ubuntu-22", "iac-repo"] + started = true - # VM General Settings - node_name = "pve2" - vm_id = 333 - name = "Kasm" - description = "kasm" - tags = ["tofu", "ubuntu-22", "iac-repo"] - started = true + agent { + enabled = true + } - agent { - enabled = true + clone { + vm_id = 9999 + } + + # VM CPU Settings + cpu { + cores = 4 + type = "host" + architecture = "x86_64" + } + + # VM Memory Settings + memory { + dedicated = 4096 + } + + # VM Network Settings + network_device { + bridge = "vmbr0" + vlan_id = 1 + } + + # VM Disk Settings + disk { + datastore_id = "local-lvm" + size = 100 + interface = "scsi0" + } + + initialization { + ip_config { + ipv4 { + address = var.kasm_ip + gateway = var.vlan_gateway + } } - clone { - vm_id = 8101 - } - - # VM CPU Settings - cpu { - cores = 4 - type = "host" - architecture = "x86_64" - } - - # VM Memory Settings - memory { - dedicated = 4096 - } + user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id + } - # VM Network Settings - network_device { - bridge = "vmbr0" - vlan_id = 1 - } - - # VM Disk Settings - disk { - datastore_id = "local-lvm" - size = 100 - interface = "scsi0" - } - - initialization { - ip_config { - ipv4 { - address = var.kasm_ip - gateway = var.vlan_gateway - } - } - - user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id - } - - lifecycle { - ignore_changes = [ - initialization[0].user_account[0].keys, - initialization[0].user_account[0].password, - initialization[0].user_account[0].username, - initialization[0].user_data_file_id - ] - } + lifecycle { + ignore_changes = [ + initialization[0].user_account[0].keys, + initialization[0].user_account[0].password, + initialization[0].user_account[0].username, + initialization[0].user_data_file_id + ] + } +provisioner "remote-exec" { + inline = [ + "sudo bash /home/mafyuh/iac/docker/scripts/kasm.sh" + ] + connection { + type = "ssh" + user = "mafyuh" + private_key = file("/home/mafyuh/.ssh/id_rsa") + host = var.kasm_ssh_ip + } } +} \ No newline at end of file diff --git a/terraform/test.tf b/terraform/test.tf deleted file mode 100644 index 87c0ac6..0000000 --- a/terraform/test.tf +++ /dev/null @@ -1,63 +0,0 @@ -resource "proxmox_virtual_environment_vm" "test" { - - # VM General Settings - node_name = "pve2" - vm_id = 335 - name = "test" - description = "test" - tags = ["tofu", "ubuntu-22", "iac-repo"] - started = true - - agent { - enabled = true - } - - clone { - vm_id = 9636 - } - - # VM CPU Settings - cpu { - cores = 4 - type = "host" - architecture = "x86_64" - } - - # VM Memory Settings - memory { - dedicated = 4096 - } - - # VM Network Settings - network_device { - bridge = "vmbr0" - vlan_id = 1 - } - - # VM Disk Settings - disk { - datastore_id = "Fast500Gb" - size = 10 - interface = "scsi0" - } - - initialization { - ip_config { - ipv4 { - address = "dhcp" - } - } - - user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id - } - - lifecycle { - ignore_changes = [ - initialization[0].user_account[0].keys, - initialization[0].user_account[0].password, - initialization[0].user_account[0].username, - initialization[0].user_data_file_id - ] - } - -} diff --git a/terraform/vars.tf b/terraform/vars.tf index 47448eb..cb9fecd 100644 --- a/terraform/vars.tf +++ b/terraform/vars.tf @@ -48,4 +48,8 @@ variable "init_password" { variable "kasm_ip" { type = string +} + +variable "kasm_ssh_ip" { + type = string } \ No newline at end of file From 042c92b21f5df5a700bae50c164c656b3bfee969 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Thu, 1 Aug 2024 21:40:29 -0400 Subject: [PATCH 10/12] test kasm script --- docker/scripts/kasm.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker/scripts/kasm.sh b/docker/scripts/kasm.sh index ebd90e1..e287f43 100644 --- a/docker/scripts/kasm.sh +++ b/docker/scripts/kasm.sh @@ -3,5 +3,8 @@ # Navigate to the directory cd /home/mafyuh/iac/docker/kasm -# Run the command -dcu +# Pull the latest changes +git pull + +# Run docker compose up -d +dcu \ No newline at end of file From bf210baa12db2b7d959a7c9222acafe703bcf961 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Thu, 1 Aug 2024 21:50:43 -0400 Subject: [PATCH 11/12] so dope, no need to spin up containers manually --- docker/scripts/kasm.sh | 10 ---------- terraform/kasm.tf | 4 +++- 2 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 docker/scripts/kasm.sh diff --git a/docker/scripts/kasm.sh b/docker/scripts/kasm.sh deleted file mode 100644 index e287f43..0000000 --- a/docker/scripts/kasm.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Navigate to the directory -cd /home/mafyuh/iac/docker/kasm - -# Pull the latest changes -git pull - -# Run docker compose up -d -dcu \ No newline at end of file diff --git a/terraform/kasm.tf b/terraform/kasm.tf index ad4c440..7429341 100644 --- a/terraform/kasm.tf +++ b/terraform/kasm.tf @@ -62,7 +62,9 @@ resource "proxmox_virtual_environment_vm" "Kasm" { provisioner "remote-exec" { inline = [ - "sudo bash /home/mafyuh/iac/docker/scripts/kasm.sh" + "cd /home/mafyuh/iac/docker/kasm", + "git pull", + "docker compose up -d" ] connection { type = "ssh" From 209e551c4b124768d6b0aa48206c2df3e9e70538 Mon Sep 17 00:00:00 2001 From: mafyuh Date: Thu, 1 Aug 2024 22:26:49 -0400 Subject: [PATCH 12/12] Update docker/authentik/docker-compose.yml --- docker/authentik/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/authentik/docker-compose.yml b/docker/authentik/docker-compose.yml index e70cf5b..ed049d2 100644 --- a/docker/authentik/docker-compose.yml +++ b/docker/authentik/docker-compose.yml @@ -32,7 +32,7 @@ services: volumes: - redis:/data server: - image: ghcr.io/goauthentik/server@sha256:a98f95518269d01bb812eb0e12c6647f3d08a36e37b9fdbdccf9345d4431b9f0 + image: ghcr.io/goauthentik/server@sha256:f79b6cf35b29a8591136afb633ddd46da303e9cd2ca82c7cdfbd020a780e15e8 restart: unless-stopped command: server environment: @@ -53,7 +53,7 @@ services: - postgresql - redis worker: - image: ghcr.io/goauthentik/server@sha256:a98f95518269d01bb812eb0e12c6647f3d08a36e37b9fdbdccf9345d4431b9f0 + image: ghcr.io/goauthentik/server@sha256:f79b6cf35b29a8591136afb633ddd46da303e9cd2ca82c7cdfbd020a780e15e8 restart: unless-stopped command: worker environment: