97 lines
No EOL
1.9 KiB
HCL
97 lines
No EOL
1.9 KiB
HCL
terraform {
|
|
required_version = ">= 1.0"
|
|
required_providers {
|
|
talos = {
|
|
source = "siderolabs/talos"
|
|
version = "~> 0.9"
|
|
}
|
|
libvirt = {
|
|
source = "dmacvicar/libvirt"
|
|
version = "~> 0.7"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "libvirt" {
|
|
uri = "qemu:///system"
|
|
}
|
|
|
|
# Load variables from a .tfvars file
|
|
variable "cluster_name" {
|
|
description = "The name of the Talos cluster"
|
|
type = string
|
|
default = "evolved-npcs-cluster"
|
|
}
|
|
|
|
variable "memory_mb" {
|
|
description = "Memory for each VM in MB"
|
|
type = number
|
|
default = 2048
|
|
}
|
|
|
|
variable "vcpu_count" {
|
|
description = "Number of vCPUs for each VM"
|
|
type = number
|
|
default = 2
|
|
}
|
|
|
|
variable "talos_version" {
|
|
description = "The version of Talos to use"
|
|
type = string
|
|
default = "v1.11.1"
|
|
}
|
|
|
|
resource "libvirt_network" "talos_bridge" {
|
|
name = "my-talos-net"
|
|
autostart = true
|
|
|
|
xml {
|
|
xslt = file("control-plane-net.xsl")
|
|
}
|
|
}
|
|
|
|
# Download the ISO
|
|
resource "libvirt_volume" "talos_iso" {
|
|
name = "talos-metal-arm64.iso"
|
|
pool = "images"
|
|
source = "https://factory.talos.dev/image/4a0d65c669d46663f377e7161e50cfd570c401f26fd9e7bda34a0216b6f1922b/v1.11.1/metal-arm64.iso"
|
|
format = "raw"
|
|
}
|
|
|
|
# Create disk for VM
|
|
resource "libvirt_volume" "control_plane_disk" {
|
|
name = "control-plane-node-1-disk.qcow2"
|
|
pool = "images"
|
|
base_volume_id = libvirt_volume.talos_iso.id
|
|
size = 42949672960 # 40GB in bytes
|
|
format = "qcow2"
|
|
}
|
|
|
|
# Create the VM
|
|
resource "libvirt_domain" "control_plane_node_1" {
|
|
name = "control-plane-node-1"
|
|
memory = 2048
|
|
vcpu = 2
|
|
|
|
disk {
|
|
volume_id = libvirt_volume.control_plane_disk.id
|
|
}
|
|
|
|
disk {
|
|
file = libvirt_volume.talos_iso.id
|
|
}
|
|
|
|
network_interface {
|
|
network_name = "my-talos-net"
|
|
}
|
|
|
|
graphics {
|
|
type = "none"
|
|
}
|
|
|
|
boot_device {
|
|
dev = ["hd", "cdrom"]
|
|
}
|
|
|
|
autostart = true
|
|
} |