Double check that security_driver = "none"
is uncommented in /etc/libvirt/qemu.conf
and restart sudo systemctl restart libvirtd
for permission denied issue
cd /tmp/
mkdir -p ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64
wget https://github.com/dmacvicar/terraform-provider-libvirt/releases/download/v0.6.2/terraform-provider-libvirt-0.6.2+git.1585292411.8cbe9ad0.Ubuntu_18.04.amd64.tar.gz
tar -xvf terraform-provider-libvirt-0.6.2+git.1585292411.8cbe9ad0.Ubuntu_18.04.amd64.tar.gz
mv ./terraform-provider-libvirt ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64/
mkdir -p ~/workspace/terraform-kvm-example/
cd ~/workspace/terraform-kvm-example/
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_volume" "centos7-qcow2" {
name = "centos7.qcow2"
pool = "default"
source = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
format = "qcow2"
}
resource "libvirt_domain" "db1" {
name = "db1"
memory = "1024"
vcpu = 1
network_interface {
network_name = "default"
}
disk {
volume_id = libvirt_volume.centos7-qcow2.id
}
console {
type = "pty"
target_type = "serial"
target_port = "0"
}
graphics {
type = "spice"
listen_type = "address"
autoport = true
}
}
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.2"
}
}
}
terraform init
terraform plan
terraform apply
- https://github.com/dmacvicar/terraform-provider-libvirt/tree/master/examples/v0.13
- https://computingforgeeks.com/how-to-provision-vms-on-kvm-with-terraform/
- https://github.com/dmacvicar/terraform-provider-libvirt/releases
- https://gist.github.com/nrocco/072ea98cca82e4721b2289cb75558da1
- https://www.terraform.io/upgrade-guides/0-13.html#in-house-providers
- dmacvicar/terraform-provider-libvirt#747 (comment)
- https://discuss.hashicorp.com/t/automating-kvm-infrastructure-deployment-with-terraform-libvirt-library/3515
- dmacvicar/terraform-provider-libvirt#546 (comment)
- https://devonhubner.org/Terraform_provider_for_Libvirt/
- https://blog.gruntwork.io/terraform-tips-tricks-loops-if-statements-and-gotchas-f739bbae55f9