mirror of
https://github.com/tolerryan/NewWatari.git
synced 2026-10-12 10:47:41 +00:00
refactor to a more templated version.
may need to update the modules section of main.tf
This commit is contained in:
@@ -1,80 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
proxmox = {
|
|
||||||
source = "bpg/proxmox"
|
|
||||||
version = "0.97.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
resource "proxmox_virtual_environment_container" "example_template" {
|
|
||||||
description = "Managed by Terraform"
|
|
||||||
start_on_boot = "true"
|
|
||||||
unprivileged = true
|
|
||||||
features {
|
|
||||||
nesting = true
|
|
||||||
}
|
|
||||||
wait_for_ip {
|
|
||||||
ipv4 = true
|
|
||||||
}
|
|
||||||
|
|
||||||
disk {
|
|
||||||
#datastore_id = var.virtual_environment_storage
|
|
||||||
# ^ Possible template example
|
|
||||||
datastore_id = "local-lvm"
|
|
||||||
size = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
#mount_point {
|
|
||||||
# // volume mount
|
|
||||||
# volume = var.virtual_environment_storage
|
|
||||||
# size = "4G"
|
|
||||||
# path = "mnt/local"
|
|
||||||
#}
|
|
||||||
|
|
||||||
initialization {
|
|
||||||
dns {
|
|
||||||
servers = ["1.1.1.1", "8.8.8.8"]
|
|
||||||
}
|
|
||||||
|
|
||||||
hostname = "downloader"
|
|
||||||
|
|
||||||
ip_config {
|
|
||||||
ipv4 {
|
|
||||||
address = "192.168.0.22/24"
|
|
||||||
gateway = "192.168.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
user_account {
|
|
||||||
# keys = [trimspace(tls_private_key.example.public_key_openssh)]
|
|
||||||
password = "example"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
network_interface {
|
|
||||||
name = "veth0"
|
|
||||||
mtu = 1450
|
|
||||||
}
|
|
||||||
|
|
||||||
#node_name = data.proxmox_virtual_environment_nodes.example.names[0]
|
|
||||||
# ^ possible way to template the node_name
|
|
||||||
node_name = "watari"
|
|
||||||
|
|
||||||
operating_system {
|
|
||||||
template_file_id = "local:vztmpl/debian-13-standard_13.3-sudo_amd64.tar.zst"
|
|
||||||
type = "debian"
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = [
|
|
||||||
"deb13",
|
|
||||||
"terraform",
|
|
||||||
]
|
|
||||||
|
|
||||||
startup {
|
|
||||||
order = "3"
|
|
||||||
up_delay = "60"
|
|
||||||
down_delay = "60"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
94
lxc/downloader/main.tf
Normal file
94
lxc/downloader/main.tf
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
proxmox = {
|
||||||
|
source = "bpg/proxmox"
|
||||||
|
version = "0.97.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Optional second disk – create it only when the flag is true.
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
resource "proxmox_virtual_environment_container" "example_template" {
|
||||||
|
description = "Managed by Terraform"
|
||||||
|
start_on_boot = var.start_on_boot
|
||||||
|
unprivileged = var.unprivileged
|
||||||
|
|
||||||
|
features {
|
||||||
|
nesting = var.nesting_enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_for_ip {
|
||||||
|
ipv4 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---- Disk(s) ----------------------------------------------------
|
||||||
|
disk {
|
||||||
|
datastore_id = var.datastore_id # <- primary disk
|
||||||
|
size = var.disk_size_gb # in GB
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic "disk" { # <-- optional second disk
|
||||||
|
for_each = var.second_disk_enabled ? [1] : []
|
||||||
|
|
||||||
|
content {
|
||||||
|
datastore_id = var.second_disk_datastore
|
||||||
|
size = var.second_disk_size_gb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Mount points – uncomment and set if you need to mount a volume.
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
#mount_point {
|
||||||
|
# volume = var.mount_volume
|
||||||
|
# size = "4G"
|
||||||
|
# path = "/mnt/local"
|
||||||
|
#}
|
||||||
|
|
||||||
|
# ---- Initialization -------------------------------------------------
|
||||||
|
initialization {
|
||||||
|
dns {
|
||||||
|
servers = ["1.1.1.1", "8.8.8.8"]
|
||||||
|
}
|
||||||
|
|
||||||
|
hostname = var.hostname
|
||||||
|
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
address = var.ip_address
|
||||||
|
gateway = var.gateway
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
user_account {
|
||||||
|
password = var.password
|
||||||
|
# keys = [trimspace(tls_private_key.example.public_key_openssh)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---- Network ----------------------------------------------------
|
||||||
|
network_interface {
|
||||||
|
name = "veth0"
|
||||||
|
mtu = 1450
|
||||||
|
}
|
||||||
|
|
||||||
|
node_name = var.node_name
|
||||||
|
|
||||||
|
operating_system {
|
||||||
|
template_file_id = var.template_file_id
|
||||||
|
type = "debian"
|
||||||
|
}
|
||||||
|
|
||||||
|
tags = [
|
||||||
|
"deb13",
|
||||||
|
"terraform",
|
||||||
|
]
|
||||||
|
|
||||||
|
startup {
|
||||||
|
order = "3"
|
||||||
|
up_delay = "60"
|
||||||
|
down_delay = "60"
|
||||||
|
}
|
||||||
|
}
|
||||||
64
lxc/downloader/vars.tf
Normal file
64
lxc/downloader/vars.tf
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# ---------------------------------------------------------------
|
||||||
|
# General container settings (things that rarely change)
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
variable "start_on_boot" {
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "unprivileged" {
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "nesting_enabled" {
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# Disk sizes (primary + optional)
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
variable "datastore_id" {
|
||||||
|
type = string
|
||||||
|
default = "local-lvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "disk_size_gb" {
|
||||||
|
type = number
|
||||||
|
default = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "second_disk_enabled" {
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "second_disk_datastore" {
|
||||||
|
type = string
|
||||||
|
default = "local-lvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "second_disk_size_gb" {
|
||||||
|
type = number
|
||||||
|
default = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# Initialization specifics
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
variable "hostname" { default = "downloader" }
|
||||||
|
variable "ip_address" { default = "192.168.0.22/24" }
|
||||||
|
variable "gateway" { default = "192.168.0.1" }
|
||||||
|
variable "password" { default = "example" }
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# Node & template file
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
variable "node_name" { default = "watari" }
|
||||||
|
variable "template_file_id" { default = "local:vztmpl/debian-13-standard_13.3-sudo_amd64.tar.zst" }
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# (Optional) Mount point volume name – set if you enable mounts
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# variable "mount_volume" { default = "" }
|
||||||
Reference in New Issue
Block a user