This commit is contained in:
2023-12-20 09:13:14 -06:00
parent 8d6a9ecc8d
commit 2fc1cd4b86
5 changed files with 123 additions and 21 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.terraform*
.env
*.tfstate*
local.tfvars

View File

@@ -0,0 +1,18 @@
terraform {
# backend "http" {}
required_providers {
proxmox = {
source = "TheGameProfi/proxmox"
version = "2.9.15"
}
}
}
provider "proxmox" {
pm_parallel = 3
pm_tls_insecure = false
pm_api_url = var.pm_api_url
pm_api_token_id = var.pm_api_token_id
pm_api_token_secret = var.pm_api_token_secret
pm_debug = false
}

View File

@@ -1,23 +1,35 @@
module "RKE" {
source = "git::https://gitlab.com/developerdurp/tf-modules.git//TERRAFORM.PROXMOX.RKE"
dnsserver = "#{dnsserver}"
sshkeys = "#{sshkeys}"
vlan = #{vlan}
bridge = "#{bridge}"
appname = "#{appname}"
searchdomain = "#{searchdomain}"
master = {
count = #{mastercount}
template = "#{master-template}"
cores = #{mastercores}
memory = "#{mastermemory}"
node = #{masternode}
ip = #{masterip}
resource "proxmox_vm_qemu" "master" {
count = var.master.count
ciuser = "administrator"
vmid = "${var.vlan}${var.master.ip[count.index]}"
name = "rke-m-${var.appname}${format("%02d", count.index + 1)}"
target_node = var.master.node[count.index]
clone = var.master.template
qemu_os = "other"
full_clone = true
agent = 1
cores = var.master.cores
sockets = 1
cpu = "host"
memory = var.master.memory
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
boot = "c"
onboot = false
network {
model = "virtio"
bridge = var.bridge
tag = var.vlan
firewall = false
}
pm_api_url = "#{pm_api_url}"
pm_api_token_id = "#{pm_api_token_id}"
pm_api_token_secret = "#{pm_api_token_secret}"
lifecycle {
ignore_changes = [
network,
]
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${var.vlan}.${var.master.ip[count.index]}/24,gw=192.168.${var.vlan}.1"
searchdomain = var.searchdomain
nameserver = var.dnsserver
sshkeys = var.sshkeys
}

View File

@@ -0,0 +1,48 @@
variable "dnsserver" {
type = string
}
variable "sshkeys" {
type = string
}
variable "vlan" {
type = number
}
variable "bridge" {
type = string
}
variable "appname" {
type = string
}
variable "searchdomain" {
type = string
}
variable "pm_api_url" {
type = string
}
variable "pm_api_token_id" {
type = string
}
variable "pm_api_token_secret" {
type = string
}
variable "master" {
description = "Defaults of master nodes in K3S"
type = object({
count = number
template = string
cores = number
memory = number
node = list(string)
ip = list(number)
})
}

View File

@@ -0,0 +1,19 @@
dnsserver = "#{dnsserver}"
sshkeys = "#{sshkeys}"
vlan = #{vlan}
bridge = "#{bridge}"
appname = "#{appname}"
searchdomain = "#{searchdomain}"
master = {
count = #{count}
template = "#{template}"
cores = #{cores}
memory = "#{memory}"
node = [#{node}]
ip = [#{ip}]
}
pm_api_url = "#{pm_api_url}"
pm_api_token_id = "#{pm_api_token_id}"
pm_api_token_secret = "#{pm_api_token_secret}"