Update 5 files
- /terraform/defaults.tf - /terraform/main.tf - /terraform/variables.tf - /terraform/terraform.tfvars - /.gitlab-ci.yml
This commit is contained in:
5
.gitlab-ci.yml
Normal file
5
.gitlab-ci.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: main
|
||||
file:
|
||||
- 'pipelines/terraform.yml'
|
||||
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.14"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
88
terraform/main.tf
Normal file
88
terraform/main.tf
Normal file
@@ -0,0 +1,88 @@
|
||||
#k3s
|
||||
#-----------------------------------------------------
|
||||
|
||||
resource "proxmox_vm_qemu" "k3master" {
|
||||
count = var.k3master.count
|
||||
ciuser = "administrator"
|
||||
vmid = "20${var.k3master.ip[count.index]}"
|
||||
name = var.k3master.name[count.index]
|
||||
target_node = var.k3master.node[count.index]
|
||||
clone = var.k3master.template[count.index]
|
||||
qemu_os = "other"
|
||||
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"
|
||||
format = "raw"
|
||||
storage = var.k3master.storage
|
||||
ssd = 1
|
||||
backup = false
|
||||
}
|
||||
network {
|
||||
model = "virtio"
|
||||
bridge = "vmbr1"
|
||||
}
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network,
|
||||
]
|
||||
}
|
||||
#Cloud Init Settings
|
||||
ipconfig0 = "ip=192.168.20.${var.k3master.ip[count.index]}/24,gw=192.168.20.1"
|
||||
searchdomain = "durp.loc"
|
||||
nameserver = var.dnsserver
|
||||
sshkeys = var.sshkeys
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "k3server" {
|
||||
count = var.k3server.count
|
||||
ciuser = "administrator"
|
||||
vmid = "20${var.k3server.ip[count.index]}"
|
||||
name = var.k3server.name[count.index]
|
||||
target_node = var.k3server.node[count.index]
|
||||
clone = var.k3server.template[count.index]
|
||||
qemu_os = "other"
|
||||
full_clone = true
|
||||
os_type = "cloud-init"
|
||||
agent = 1
|
||||
cores = var.k3server.cores
|
||||
sockets = 1
|
||||
cpu = "host"
|
||||
memory = var.k3server.memory
|
||||
scsihw = "virtio-scsi-pci"
|
||||
bootdisk = "scsi0"
|
||||
boot = "c"
|
||||
onboot = true
|
||||
disk {
|
||||
size = var.k3server.drive
|
||||
type = "scsi"
|
||||
format = "raw"
|
||||
storage = var.k3server.storage
|
||||
ssd = 1
|
||||
backup = false
|
||||
}
|
||||
network {
|
||||
model = "virtio"
|
||||
bridge = "vmbr1"
|
||||
}
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network,
|
||||
]
|
||||
}
|
||||
#Cloud Init Settings
|
||||
ipconfig0 = "ip=192.168.20.${var.k3server.ip[count.index]}/24,gw=192.168.20.1"
|
||||
searchdomain = "durp.loc"
|
||||
nameserver = var.dnsserver
|
||||
sshkeys = var.sshkeys
|
||||
}
|
||||
27
terraform/terraform.tfvars
Normal file
27
terraform/terraform.tfvars
Normal file
@@ -0,0 +1,27 @@
|
||||
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 = 1
|
||||
name = ["master"]
|
||||
cores = 4
|
||||
memory = "4096"
|
||||
drive = "20G"
|
||||
storage = "ssd-domains"
|
||||
template = var.template
|
||||
node = ["overlord"]
|
||||
ip = ["10"]
|
||||
}
|
||||
|
||||
k3server = {
|
||||
count = 2
|
||||
name = ["node01", "node02"]
|
||||
cores = 4
|
||||
memory = "4096"
|
||||
drive = "60G"
|
||||
storage = "ssd-domains"
|
||||
template = var.template
|
||||
node = ["mothership", "mothership"]
|
||||
ip = ["20", "21"]
|
||||
}
|
||||
55
terraform/variables.tf
Normal file
55
terraform/variables.tf
Normal file
@@ -0,0 +1,55 @@
|
||||
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 = list(string)
|
||||
ip = list(number)
|
||||
})
|
||||
}
|
||||
|
||||
variable "k3server" {
|
||||
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 = list(string)
|
||||
ip = list(number)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user