Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
a8ceee4044 | |||
9087b75d5b
|
|||
8d7aea6894
|
|||
b793003532
|
|||
cd84d66fc8 | |||
b7a50ec2de
|
|||
2010b4328d | |||
e34b5f7b7b
|
|||
71963be181 | |||
50eeb579ce
|
|||
d228a92932 | |||
56eea90eff
|
|||
57199a21e8 | |||
57fd18ba04
|
|||
539f1ebb35 | |||
696fa83ef0
|
|||
e2f49c997c
|
|||
6fc69da087
|
|||
0f414cee73
|
|||
1f65d3c75e
|
|||
caa489fbf9 | |||
94b701b133
|
|||
90ecf5b603 | |||
f9a664763f
|
|||
789b2ab2a2
|
|||
bdb1847982 | |||
055fdb2282
|
|||
a5b431325c | |||
7b728727ff
|
|||
ffa5725a25
|
|||
3ab2e3da9b | |||
a3002d75a8
|
|||
bbff4df38a | |||
80e06acc47
|
|||
bb71f85fdd | |||
1f0b85ca04
|
|||
fbf00e99e1 | |||
7708a0cdf3
|
88
CHANGELOG.md
88
CHANGELOG.md
@@ -6,6 +6,94 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [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
|
||||
|
||||
### Fixed
|
||||
- use source for remote file
|
||||
|
||||
## [0.2.2] - 2024-11-29
|
||||
|
||||
### Fixed
|
||||
- make sure file names align
|
||||
|
||||
## [0.2.1] - 2024-11-29
|
||||
|
||||
### Fixed
|
||||
- cores and bootdisk
|
||||
|
||||
## [0.2.0] - 2024-11-29
|
||||
|
||||
### Added
|
||||
- include template
|
||||
|
||||
## [0.1.0] - 2024-11-29
|
||||
|
||||
### Added
|
||||
|
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# clank node
|
||||
|
||||
Setup up a virtual machine easily, and get an internal hostname for named usage
|
10
files/cloud_init_deb12.cloud_config
Normal file
10
files/cloud_init_deb12.cloud_config
Normal file
@@ -0,0 +1,10 @@
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- apt update
|
||||
- apt install -y qemu-guest-agent neovim ranger
|
||||
- systemctl start qemu-guest-agent
|
||||
- systemctl enable --now sshd
|
||||
- curl https://git.front.kjuulh.io/kjuulh/churn-v2/raw/branch/main/install.sh | bash
|
||||
|
||||
|
||||
fqdn: ${hostname}.${domain}
|
4
files/node.caddy
Normal file
4
files/node.caddy
Normal file
@@ -0,0 +1,4 @@
|
||||
@${name}-node ${replace(name, "_", "-")}.nodes.i.kjuulh.io
|
||||
handle @${name}-node {
|
||||
reverse_proxy ${split("/", ip)[0]}:80
|
||||
}
|
49
node.tf
49
node.tf
@@ -3,6 +3,11 @@ locals {
|
||||
hostname = var.name
|
||||
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
|
||||
@@ -11,6 +16,11 @@ resource "local_file" "cloud_init_deb12_node" {
|
||||
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
|
||||
resource "null_resource" "cloud_init_deb12_node" {
|
||||
connection {
|
||||
@@ -22,7 +32,7 @@ resource "null_resource" "cloud_init_deb12_node" {
|
||||
|
||||
provisioner "file" {
|
||||
source = local_file.cloud_init_deb12_node.filename
|
||||
destination = "/var/lib/vz/snippets/cloud_init_deb12_node_${var.name}.yml"
|
||||
destination = "/var/lib/vz/snippets/cloud_init_deb12_${var.name}.yml"
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
@@ -30,13 +40,37 @@ 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
|
||||
resource "proxmox_vm_qemu" "node" {
|
||||
## Wait for the cloud-config file to exist
|
||||
|
||||
depends_on = [
|
||||
null_resource.cloud_init_deb12_node
|
||||
null_resource.cloud_init_deb12_node,
|
||||
null_resource.node_caddy_template
|
||||
]
|
||||
|
||||
name = var.name
|
||||
@@ -47,10 +81,10 @@ resource "proxmox_vm_qemu" "node" {
|
||||
os_type = "cloud-init"
|
||||
|
||||
# Cloud init options
|
||||
cicustom = "vendor=local:snippets/cloud_init_deb12_node.yml"
|
||||
cicustom = "vendor=local:snippets/cloud_init_deb12_${var.name}.yml"
|
||||
ipconfig0 = "ip=${var.ip_address},gw=${var.gateway}"
|
||||
|
||||
cpu = var.cpu
|
||||
cores = var.cpu
|
||||
memory = var.memory
|
||||
agent = 1
|
||||
|
||||
@@ -65,6 +99,8 @@ resource "proxmox_vm_qemu" "node" {
|
||||
bootdisk = "scsi0"
|
||||
scsihw = "virtio-scsi-single"
|
||||
|
||||
onboot = true
|
||||
|
||||
serial {
|
||||
id = 0
|
||||
}
|
||||
@@ -82,7 +118,7 @@ resource "proxmox_vm_qemu" "node" {
|
||||
disk {
|
||||
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
|
||||
size = "10G"
|
||||
size = var.disk_size
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,7 +137,8 @@ resource "proxmox_vm_qemu" "node" {
|
||||
## TF to think this needs to be rebuilt on every apply
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network
|
||||
network,
|
||||
bootdisk
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@@ -8,10 +8,3 @@ terraform {
|
||||
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
|
||||
}
|
||||
|
||||
|
28
variables.tf
28
variables.tf
@@ -3,19 +3,26 @@ variable "proxmox_url" {
|
||||
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" {
|
||||
description = "the ip address of the proxmox instance"
|
||||
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" {
|
||||
description = "which node is the vm associated"
|
||||
default = "clank-smolboks-0"
|
||||
@@ -55,6 +62,7 @@ variable "ssh_private" {
|
||||
|
||||
variable "user_password" {
|
||||
sensitive = true
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "cpu" {
|
||||
@@ -64,3 +72,7 @@ variable "cpu" {
|
||||
variable "memory" {
|
||||
default = 512
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
default = "10G"
|
||||
}
|
||||
|
Reference in New Issue
Block a user