All checks were successful
Update Version / Update Version (push) Successful in 9s
129 lines
3.9 KiB
HCL
129 lines
3.9 KiB
HCL
# git.auengun.net/homelab/opentofu-common
|
|
# Copyright (C) 2024 GregoryDosh
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# SPDX-FileCopyrightText: 2024 GregoryDosh
|
|
|
|
variable "proxmox_lxc" {
|
|
description = "Options to configure the Proxmox LXC module."
|
|
|
|
type = object({
|
|
# Create an LXC in Proxmox?
|
|
enabled = optional(bool, false)
|
|
|
|
app_mp_path = optional(string, "/mnt/container/storage-backed-mount-point")
|
|
app_mp_storage_pool = optional(string, "Samsung970EvoPlus")
|
|
app_mp_storage_size = optional(string, "4G")
|
|
app_mp_backup = optional(bool, true)
|
|
|
|
# These pass through to the tellmate module
|
|
# but with some homelab specifics as I go.
|
|
bwlimit = optional(number, 0)
|
|
cmode = optional(string, "tty")
|
|
cores = optional(number, 1)
|
|
cpuunits = optional(number, 100)
|
|
force = optional(bool, false)
|
|
fuse = optional(bool, false)
|
|
keyctl = optional(bool, false)
|
|
memory = optional(number, 1024)
|
|
mount = optional(string, "")
|
|
nameserver = optional(string, "172.16.16.10")
|
|
nesting = optional(bool, true)
|
|
onboot = optional(bool, true)
|
|
ostemplate = optional(string, "hyperion-nfs:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst")
|
|
pve_node = optional(string, "the-infinite-forest")
|
|
searchdomain = optional(string, "auengun.net")
|
|
ssh_public_keys = optional(string, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMXkv/D0gs/1VCz7xyBEcb6zEaO4av3fwOzYEUsrIGVP")
|
|
start = optional(bool, true)
|
|
startup = optional(string, "")
|
|
storage_pool = optional(string, "Samsung970EvoPlus")
|
|
storage_size = optional(string, "10G")
|
|
swap = optional(number, 512)
|
|
unprivileged = optional(bool, true)
|
|
vlan_tag = optional(number, 20)
|
|
vmid = optional(number, 0)
|
|
|
|
# Slight detour here so I can conform things
|
|
# easier for the validation of the module.
|
|
tags = optional(list(string))
|
|
})
|
|
}
|
|
|
|
# Proxmox LXC
|
|
# https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/resources/lxc
|
|
resource "proxmox_lxc" "container" {
|
|
target_node = var.proxmox_lxc.pve_node
|
|
hostname = var.hostname
|
|
vmid = var.proxmox_lxc.vmid
|
|
|
|
nameserver = var.proxmox_lxc.nameserver
|
|
searchdomain = var.proxmox_lxc.searchdomain
|
|
|
|
ostemplate = var.proxmox_lxc.ostemplate
|
|
unprivileged = var.proxmox_lxc.unprivileged
|
|
|
|
features {
|
|
fuse = var.proxmox_lxc.fuse
|
|
keyctl = var.proxmox_lxc.keyctl
|
|
mount = var.proxmox_lxc.mount
|
|
nesting = var.proxmox_lxc.nesting
|
|
}
|
|
|
|
memory = var.proxmox_lxc.memory
|
|
swap = var.proxmox_lxc.swap
|
|
|
|
bwlimit = var.proxmox_lxc.bwlimit
|
|
cores = var.proxmox_lxc.cores
|
|
cpuunits = var.proxmox_lxc.cpuunits
|
|
|
|
force = var.proxmox_lxc.force
|
|
cmode = var.proxmox_lxc.cmode
|
|
onboot = var.proxmox_lxc.onboot
|
|
start = var.proxmox_lxc.start
|
|
startup = var.proxmox_lxc.startup
|
|
tags = join(";",
|
|
sort(
|
|
concat(
|
|
var.proxmox_lxc.tags,
|
|
[format("vlan%s", var.proxmox_lxc.vlan_tag)]
|
|
)
|
|
)
|
|
)
|
|
|
|
ssh_public_keys = var.proxmox_lxc.ssh_public_keys
|
|
|
|
rootfs {
|
|
storage = var.proxmox_lxc.storage_pool
|
|
size = var.proxmox_lxc.storage_size
|
|
}
|
|
|
|
mountpoint {
|
|
key = "0"
|
|
slot = 0
|
|
storage = var.proxmox_lxc.app_mp_storage_pool
|
|
mp = var.proxmox_lxc.app_mp_path
|
|
size = var.proxmox_lxc.app_mp_storage_size
|
|
backup = var.proxmox_lxc.app_mp_backup
|
|
}
|
|
|
|
network {
|
|
name = "eth0"
|
|
bridge = "vmbr0"
|
|
ip = format("%s/24", var.internal_ipv4)
|
|
gw = format("10.0.%s.1", var.proxmox_lxc.vlan_tag)
|
|
tag = var.proxmox_lxc.vlan_tag
|
|
}
|
|
|
|
lifecycle {
|
|
ignore_changes = [
|
|
description,
|
|
features,
|
|
mountpoint,
|
|
ostemplate,
|
|
rootfs,
|
|
ssh_public_keys,
|
|
vmid,
|
|
]
|
|
}
|
|
|
|
count = var.proxmox_lxc.enabled == true ? 1 : 0
|
|
}
|