Compare commits

..

No commits in common. "main" and "v0.2.3" have entirely different histories.
main ... v0.2.3

7 changed files with 18 additions and 136 deletions

View File

@ -6,74 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.5.10] - 2025-01-13
### Fixed
- make sure to not brick my reverse proxy
## [0.5.8] - 2025-01-12
### Fixed
- should've been equal
## [0.5.7] - 2025-01-12
### Added
- add trigger
## [0.5.6] - 2025-01-12
### Added
- remove range from ip
## [0.5.5] - 2025-01-12
### Other
- add caddy extension
## [0.5.4] - 2025-01-12
### Fixed
- add port for proxy
## [0.5.3] - 2025-01-12
### Added
- add remote node configuration
### Docs
- further docs
- add some docs
## [0.5.2] - 2025-01-11
### Added
- add ability to set disk size
## [0.5.1] - 2025-01-11
### Added
- add on boot true for all nodes
## [0.5.0] - 2024-12-01
### Added
- remove private variables
- remove provider
## [0.4.0] - 2024-11-30
### Added
- install churn
## [0.3.0] - 2024-11-30
### Added
- allow password to be null
### Fixed
- revert changes to ip
## [0.2.3] - 2024-11-29 ## [0.2.3] - 2024-11-29
### Fixed ### Fixed

View File

@ -1,3 +0,0 @@
# clank node
Setup up a virtual machine easily, and get an internal hostname for named usage

View File

@ -4,7 +4,5 @@ runcmd:
- apt install -y qemu-guest-agent neovim ranger - apt install -y qemu-guest-agent neovim ranger
- systemctl start qemu-guest-agent - systemctl start qemu-guest-agent
- systemctl enable --now sshd - systemctl enable --now sshd
- curl https://git.front.kjuulh.io/kjuulh/churn-v2/raw/branch/main/install.sh | bash
fqdn: ${hostname}.${domain} fqdn: ${hostname}.${domain}

View File

@ -1,4 +0,0 @@
@${name}-node ${replace(name, "_", "-")}.nodes.i.kjuulh.io
handle @${name}-node {
reverse_proxy ${split("/", ip)[0]}:80
}

42
node.tf
View File

@ -3,11 +3,6 @@ locals {
hostname = var.name hostname = var.name
domain = var.domain domain = var.domain
}) })
node_config = templatefile("${path.module}/files/node.caddy", {
name = var.name
ip = var.ip_address
})
} }
# Create a local copy of the file, to transfer to Proxmox # Create a local copy of the file, to transfer to Proxmox
@ -16,11 +11,6 @@ resource "local_file" "cloud_init_deb12_node" {
filename = "${path.module}/files/user_data_cloud_init_deb12_${var.name}.cfg" filename = "${path.module}/files/user_data_cloud_init_deb12_${var.name}.cfg"
} }
resource "local_file" "node_caddy" {
content = local.node_config
filename = "${path.module}/files/${var.name}.caddy"
}
# Transfer the file to the Proxmox Host # Transfer the file to the Proxmox Host
resource "null_resource" "cloud_init_deb12_node" { resource "null_resource" "cloud_init_deb12_node" {
connection { connection {
@ -31,7 +21,7 @@ resource "null_resource" "cloud_init_deb12_node" {
} }
provisioner "file" { provisioner "file" {
source = local_file.cloud_init_deb12_node.filename source = local_file.cloud_init_deb12_node.source
destination = "/var/lib/vz/snippets/cloud_init_deb12_${var.name}.yml" destination = "/var/lib/vz/snippets/cloud_init_deb12_${var.name}.yml"
} }
@ -40,37 +30,13 @@ resource "null_resource" "cloud_init_deb12_node" {
] ]
} }
resource "null_resource" "node_caddy_template" {
triggers = {
file_content = fileexists(local_file.node_caddy.filename) ? filemd5(local_file.node_caddy.filename) : timestamp()
}
connection {
type = "ssh"
user = "root"
private_key = var.ssh_private
host = var.proxy_ip
port = var.proxy_port
}
provisioner "file" {
source = local_file.node_caddy.filename
destination = "${var.proxy_location}/${var.name}.caddy"
}
depends_on = [
local_file.node_caddy
]
}
# Create the VM # Create the VM
resource "proxmox_vm_qemu" "node" { resource "proxmox_vm_qemu" "node" {
## Wait for the cloud-config file to exist ## Wait for the cloud-config file to exist
depends_on = [ depends_on = [
null_resource.cloud_init_deb12_node, null_resource.cloud_init_deb12_node
null_resource.node_caddy_template
] ]
name = var.name name = var.name
@ -99,8 +65,6 @@ resource "proxmox_vm_qemu" "node" {
bootdisk = "scsi0" bootdisk = "scsi0"
scsihw = "virtio-scsi-single" scsihw = "virtio-scsi-single"
onboot = true
serial { serial {
id = 0 id = 0
} }
@ -118,7 +82,7 @@ resource "proxmox_vm_qemu" "node" {
disk { disk {
storage = "local" storage = "local"
# The size of the disk should be at least as big as the disk in the template. If it's smaller, the disk will be recreated # The size of the disk should be at least as big as the disk in the template. If it's smaller, the disk will be recreated
size = var.disk_size size = "10G"
} }
} }
} }

View File

@ -8,3 +8,10 @@ terraform {
required_version = ">= 0.13" required_version = ">= 0.13"
} }
provider "proxmox" {
pm_api_url = var.proxmox_url
pm_user = var.proxmox_user
pm_password = var.proxmox_password
pm_tls_insecure = true
}

View File

@ -3,26 +3,19 @@ variable "proxmox_url" {
default = "https://proxmox.i.kjuulh.io/api2/json" default = "https://proxmox.i.kjuulh.io/api2/json"
} }
variable "proxmox_user" {
description = "proxmox username (eg. <name>@pve)"
}
variable "proxmox_password" {
description = "proxmox password"
}
variable "proxmox_ip" { variable "proxmox_ip" {
description = "the ip address of the proxmox instance" description = "the ip address of the proxmox instance"
default = "10.0.11.0" default = "10.0.11.0"
} }
variable "proxy_ip" {
description = "which ip to use for the caddy file"
default = "10.0.9.0"
}
variable "proxy_port" {
description = "which port to use for the caddy file"
default = 222
}
variable "proxy_location" {
description = "which where to place the files upstream"
default = "/root/wireguard/nodes"
}
variable "proxmox_node" { variable "proxmox_node" {
description = "which node is the vm associated" description = "which node is the vm associated"
default = "clank-smolboks-0" default = "clank-smolboks-0"
@ -62,7 +55,6 @@ variable "ssh_private" {
variable "user_password" { variable "user_password" {
sensitive = true sensitive = true
default = null
} }
variable "cpu" { variable "cpu" {
@ -72,7 +64,3 @@ variable "cpu" {
variable "memory" { variable "memory" {
default = 512 default = 512
} }
variable "disk_size" {
default = "10G"
}