Add infrastructure packages: terraform-pve, ansible-push, wolfstack-keepalived, terraform-pve-vm
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.70.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_container" "this" {
|
||||
node_name = var.node
|
||||
vm_id = var.vmid
|
||||
unprivileged = var.unprivileged
|
||||
|
||||
description = "Terraform batch LXC — ${var.hostname}"
|
||||
|
||||
cpu {
|
||||
cores = var.cores
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = var.memory
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = var.storage
|
||||
size = var.rootfs_size
|
||||
}
|
||||
|
||||
network_interface {
|
||||
name = "eth0"
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
dynamic "features" {
|
||||
for_each = var.unprivileged ? [1] : []
|
||||
content {
|
||||
nesting = true
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "device_passthrough" {
|
||||
for_each = var.devices
|
||||
content {
|
||||
path = device_passthrough.value.path
|
||||
mode = device_passthrough.value.mode
|
||||
uid = device_passthrough.value.uid
|
||||
gid = device_passthrough.value.gid
|
||||
deny_write = device_passthrough.value.deny_write
|
||||
}
|
||||
}
|
||||
|
||||
initialization {
|
||||
hostname = var.hostname
|
||||
|
||||
dns {
|
||||
servers = var.dns_servers
|
||||
}
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = var.ipv4
|
||||
gateway = var.gateway
|
||||
}
|
||||
}
|
||||
|
||||
user_account {
|
||||
keys = [file(var.ssh_key_path)]
|
||||
password = var.password
|
||||
}
|
||||
}
|
||||
|
||||
operating_system {
|
||||
template_file_id = var.template_file_id
|
||||
type = "debian"
|
||||
}
|
||||
|
||||
tags = var.tags
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
output "vmid" {
|
||||
description = "LXC VMID"
|
||||
value = proxmox_virtual_environment_container.this.vm_id
|
||||
}
|
||||
|
||||
output "hostname" {
|
||||
description = "LXC hostname"
|
||||
value = var.hostname
|
||||
}
|
||||
|
||||
output "ipv4" {
|
||||
description = "LXC static IPv4 with CIDR"
|
||||
value = var.ipv4
|
||||
}
|
||||
|
||||
output "node" {
|
||||
description = "Target PVE node"
|
||||
value = var.node
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
variable "vmid" {
|
||||
description = "LXC VMID"
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "hostname" {
|
||||
description = "LXC hostname"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ipv4" {
|
||||
description = "Static IPv4 with CIDR"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "node" {
|
||||
description = "Target PVE node"
|
||||
type = string
|
||||
default = "mk33"
|
||||
}
|
||||
|
||||
variable "cores" {
|
||||
description = "CPU cores"
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "memory" {
|
||||
description = "RAM in MB"
|
||||
type = number
|
||||
default = 2048
|
||||
}
|
||||
|
||||
variable "storage" {
|
||||
description = "Storage pool"
|
||||
type = string
|
||||
default = "local"
|
||||
}
|
||||
|
||||
variable "rootfs_size" {
|
||||
description = "Root filesystem size in GB"
|
||||
type = number
|
||||
default = 8
|
||||
}
|
||||
|
||||
variable "gateway" {
|
||||
description = "IPv4 gateway"
|
||||
type = string
|
||||
default = "192.168.18.1"
|
||||
}
|
||||
|
||||
variable "dns_servers" {
|
||||
description = "DNS servers"
|
||||
type = list(string)
|
||||
default = ["192.168.7.7", "192.168.18.1", "1.1.1.1"]
|
||||
}
|
||||
|
||||
variable "ssh_key_path" {
|
||||
description = "Path to SSH public key for jarvis user"
|
||||
type = string
|
||||
default = "artemis_key.pub"
|
||||
}
|
||||
|
||||
variable "template_file_id" {
|
||||
description = "LXC OS template file ID (storage:path)"
|
||||
type = string
|
||||
default = "nas-ct-stor:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst"
|
||||
}
|
||||
|
||||
variable "password" {
|
||||
description = "Root password for console login"
|
||||
type = string
|
||||
sensitive = true
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Tags to apply to the LXC"
|
||||
type = list(string)
|
||||
default = ["terraform", "batch"]
|
||||
}
|
||||
|
||||
variable "unprivileged" {
|
||||
description = "Run as unprivileged container"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "devices" {
|
||||
description = "List of device passthrough configs (path, mode, uid, gid, deny_write)"
|
||||
type = list(object({
|
||||
path = string
|
||||
mode = optional(string, "0666")
|
||||
uid = optional(number, 0)
|
||||
gid = optional(number, 0)
|
||||
deny_write = optional(bool, false)
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
Reference in New Issue
Block a user