This provider is still experimental/in development. To see what is left or planned, see the issues list.
This is a terraform provider that lets you provision servers on a libvirt host via Terraform.
Copied from the Terraform documentation:
To install a plugin, put the binary somewhere on your filesystem, then configure Terraform to be able to find it. The configuration where plugins are defined is ~/.terraformrc for Unix-like systems and %APPDATA%/terraform.rc for Windows.
The binary should be renamed to terraform-provider-libvirt
You should update your .terraformrc and refer to the binary:
providers {
libvirt = "/path/to/terraform-provider-libvirt"
}
Here is an example that will setup the following:
- A virtual server resource
(create this as libvirt.tf and run terraform commands from this directory):
provider "libvirt" {
uri = "qemu:///system"
}
You can also set the URI in the LIBVIRT_DEFAULT_URI environment variable.
Now, define a libvirt domain:
resource "libvirt_domain" "terraform_test" {
name = "terraform_test"
}
Now you can see the plan, apply it, and then destroy the infrastructure:
$ terraform plan
$ terraform apply
$ terraform destroy
- Install Go on your machine
- Set up Gopath
git clone
this repository into$GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
- Run
go get
to get dependencies - Run
go install
to build the binary. You will now find the binary at$GOPATH/bin/terraform-provider-libvirt
.
- create the example file libvirt.tf in your working directory
- terraform plan
- terraform apply
You need to define the LIBVIRT_DEFAULT_URI and TF_ACC variables:
export LIBVIRT_DEFAULT_URI=qemu:///system
export TF_ACC=1
go test ./...
-
There is a bug in libvirt that seems to be causing problems to unlink volumes. Tracked here.
If you see something like:
cannot unlink file '/var/lib/libvirt/images/XXXXXXXXXXXX': Permission denied
It is probably related.
- Duncan Mac-Vicar P. dmacvicar@suse.de
The structure and boilerplate is inspired from the Softlayer and Google Terraform provider sources.
- Apache 2.0, See LICENSE file