terraform-proxmox-simple/main.tf

77 lines
1.6 KiB
HCL

terraform {
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = "3.0.2-rc05"
}
}
}
provider "proxmox" {
pm_tls_insecure = true
pm_api_url = "https://192.168.251.251:8006/api2/json"
pm_user = "terraform@pve"
pm_password = "P@ssw0rd"
}
resource "proxmox_vm_qemu" "vm1" {
name = "terraform-vm1"
description = "Debian VM cloned from Cloud-Init template"
target_node = "pve0"
clone = "debian-template"
# full_clone = true
agent = 1
os_type = "cloud-init"
# CPU and Memory
memory = 4096
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
# CPU Block is now REQUIRED[citation:5]
cpu {
type = "host"
cores = 4 # Количество ядер на сокет
sockets = 1
}
# Disks must now be defined in nested `disks` blocks[citation:1][citation:3]
disks {
scsi {
scsi0 {
disk {
size = 20
storage = "ssd1"
}
}
}
ide {
ide3 {
cloudinit {
storage = "ssd1"
}
}
}
}
# Network must be defined in a `network` block with an ID[citation:5]
network {
id = 0 # The network ID is now required and must be in sequence (0, 1, 2...)[citation:5]
model = "virtio"
bridge = "vmbr0"
}
# Cloud-Init
ciuser = "debian"
cipassword = "Password123!"
ipconfig0 = "ip=192.168.251.100/24,gw=192.168.251.254"
serial {
id = 0
type = "socket"
}
# sshkeys = <<EOF
#ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu... user@host
#EOF
}