Update terraform/variables.tf, terraform/main.tf, terraform/defaults.tf, terraform/terraform.tfvars, .gitlab-ci.yml
This commit is contained in:
18
terraform/defaults.tf
Normal file
18
terraform/defaults.tf
Normal file
@@ -0,0 +1,18 @@
|
||||
terraform {
|
||||
backend "http" {}
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "Telmate/proxmox"
|
||||
version = "~> 2.9.11"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
pm_parallel = 3
|
||||
pm_tls_insecure = true
|
||||
pm_api_url = var.pm_api_url
|
||||
pm_user = var.pm_user
|
||||
pm_password = var.pm_password
|
||||
pm_debug = false
|
||||
}
|
||||
129
terraform/main.tf
Normal file
129
terraform/main.tf
Normal file
@@ -0,0 +1,129 @@
|
||||
#k3s
|
||||
#------------------------------------------------------
|
||||
|
||||
resource "proxmox_vm_qemu" "k3master" {
|
||||
count = var.k3master.count
|
||||
ciuser = "administrator"
|
||||
vmid = "${var.k3master.tag}${var.k3master.ip[count.index]}"
|
||||
name = var.k3master.name[count.index]
|
||||
target_node = var.k3master.node
|
||||
clone = var.k3master.template
|
||||
full_clone = true
|
||||
os_type = "cloud-init"
|
||||
agent = 1
|
||||
cores = var.k3master.cores
|
||||
sockets = 1
|
||||
cpu = "host"
|
||||
memory = var.k3master.memory
|
||||
scsihw = "virtio-scsi-pci"
|
||||
bootdisk = "scsi0"
|
||||
boot = "c"
|
||||
onboot = true
|
||||
disk {
|
||||
size = var.k3master.drive
|
||||
type = "scsi"
|
||||
storage = var.k3master.storage
|
||||
ssd = 0
|
||||
backup = 0
|
||||
}
|
||||
network {
|
||||
model = "virtio"
|
||||
bridge = "vmbr1"
|
||||
tag = var.k3master.tag
|
||||
}
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network,
|
||||
]
|
||||
}
|
||||
#Cloud Init Settings
|
||||
ipconfig0 = "ip=192.168.${var.k3master.tag}.${var.k3master.ip[count.index]}/24,gw=192.168.${var.k3master.tag}.1"
|
||||
searchdomain = "durp.loc"
|
||||
nameserver = "${var.dnsserver}"
|
||||
sshkeys = "${var.sshkeys}"
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "k3server" {
|
||||
count = var.k3server.count
|
||||
ciuser = "administrator"
|
||||
vmid = "${var.k3server.tag}${var.k3server.ip[count.index]}"
|
||||
name = var.k3server.name[count.index]
|
||||
target_node = var.k3server.node
|
||||
clone = var.k3server.template
|
||||
full_clone = true
|
||||
os_type = "cloud-init"
|
||||
agent = 1
|
||||
cores = var.k3server.cores[count.index]
|
||||
sockets = 1
|
||||
cpu = "host"
|
||||
memory = var.k3server.memory[count.index]
|
||||
scsihw = "virtio-scsi-pci"
|
||||
bootdisk = "scsi0"
|
||||
boot = "c"
|
||||
onboot = true
|
||||
disk {
|
||||
size = var.k3server.drive[count.index]
|
||||
type = "scsi"
|
||||
storage = var.k3server.storage[count.index]
|
||||
ssd = 1
|
||||
backup = 0
|
||||
}
|
||||
network {
|
||||
model = "virtio"
|
||||
bridge = "vmbr1"
|
||||
tag = var.k3server.tag
|
||||
}
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network,
|
||||
]
|
||||
}
|
||||
#Cloud Init Settings
|
||||
ipconfig0 = "ip=192.168.${var.k3server.tag}.${var.k3server.ip[count.index]}/24,gw=192.168.${var.k3server.tag}.1"
|
||||
searchdomain = "durp.loc"
|
||||
nameserver = "${var.dnsserver}"
|
||||
sshkeys = "${var.sshkeys}"
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "kasm" {
|
||||
count = 1
|
||||
ciuser = "administrator"
|
||||
vmid = 20110
|
||||
name = "kasm"
|
||||
target_node = "overlord"
|
||||
clone = "CentOS9-Template"
|
||||
full_clone = true
|
||||
os_type = "cloud-init"
|
||||
agent = 1
|
||||
cores = 4
|
||||
sockets = 1
|
||||
cpu = "host"
|
||||
memory = 4096
|
||||
scsihw = "virtio-scsi-pci"
|
||||
bootdisk = "scsi0"
|
||||
boot = "c"
|
||||
onboot = true
|
||||
disk {
|
||||
size = "60G"
|
||||
type = "scsi"
|
||||
storage = "local-zfs"
|
||||
ssd = 1
|
||||
backup = 0
|
||||
}
|
||||
network {
|
||||
model = "virtio"
|
||||
bridge = "vmbr1"
|
||||
tag = 20
|
||||
}
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network,
|
||||
]
|
||||
}
|
||||
#Cloud Init Settings
|
||||
ipconfig0 = "ip=192.168.20.110/24,gw=192.168.20.1"
|
||||
searchdomain = "durp.loc"
|
||||
nameserver = "${var.dnsserver}"
|
||||
sshkeys = "${var.sshkeys}"
|
||||
}
|
||||
|
||||
28
terraform/terraform.tfvars
Normal file
28
terraform/terraform.tfvars
Normal file
@@ -0,0 +1,28 @@
|
||||
dnsserver = "192.168.20.1"
|
||||
sshkeys = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDTYqag8OKcV6kIitn3Axlyi3Xr9EeybG10wlglw34fYF0pY+OERy7zZKEju4ijZzQ7eWNlcXLYSorm5Tngkvnz4vbM4b9R7gZjTV9drSGDo0BLkMXNuSTrKwGeokcNkxh+HZcWSK4/SE5zPzvkPj1UvmAgQ4P4N79mqPe5/9gAvdrlUWEtuqVdEHc/FMk4kEZsRu4lg58KoghNCRYMYHOyd1rbHsuWpX5NumPxnosWG22jzqj46rUWEXvA7MrCGGbUDlk5+/h7Bvw4O8nGZLEo/qyaYvChTBj/UqYYBssC4VlW/SNJB1yfrklqdtcknmFVJBi174cQtzZDXOerwneh8/+t7wWpcxkWscxYrwdJspzAU/NGk02xDPaG4F1mdgZ6HIZCQAaw/EbaNbiuU+bhdngEIHUvVmdiy4T09FWIWuJxO6FnAiVIU5K8LpqGLTFp7kjOwAczdQ+KVojm/1A5W/ZoTE/y3Ni1fVaOJFCxSgU7qiKAm7hb2ZXvznNgryc="
|
||||
|
||||
k3master = {
|
||||
count = "3"
|
||||
name = ["master01", "master02", "master03"]
|
||||
cores = "2"
|
||||
memory = "4096"
|
||||
drive = "20G"
|
||||
storage = "domains"
|
||||
template = "CentOS9-Template"
|
||||
node = "overlord"
|
||||
tag = "20"
|
||||
ip = ["121", "122", "123"]
|
||||
}
|
||||
|
||||
k3server = {
|
||||
count = "3"
|
||||
name = ["node01", "node02", "node03"]
|
||||
cores = ["4", "4", "4"]
|
||||
memory = ["8192","8192","8192"]
|
||||
drive = ["145G","145G","145G"]
|
||||
storage = ["NVMeSSD", "NVMeSSD", "NVMeSSD"]
|
||||
template = "CentOS9-Template"
|
||||
node = "overlord"
|
||||
tag = "20"
|
||||
ip = ["124", "125", "126"]
|
||||
}
|
||||
82
terraform/variables.tf
Normal file
82
terraform/variables.tf
Normal file
@@ -0,0 +1,82 @@
|
||||
variable "pm_api_url" {
|
||||
description = "API URL to Proxmox provider"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "dnsserver" {
|
||||
description = "DNS provider"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sshkeys" {
|
||||
description = "Public SSH key to inject into CloudInit"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "pm_password" {
|
||||
description = "Passowrd to Proxmox provider"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "pm_user" {
|
||||
description = "UIsername to Proxmox provider"
|
||||
type = string
|
||||
default = "root@pam"
|
||||
}
|
||||
|
||||
|
||||
variable "k3master" {
|
||||
description = "Defaults of master nodes in K3S"
|
||||
type = object({
|
||||
count = number
|
||||
name = list(string)
|
||||
cores = number
|
||||
memory = number
|
||||
drive = string
|
||||
storage = string
|
||||
template = string
|
||||
node = string
|
||||
tag = number
|
||||
ip = list(number)
|
||||
})
|
||||
default = {
|
||||
count = "1"
|
||||
name = ["master01"]
|
||||
cores = "2"
|
||||
memory = "2048"
|
||||
drive = "20G"
|
||||
storage = "domains"
|
||||
template = "CentOS9-Template"
|
||||
node = "overlord"
|
||||
tag = "20"
|
||||
ip = ["121"]
|
||||
}
|
||||
}
|
||||
|
||||
variable "k3server" {
|
||||
description = "Defaults of worker nodes in K3S"
|
||||
type = object({
|
||||
count = number
|
||||
name = list(string)
|
||||
cores = list(number)
|
||||
memory = list(number)
|
||||
drive = list(string)
|
||||
storage = list(string)
|
||||
template = string
|
||||
node = string
|
||||
tag = number
|
||||
ip = list(number)
|
||||
})
|
||||
default = {
|
||||
count = "1"
|
||||
name = ["node01"]
|
||||
cores = "2"
|
||||
memory = "4096"
|
||||
drive = "60G"
|
||||
storage = "domains"
|
||||
template = "CentOS9-Template"
|
||||
node = "overlord"
|
||||
tag = "20"
|
||||
ip = ["124"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user