Files
IaC/terraform/main.tf

67 lines
1.4 KiB
HCL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
terraform {
required_providers {
# Мы называем локальный алиас "proxmox"
proxmox = {
source = "bpg/proxmox"
version = "0.70.0"
}
}
backend "http" {}
}
provider "proxmox" {
endpoint = var.proxmox_api_url
api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
insecure = true
ssh {
agent = false
}
}
resource "proxmox_virtual_machine" "k8s_nodes" {
# Явно указываем, какой провайдер использовать для этого ресурса
provider = proxmox
for_each = var.vm_nodes
node_name = "pve"
name = each.value.name
vm_id = each.value.id
# Мы перешли на клонирование шаблона (Шаг 9000 из прошлой инструкции)
clone {
vm_id = 9000
}
cpu {
cores = 2
type = "host"
}
memory {
dedicated = 4096
}
network_device {
bridge = "vmbr0"
}
disk {
datastore_id = "local-lvm"
interface = "scsi0"
size = 20
}
initialization {
ip_config {
ipv4 {
address = "${each.value.ip}/24"
gateway = "10.33.33.1"
}
}
user_account {
username = "ubuntu"
keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPkMcT6PGm4xwBlwwwLkzdzTF/pgtADIcdejf5xALbxQ semaphore-gitea-key"]
}
}
}