# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r terraform { required_version = ">= 0.12" required_providers { null = "~> 2.1" template = "~> 2.1" libvirt = ">= 0.0.0" } backend "etcdv3" { endpoints = ["https://100.64.0.19:2379"] lock = true prefix = "/terraform-state/stack" cacert_path = "/home/antoine/virtualization/kubernetes-the-hard-way/certs/ca.pem" cert_path = "/home/antoine/virtualization/kubernetes-the-hard-way/certs/kubernetes.pem" key_path = "/home/antoine/virtualization/kubernetes-the-hard-way/certs/kubernetes-key.pem" } } provider "libvirt" { uri = "qemu+tcp://dx30.localdomain/system" } data "template_file" "user_data" { template = "${file("${path.module}/cloud_init.cfg")}" } variable "pool_1" { type = string default = "pool_1" description = "already created pool name, set with variable because libvirt provider dont' wotk with data resource" } variable "debian_buster_qcow2" { type = string default = "debian-buster.qcow2" description = "already created debian vol, set with variable because libvirt provider dont' wotk with data resource" } variable "centos7_qcow2" { type = string default = "centos7.qcow2" description = "already created centos vol, set with variable because libvirt provider dont' wotk with data resource" } # Use CloudInit to add the instance resource "libvirt_cloudinit_disk" "commoninit" { name = "commoninit.iso" pool = var.pool_1 user_data = data.template_file.user_data.rendered } resource "null_resource" "delay_10s" { provisioner "local-exec" { command = "sleep 10" } triggers = { "before" = libvirt_domain.db1.id } } # Output Server IP output "ip" { value = libvirt_domain.db1.network_interface depends_on = [null_resource.delay_10s] }