This repository contains terraform modules to quickly create libvirt
VMs from cloud images using Terraform with libvirt provider.
- KVM supported Linux Machine
libvirtd
is up and running- Terraform.
-
modules/net
- Creates a Networkmodule "vnet" { source = "git::https://github.com/tprasadtp/tfm-libvirt.git//modules/net" name = "test" domain = "test.kvm" subnet = "192.168.127.0/24" }
-
modules/vm
- Creates VMmodule "vm" { source = "git::https://github.com/tprasadtp/tfm-libvirt.git//modules/vm" cloudimage = pathexpand("~/Virtual/installers/focal-server-cloudimg-amd64.img") cloudimage_format = "raw" name = "test" network = "test" vcpu = 1 memory = 256 vcpu_model_host = true user_data = file("${path.module}/user-data.cfg") }
- This module is meant to quickly create headless machines in a reproducible way.
- VMs with UI are NOT supported!, vm module even strips off all video/spice devices!
- Advanced configs are not supported. You might look into provider's documentation for creating VMs which support additional features.
- Tests spin up VMs and asserts they are running with right config using ansible.
- You can use already installed version of ansible if you wish. Otherwise,
poetry install
VMs use cloud images as its easier to configure them them using cloud-init
.