• Stars
    star
    1,584
  • Rank 29,431 (Top 0.6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated 21 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terraform provider to provision infrastructure with Linux's KVM using libvirt

Terraform provider for libvirt

alpha Tests Registry


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

Introduction & Goals

This project exists:

  • To allow teams to get the benefits Software Defined Infrastructure Terraform provides, on top of classical and cheap virtualization infrastructure provided by Linux and KVM This helps in very dynamic DevOps, Development and Testing activities.
  • To allow for mixing KVM resources with other infrastructure Terraform is able to manage

What is NOT in scope:

  • To support every advanced feature libvirt supports

    This would make the mapping from terraform complicated and not maintanable. See the How to contribute section to understand how to approach new features.

Getting started

The provider is available for auto-installation from the Terraform Registry.

In your main.tf file, specify the version you want to use:

terraform {
  required_providers {
    libvirt = {
      source = "dmacvicar/libvirt"
    }
  }
}

provider "libvirt" {
  # Configuration options
}

And now run terraform init:

$ terraform init

Creating your first virtual machine

Here is an example that will setup the following:

  • A virtual server resource

(create this as main.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 and check the documentation.

Manual installation

You can also manually download the provider from the releases section on Github. To install it, refer to the Terraform documentation.

Building from source

  • Go is required for building.
git clone https://github.com/dmacvicar/terraform-provider-libvirt.git
cd terraform-provider-libvirt
make

The binary will be called terraform-provider-libvirt.

Using multiple hypervisors / provider instances

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

Using qemu-agent

From its documentation, qemu-agent:

It is a daemon program running inside the domain which is supposed to help management applications with executing functions which need assistance of the guest OS.

Until terraform-provider-libvirt 0.4.2, qemu-agent was used by default to get network configuration. However, if qemu-agent is not running, this creates a delay until connecting to it times-out.

In current versions, we default to not to attempt connecting to it, and attempting to retrieve network interface information from the agent needs to be enabled explicitly with qemu_agent = true, further details here. Note that you still need to make sure the agent is running in the OS, and that is unrelated to this option.

Note: when using bridge network configurations you need to enable the qemu_agent = true. otherwise you will not retrieve the ip adresses of domains.

Be aware that this variables may be subject to change again in future versions.

Upstream projects using terraform-libvirt:

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

More Repositories

1

site.org

Website in org mode
Emacs Lisp
43
star
2

bicho

ruby Bugzilla access library
Ruby
18
star
3

mirall

Mirall folder sharing (DEPRECATED, go here for the maintained fork https://github.com/nextcloud/desktop )
C++
14
star
4

ruby-rpm-ffi

New bindings for RPM (4.9.0+ for now)
Ruby
13
star
5

kopete-facebook

Facebook plugin for Kopete using the original Comet/HTTP endpoint (OBSOLETE)
C++
11
star
6

garita

Simple Docker v2 registry auth server in Go
Go
11
star
7

ob-d2

Generate d2 diagrams within Emacs org-mode babel
Emacs Lisp
10
star
8

qemacs

CVS import of qemacs for some experiments
C
9
star
9

dotfiles

Dotfiles managed with stow
Emacs Lisp
6
star
10

ruby-rpm

ruby bindings for rpm - DEPRECATED - See https://github.com/dmacvicar/ruby-rpm-ffi
C
6
star
11

gorgojo

Golang Bugzilla Client
Go
6
star
12

ruby-sfcc

ruby bindings for sblim client
C
6
star
13

awesome-foss

A list of free and open-source software I personally find outstanding/remarkable
5
star
14

fanotify_example

Example of fanotify API including the new FAN_DELETE in kernel 5.1
C
4
star
15

activecim

ActiveRecord like API for CIM
Ruby
3
star
16

salt-opensuse-playground

Vagrantfile to play with Salt on SUSE
SaltStack
3
star
17

opensuse-obs-client-android

Java
3
star
18

immubash

Storing entered bash commands in immudb
Go
3
star
19

iu

images indexer/searcher
C++
3
star
20

smt-ws

SMT webservice
Ruby
2
star
21

playground

My playground for unfinished experiments, mostly to move them between machines
Java
2
star
22

devise_unix2_chkpwd_authenticatable

Similar to devise_pam_authenticatable but uses unix2_chkpwd
Ruby
2
star
23

vmit

kvm helper tool
Ruby
2
star
24

enhancerepo

rpm-md repository extension generator
Ruby
2
star
25

smt-webconsole

2
star
26

piecechains.go

A Piece-Chains implementation in Golang
Go
1
star
27

sublime-config

Packages/User settings
1
star
28

minidj-indexer

Creates proprietary index for Typhoon My Mini DJ devices
C++
1
star
29

feta

FATE access library
Ruby
1
star
30

kiwi_diff

Compare KIWI configurations
Ruby
1
star