mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-opentofu-private.git
synced 2025-10-27 15:53:06 +00:00
99 lines
2.1 KiB
HCL
99 lines
2.1 KiB
HCL
provider "proxmox" {
|
|
endpoint = var.proxmox_server
|
|
api_token = var.proxmox_apikey
|
|
ssh {
|
|
agent = false
|
|
username = var.proxmox_username_ssh
|
|
socks5_server = var.proxmox_server_ssh
|
|
password = var.proxmox_password_ssh
|
|
|
|
node {
|
|
name = "fenix"
|
|
address = "127.0.0.1"
|
|
port = 1081
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
resource "proxmox_virtual_environment_download_file" "latest_ubunto_cloud_img" {
|
|
content_type = "import"
|
|
datastore_id = "local-snippets"
|
|
node_name = "fenix"
|
|
url = "https://cloud-images.ubuntu.com/jammy/20250619/jammy-server-cloudimg-amd64.img"
|
|
# need to rename the file to *.qcow2 to indicate the actual file format for import
|
|
file_name = "jammy-server-cloudimg-amd64.img"
|
|
}
|
|
|
|
resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
|
|
|
depends_on = [proxmox_virtual_environment_download_file.latest_ubunto_cloud_img]
|
|
name = "proxmox-kubernetes-VM-template"
|
|
node_name = "fenix"
|
|
vm_id = 1002
|
|
template = true
|
|
started = false
|
|
|
|
agent {
|
|
enabled = true
|
|
}
|
|
tags = ["opentofu", "kubernetes", "fedora"]
|
|
machine = "q35"
|
|
bios = "seabios"
|
|
description = "kubernetes VM Template created via iac"
|
|
|
|
cpu {
|
|
cores = 2
|
|
}
|
|
|
|
memory {
|
|
dedicated = 4096
|
|
}
|
|
|
|
# Configuração do disco rígido
|
|
disk {
|
|
datastore_id = "local-lvm"
|
|
interface = "scsi0"
|
|
size = 64
|
|
}
|
|
|
|
|
|
disk {
|
|
datastore_id = "local-lvm"
|
|
import_from = proxmox_virtual_environment_download_file.latest_fedora_cloud_img.id
|
|
interface = "scsi1"
|
|
}
|
|
|
|
# Configuração da interface de rede
|
|
network_device {
|
|
bridge = "vmbr0"
|
|
model = "virtio"
|
|
}
|
|
|
|
initialization {
|
|
ip_config {
|
|
ipv4 {
|
|
address = "192.168.1.24/24" # IP estático + máscara de rede
|
|
gateway = "192.168.1.1" # Gateway da rede
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
resource "proxmox_virtual_environment_vm" "VM-Kubernetes-01" {
|
|
depends_on = [proxmox_virtual_environment_vm.proxmox-kubernetes-VM-template]
|
|
name = "VM-Kubernetes-01"
|
|
node_name = "fenix"
|
|
|
|
clone {
|
|
vm_id = proxmox_virtual_environment_vm.proxmox-kubernetes-VM-template.id
|
|
}
|
|
agent {
|
|
enabled = true
|
|
}
|
|
}
|
|
|
|
|
|
|