terraform + libvirt

Using Terraform with KVM/QEMU

These are my notes on using Terraform to provision libvirt/kvm instances. Though Terraform really shines in the cloud, I wanted to set this to experiment with Terraform on local hardware. It took a lot longer than I expected so this is to document my missteps and eventual resolution.

Setup Host Machine

  • Install Terraform

  • Instill libvirt development packages

  • Install Golang

  • Install mkisofs

Download/Build libvirt

  • Check out the git repository

  • Build the binary

  • Copy to the requisite paths

Create Terraform plan

  • Use the following


terraform {

required_version ">= 0.13"

required_providers {

libvirt = {

source = "dmacvicar/libvirt"

version= "0.6.0"

}

}

}




  • Connection URI

    • uri = "qemu+ssh://root@192.168.5.201/system" <- Use this if you have SSH key to root

    • uri