ci: add changed config
This commit is contained in:
parent
5c57494895
commit
5e85050e79
8 changed files with 260 additions and 36 deletions
56
tofu/main.tf
56
tofu/main.tf
|
|
@ -12,7 +12,6 @@ provider "libvirt" {
|
|||
}
|
||||
|
||||
# --- Base Image Handling ---
|
||||
# Download the base cloud image if it doesn't exist locally
|
||||
resource "libvirt_volume" "base_image" {
|
||||
name = var.base_image_name
|
||||
pool = var.libvirt_pool
|
||||
|
|
@ -21,7 +20,6 @@ resource "libvirt_volume" "base_image" {
|
|||
}
|
||||
|
||||
# --- Cloud-Init Configuration ---
|
||||
# Common cloud-init data for all nodes
|
||||
data "cloudinit_config" "common_init" {
|
||||
gzip = false
|
||||
base64_encode = false
|
||||
|
|
@ -35,38 +33,31 @@ data "cloudinit_config" "common_init" {
|
|||
}
|
||||
}
|
||||
|
||||
# Create a cloud-init ISO disk using the common config
|
||||
resource "libvirt_cloudinit_disk" "common_iso" {
|
||||
name = "${var.cluster_name}-common-init.iso"
|
||||
user_data = data.cloudinit_config.common_init.rendered
|
||||
pool = var.libvirt_pool
|
||||
name = "${var.cluster_name}-common-init.iso"
|
||||
user_data = data.cloudinit_config.common_init.rendered
|
||||
pool = var.libvirt_pool
|
||||
}
|
||||
|
||||
# # --- Network ---
|
||||
# # Use the default libvirt network
|
||||
# data "libvirt_network" "default_network" {
|
||||
# name = var.libvirt_network_name
|
||||
# }
|
||||
|
||||
# --- K3s Server Node ---
|
||||
# Create a volume for the server node based on the base image
|
||||
resource "libvirt_volume" "server_disk" {
|
||||
name = "${var.server_hostname}-disk.qcow2"
|
||||
base_volume_id = libvirt_volume.base_image.id
|
||||
pool = var.libvirt_pool
|
||||
size = var.vm_disk_size
|
||||
size = var.server_disk_size
|
||||
format = "qcow2"
|
||||
}
|
||||
|
||||
resource "libvirt_domain" "server" {
|
||||
name = var.server_hostname
|
||||
memory = var.vm_memory
|
||||
vcpu = var.vm_vcpu
|
||||
memory = var.server_memory
|
||||
vcpu = var.server_vcpu
|
||||
|
||||
cloudinit = libvirt_cloudinit_disk.common_iso.id
|
||||
|
||||
network_interface {
|
||||
network_name = var.libvirt_network_name
|
||||
addresses = [var.server_ip]
|
||||
wait_for_lease = true
|
||||
}
|
||||
|
||||
|
|
@ -80,35 +71,38 @@ resource "libvirt_domain" "server" {
|
|||
target_type = "serial"
|
||||
}
|
||||
graphics {
|
||||
type = "spice"
|
||||
listen_type = "address"
|
||||
autoport = true
|
||||
type = "spice"
|
||||
listen_type = "address"
|
||||
autoport = true
|
||||
}
|
||||
}
|
||||
|
||||
# --- K3s Agent Node ---
|
||||
# --- K3s Agent Nodes ---
|
||||
resource "libvirt_volume" "agent_disk" {
|
||||
name = "${var.agent_hostname}-disk.qcow2"
|
||||
count = var.agent_count
|
||||
name = "${var.agent_hostname_prefix}-${count.index + 1}-disk.qcow2"
|
||||
base_volume_id = libvirt_volume.base_image.id
|
||||
pool = var.libvirt_pool
|
||||
size = var.vm_disk_size
|
||||
size = var.agent_disk_size
|
||||
format = "qcow2"
|
||||
}
|
||||
|
||||
resource "libvirt_domain" "agent" {
|
||||
name = var.agent_hostname
|
||||
memory = var.vm_memory
|
||||
vcpu = var.vm_vcpu
|
||||
resource "libvirt_domain" "agent" {
|
||||
count = var.agent_count
|
||||
name = "${var.agent_hostname_prefix}-${count.index + 1}"
|
||||
memory = var.agent_memory
|
||||
vcpu = var.agent_vcpu
|
||||
|
||||
cloudinit = libvirt_cloudinit_disk.common_iso.id
|
||||
|
||||
network_interface {
|
||||
network_name = var.libvirt_network_name
|
||||
addresses = [var.agent_ips[count.index]]
|
||||
wait_for_lease = true
|
||||
}
|
||||
|
||||
disk {
|
||||
volume_id = libvirt_volume.agent_disk.id
|
||||
volume_id = libvirt_volume.agent_disk[count.index].id
|
||||
}
|
||||
|
||||
console {
|
||||
|
|
@ -116,9 +110,9 @@ resource "libvirt_volume" "agent_disk" {
|
|||
target_port = "0"
|
||||
target_type = "serial"
|
||||
}
|
||||
graphics {
|
||||
type = "spice"
|
||||
listen_type = "address"
|
||||
autoport = true
|
||||
graphics {
|
||||
type = "spice"
|
||||
listen_type = "address"
|
||||
autoport = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue