mirror of
https://github.com/optim-enterprises-bv/terraform-talos.git
synced 2025-10-30 17:58:32 +00:00
Add proxmox
This commit is contained in:
1
proxmox/.gitignore
vendored
Normal file
1
proxmox/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.yaml
|
||||||
7
proxmox/auth.tf
Normal file
7
proxmox/auth.tf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
provider "proxmox" {
|
||||||
|
pm_api_url = "https://${var.proxmox_host}:8006/api2/json"
|
||||||
|
pm_api_token_id = var.proxmox_token_id
|
||||||
|
pm_api_token_secret = var.proxmox_token_secret
|
||||||
|
pm_tls_insecure = true
|
||||||
|
}
|
||||||
72
proxmox/instances-master.tf
Normal file
72
proxmox/instances-master.tf
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
locals {
|
||||||
|
gwv4 = cidrhost(var.vpc_main_cidr, -3)
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "null_resource" "cloud_init_config_files" {
|
||||||
|
count = lookup(var.controlplane, "count", 0)
|
||||||
|
connection {
|
||||||
|
type = "ssh"
|
||||||
|
user = "root"
|
||||||
|
host = var.proxmox_host
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "file" {
|
||||||
|
# content = ""
|
||||||
|
source = "init.yaml"
|
||||||
|
destination = "/var/lib/vz/snippets/master-${count.index + 1}.yml"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "proxmox_vm_qemu" "controlplane" {
|
||||||
|
count = lookup(var.controlplane, "count", 0)
|
||||||
|
name = "master-${count.index + 1}"
|
||||||
|
target_node = var.proxmox_nodename
|
||||||
|
clone = "talos"
|
||||||
|
|
||||||
|
# preprovision = false
|
||||||
|
define_connection_info = false
|
||||||
|
os_type = "ubuntu"
|
||||||
|
ipconfig0 = "ip=${cidrhost(var.vpc_main_cidr, 11 + count.index)}/24,gw=${local.gwv4}"
|
||||||
|
cicustom = "user=local:snippets/master-${count.index + 1}.yml"
|
||||||
|
cloudinit_cdrom_storage = var.proxmox_storage
|
||||||
|
|
||||||
|
onboot = false
|
||||||
|
bios = "ovmf"
|
||||||
|
cpu = "host,flags=+aes"
|
||||||
|
cores = 2
|
||||||
|
sockets = 1
|
||||||
|
memory = 2048
|
||||||
|
scsihw = "virtio-scsi-pci"
|
||||||
|
|
||||||
|
vga {
|
||||||
|
type = "serial0"
|
||||||
|
}
|
||||||
|
serial {
|
||||||
|
id = 0
|
||||||
|
type = "socket"
|
||||||
|
}
|
||||||
|
|
||||||
|
network {
|
||||||
|
model = "virtio"
|
||||||
|
bridge = var.proxmox_bridge
|
||||||
|
}
|
||||||
|
|
||||||
|
boot = "order=scsi0;net0"
|
||||||
|
disk {
|
||||||
|
type = "scsi"
|
||||||
|
storage = var.proxmox_storage
|
||||||
|
size = "16G"
|
||||||
|
cache = "writethrough"
|
||||||
|
ssd = 1
|
||||||
|
backup = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
lifecycle {
|
||||||
|
ignore_changes = [
|
||||||
|
desc,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
depends_on = [null_resource.cloud_init_config_files]
|
||||||
|
}
|
||||||
58
proxmox/variables.tf
Normal file
58
proxmox/variables.tf
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
variable "proxmox_host" {
|
||||||
|
description = "Proxmox host"
|
||||||
|
type = string
|
||||||
|
default = "192.168.1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "proxmox_nodename" {
|
||||||
|
description = "Proxmox node name"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "proxmox_storage" {
|
||||||
|
description = "Proxmox storage name"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "proxmox_bridge" {
|
||||||
|
description = "Proxmox bridge name"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "proxmox_token_id" {
|
||||||
|
description = "Proxmox token id"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "proxmox_token_secret" {
|
||||||
|
description = "Proxmox token secret"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "kubernetes" {
|
||||||
|
type = map(string)
|
||||||
|
default = {
|
||||||
|
podSubnets = "10.32.0.0/12,f00d:10:32::/102"
|
||||||
|
serviceSubnets = "10.200.0.0/22,fd40:10:200::/112"
|
||||||
|
domain = "cluster.local"
|
||||||
|
cluster_name = "talos-k8s-proxmox"
|
||||||
|
tokenmachine = ""
|
||||||
|
token = ""
|
||||||
|
ca = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "vpc_main_cidr" {
|
||||||
|
description = "Local proxmox subnet"
|
||||||
|
type = string
|
||||||
|
default = "192.168.10.0/24"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "controlplane" {
|
||||||
|
description = "Property of controlplane"
|
||||||
|
type = map(any)
|
||||||
|
default = {
|
||||||
|
count = 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
9
proxmox/versions.tf
Normal file
9
proxmox/versions.tf
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
proxmox = {
|
||||||
|
source = "Telmate/proxmox"
|
||||||
|
version = "~> 2.7.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
required_version = ">= 1.0"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user