Week 4 ‐ KVM and Terraform - AlanK23/Sec-350-01 GitHub Wiki

Terraform Provider and Configuration

main.tf contains terraform block with dmacvicar/libvirt provider (version ~> 0.9) and provider block with uri = qemu:///system

Variables and Student Isolation

variables.tf defines student_name with regex validation, cpu_cores, ram_size, image_path, and vm_name with correct types and defaults

Disk Copy with terraform_data

terraform_data resource copies qcow2 image from /opt/images/ into libvirt storage pool; destroy provisioner removes copied image

Domain (VM) Configuration

libvirt_domain resource defines VM with correct name, memory, vcpu, cpu passthrough, OS type, disk attachment, network interface, Spice graphics, and serial console

Outputs and terraform.tfvars

href link for outputs.tf defines vm_name and vnc_display outputs; terraform.tfvars sets student_name and other personal defaults

Deployment and Verification

terraform init/plan/apply succeeds; VM boots and is accessible via Spice or RDP; terraform destroy cleans up all resources

GitHub Push

sys350-infra/ repository pushed to GitHub with .gitignore excluding .terraform/ and terraform.tfstate; per-VM directories (windows-server, windows-client) are properly structured

  • done