Skip to content

Commit a7ac8d6

Browse files
committedAug 2, 2024
testing
1 parent e45732b commit a7ac8d6

File tree

6 files changed

+83
-122
lines changed

6 files changed

+83
-122
lines changed
 

‎docker/scripts/kasm.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Navigate to the directory
4+
cd /home/mafyuh/iac/docker/kasm
5+
6+
# Run the command
7+
dcu

‎packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl

+9-5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ source "proxmox-clone" "ubuntu-server-jammy" {
3131

3232
# VM General Settings
3333
node = "pve2"
34+
35+
## See https://git.mafyuh.dev/mafyuh/iac/src/branch/main/terraform/ubuntu22-template2.tf
3436
clone_vm_id = "8101"
35-
vm_id = "9636"
37+
38+
vm_id = "9999"
3639
vm_name = "ubuntu-server-jammy"
37-
template_description = "Ubuntu Server jammy Image"
40+
template_description = "Custom Ubuntu Server see https://git.mafyuh.dev/mafyuh/iac/src/branch/main/packer/ubuntu-jammy/ubuntu-jammy.pkr.hcl"
3841

3942
# VM System Settings
4043
qemu_agent = true
@@ -43,7 +46,7 @@ source "proxmox-clone" "ubuntu-server-jammy" {
4346
scsi_controller = "virtio-scsi-pci"
4447

4548
disks {
46-
disk_size = "5G"
49+
disk_size = "4G"
4750
format = "raw"
4851
storage_pool = "Fast500Gb"
4952
type = "virtio"
@@ -65,6 +68,7 @@ source "proxmox-clone" "ubuntu-server-jammy" {
6568

6669

6770
ssh_username = "mafyuh"
71+
# WSL Filesystem
6872
ssh_private_key_file = "~/.ssh/id_rsa"
6973
}
7074

@@ -74,7 +78,7 @@ build {
7478
name = "ubuntu-server-jammy"
7579
sources = ["source.proxmox-clone.ubuntu-server-jammy"]
7680

77-
81+
## Cleanup for re-template
7882
provisioner "shell" {
7983
inline = [
8084
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
@@ -101,7 +105,7 @@ build {
101105
inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ]
102106
}
103107

104-
# Provisioning the VM Template with Docker Installation #4
108+
# Install Commonly Used Things - add alias's - set git config
105109
provisioner "shell" {
106110
inline = [
107111
"sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common qemu-guest-agent net-tools",

‎terraform/cloud-init.tf

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ resource "proxmox_virtual_environment_file" "cloud_config2" {
6363
sudo: ALL=(ALL) NOPASSWD:ALL
6464
runcmd:
6565
- apt update
66-
- apt install -y qemu-guest-agent
6766
- timedatectl set-timezone America/New_York
6867
- systemctl enable qemu-guest-agent
6968
- systemctl start qemu-guest-agent

‎terraform/kasm.tf

+63-53
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,74 @@
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", "iac-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 = var.kasm_ip
48-
gateway = var.vlan_gateway
49-
}
50-
}
51-
52-
user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id
53-
}
51+
user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id
52+
}
5453

55-
lifecycle {
56-
ignore_changes = [
57-
initialization[0].user_account[0].keys,
58-
initialization[0].user_account[0].password,
59-
initialization[0].user_account[0].username,
60-
initialization[0].user_data_file_id
61-
]
62-
}
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+
}
6362

63+
provisioner "remote-exec" {
64+
inline = [
65+
"sudo bash /home/mafyuh/iac/docker/scripts/kasm.sh"
66+
]
67+
connection {
68+
type = "ssh"
69+
user = "mafyuh"
70+
private_key = file("/home/mafyuh/.ssh/id_rsa")
71+
host = var.kasm_ssh_ip
72+
}
6473
}
74+
}

‎terraform/test.tf

-63
This file was deleted.

‎terraform/vars.tf

+4
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ variable "init_password" {
4848

4949
variable "kasm_ip" {
5050
type = string
51+
}
52+
53+
variable "kasm_ssh_ip" {
54+
type = string
5155
}

0 commit comments

Comments
 (0)
Please sign in to comment.