Terraforms examples with terraform-provider-libvirt.
I use qemu/KVM images built with packer thanks to this project : packer-kvm. They are regularly published on a website.
Only for education and learning purposes. Do not use it in production.
Terraform is an Infrastructure as Code (IaC) tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.
Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.
The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.What is Terraform?
Here we use the third party terraform-provider-libvirt to manage Libvirt resources as networks, storage pools, volumes, template for cloud-init iso disk with count functions and any provisioners.
Setup a local installation on your virtualization host with Libvirt, Terraform and the Libvirt provider plugin for Terraform (Ubuntu bionic) :
git clone https://github.com/goffinet/terraform-libvirt
cd terraform-libvirt/
bash -x setup.sh
- basics examples terraform-provider-libvirt resources based on contribs.
- network labs ported from bash.
git clone https://github.com/goffinet/terraform-libvirt
cd terraform-libvirt/basics/ubuntu
terraform plan
cd terraform-libvirt/basics/ubuntu
docker run --rm --privileged --cap-add=ALL \
-v /lib/modules:/lib/modules \
-v /var/lib/libvirt:/var/lib/libvirt \
-v /var/log:/var/log \
-v /run:/run \
-v `pwd`:/opt/ \
-w /opt/ \
-it \
goffinet/terraform terraform init