Files
ilkerandClaude Opus 5.5 71b30a8ac3 setup: install onto a libvirt host
The second setup backend, SITE_KIND=libvirt:

  libvirt   reaches the KVM host as root (or a sudo login) with the
            provisioner key, pinning its host key the first time; checks
            libvirt, /dev/kvm, the management bridge, qemu-img and curl,
            and installs none of them; puts a directory pool and the cloud
            image in place. On a host that is the control plane itself it
            authorises its own key for root.
  template  builds a head image: the cloud image copied, a build VM with a
            seed made here, the same golden.yml as Proxmox (now shared as
            bakeHead), its disk kept under a new name per build - heads'
            disks are overlays on it, so it is never rewritten in place.
  config    sites.yaml (kind libvirt, the pinned known_hosts), the unit's
            environment file, site.auto.tfvars naming the image.
  verify    the same checks by using them, and discovery through the
            provider with the settings the portal reads.

The libvirt module no longer takes the host's name: setup writes its
configuration before it has reached the host. Placement is held to one
host by comparing the hosts it chose with each other.

deploy/site.env.libvirt.example is held to its own validation, like the
Proxmox one. The interactive installer refuses a non-Proxmox site and
points at -yes -config. Tests cover the fields, what config writes and
that the portal can build a provider from it, every site.auto.tfvars
variable being declared by its environment (both backends), and the
host key pinned once and held to.

Not yet run against a real host end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:48:53 +01:00

64 lines
1.6 KiB
Terraform

# One cluster on a libvirt host. The portal copies this into each cluster's
# working directory beside the site's variables (site.auto.tfvars, written
# by `hpcod setup`) and the cluster's (cluster.auto.tfvars, written from its
# record).
terraform {
required_version = ">= 1.6"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.9.9"
}
cloudinit = {
source = "hashicorp/cloudinit"
version = "~> 2.3"
}
}
}
# qemu+ssh with the provisioner key, checked against the host key setup
# pinned when it first reached the host.
provider "libvirt" {
uri = var.libvirt_uri
}
module "tenant" {
source = "../../modules/libvirt"
cluster_id = var.cluster_id
tenant_id = var.tenant_id
tenant_name = var.tenant_name
head = var.head
compute = var.compute
mgmt_ip_cidr = var.mgmt_ip_cidr
head_host = var.head_host
compute_hosts = var.compute_hosts
devices = var.devices
apps = var.apps
control_plane_cert = var.control_plane_cert
started = var.started
pool = var.pool
head_base_path = var.head_base_path
mgmt_bridge = var.mgmt_bridge
mgmt_gateway = var.mgmt_gateway
nameservers = var.nameservers
mac_prefix = var.mac_prefix
ci_user = var.ci_user
ssh_public_keys = var.ssh_public_keys
}
output "tenant" {
value = {
bridge = module.tenant.bridge
subnet = module.tenant.subnet
head = module.tenant.head
compute = module.tenant.compute
}
}
output "ansible_inventory" {
value = module.tenant.ansible_inventory
}