A small project using Terraform to deploy a ubuntu, fedora, and centos instances on KVM for training purposes.
- Ubuntu Server 21.10 for bare metal
- focal-server-cloudimg-amd64.img for ubuntu
- Fedora-Cloud-Base-35-1.2.x86_64.raw.xz for fedora - extract and convert using qemu-image to .qcow2
- CentOS-7-x86_64-GenericCloud-2111.qcow2 for virtual machines
This will do a bunch of things including installing necessary packages, configuring your network interface, creating a bridge, creating a libvirt storage pool, and downloading cloud images.
- Assumes existence of /mnt/kvm directory. Consider mounting this to a logical volume.
sudo sh hostconfig.sh
- Update netplan to match your network environment.
- Update cloud_init to match your network environment and supply your own ssh public keys.
Initialize a Terraform working directory
terraform init
Generate and show Terraform execution plan
terraform plan
Then build your Terraform infrastructure
terraform apply
Check your infrastructure use virsh
virsh list --all
You can destroy your Terraform infrastructure
terraform destroy