This commit is contained in:
Matt Reeves 2024-08-01 21:36:12 -04:00
parent e45732b1f1
commit a7ac8d678c
6 changed files with 86 additions and 125 deletions

7
docker/scripts/kasm.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
# Navigate to the directory
cd /home/mafyuh/iac/docker/kasm
# Run the command
dcu

View file

@ -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",

View file

@ -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

View file

@ -1,5 +1,4 @@
resource "proxmox_virtual_environment_vm" "Kasm" {
# VM General Settings
node_name = "pve2"
vm_id = 333
@ -13,7 +12,7 @@ resource "proxmox_virtual_environment_vm" "Kasm" {
}
clone {
vm_id = 8101
vm_id = 9999
}
# VM CPU Settings
@ -61,4 +60,15 @@ resource "proxmox_virtual_environment_vm" "Kasm" {
]
}
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
}
}
}

View file

@ -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
]
}
}

View file

@ -49,3 +49,7 @@ variable "init_password" {
variable "kasm_ip" {
type = string
}
variable "kasm_ssh_ip" {
type = string
}