terraform-provider-libvirt

command module
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

README

Terraform provider for libvirt

alpha Build Status


This is a terraform provider that lets you provision servers on a libvirt host via Terraform.

Table of Content

Website Docs

Downloading

Builds for openSUSE, CentOS, Ubuntu, Fedora are created with openSUSE's OBS. The build definitions are available for both the stable and master branches.

Using released builds

  • Head to the releases section and download the latest stable release build for your distribution.

Using unstable builds

Using community packages

If you are using opensuse/SUSE distro, add the repo and download the package (check the repo according your distro)

NOTE: This may not be the latest release.


DISTRO=openSUSE_Leap_42.3
zypper addrepo http://download.opensuse.org/repositories/Virtualization:containers/$DISTRO/Virtualization:containers.repo
zypper refresh
zypper install terraform-provider-libvirt

Building from source

Before building, you will need the following

  • libvirt 1.2.14 or newer development headers
  • latest golang version
  • cgo is required by the libvirt-go package. export CGO_ENABLED="1"

This project uses glide to vendor all its dependencies.

You do not have to interact with glide since the vendored packages are already included in the repo.

Ensure you have the latest version of Go installed on your system, terraform usually takes advantage of features available only inside of the latest stable release.

You need also need libvirt-dev(el) package installed.

go get github.com/dmacvicar/terraform-provider-libvirt
cd $GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
go install

You will now find the binary at $GOPATH/bin/terraform-provider-libvirt.

Installing

  • Check that libvirt daemon 1.2.14 or newer is running on the hypervisor
  • mkisofs is required to use the CloudInit

Copied from the Terraform documentation:

At present Terraform can automatically install only the providers distributed by HashiCorp. Third-party providers can be manually installed by placing their plugin executables in one of the following locations depending on the host operating system:

On Linux and unix systems, in the sub-path .terraform.d/plugins in your user's home directory.

On Windows, in the sub-path terraform.d/plugins beneath your user's "Application Data" directory.

terraform init will search this directory for additional plugins during plugin initialization.

Using the provider

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 init
$ terraform plan
$ terraform apply
$ terraform destroy

Look at more advanced examples here

Using multiple hypervisors / provider instances

You can target different libvirt hosts instantiating the provider multiple times. Example.

Troubleshooting (aka you have a problem)

Have a look at TROUBLESHOOTING, and feel free to add a PR if you find out something is missing.

Authors

See also the list of contributors who participated in this project.

The structure and boilerplate is inspired from the Softlayer and Google Terraform provider sources.

License

  • Apache 2.0, See LICENSE file

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL