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