commit e831f2f4d224d57aa38402ddf6b25997f2b40d0a
parent e5dc54c37f9bfff07e52d7871a3837e02f5eb6f0
Author: Dionysis Grigoropoulos <dgrig@erethon.com>
Date: Mon, 7 Dec 2020 02:32:16 +0200
libvirt_host: Support file and volume based hosts
* Add support for the creation of hosts based on either volumes or ISO
files for use in a LiveCD environment.
* Add variable to allow Spice to listen to localhost
Diffstat:
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/terraform/modules/libvirt_host/main.tf b/terraform/modules/libvirt_host/main.tf
@@ -37,21 +37,11 @@ resource "libvirt_domain" "libvirt_host" {
dev = ["hd"]
}
- #disk {
- # volume_id = (libvirt_volume.volume[0].id != "" ? libvirt_volume.volume[0].id : null)
- #}
-
- #disk {
- # file = (var.iso != "" ? var.iso : null)
- # scsi = (var.iso != "" ? false : null)
- #}
-
dynamic "disk" {
for_each = var.disks
- iterator = disk
content {
- #file = (disk.iso != "" ? disk.iso : null)
- volume_id = (libvirt_volume.volume[0].id != "" ? libvirt_volume.volume[0].id : null)
+ file = lookup(disk.value, "iso", null)
+ volume_id = (lookup(disk.value, "volume_id", null) != null ? libvirt_volume.volume[0].id : null)
}
}
@@ -62,6 +52,6 @@ resource "libvirt_domain" "libvirt_host" {
graphics {
type = "spice"
- listen_type = "none"
+ listen_type = (var.enable_graphics == true ? "address" : "none")
}
}
diff --git a/terraform/modules/libvirt_host/vars.tf b/terraform/modules/libvirt_host/vars.tf
@@ -76,12 +76,12 @@ variable "base_volume_id" {
default = ""
}
-variable "iso" {
- type = string
- default = ""
+variable "disks" {
+ type = list(map(any))
+ default = [{}]
}
-variable "disks" {
- type = list
- default = []
+variable enable_graphics {
+ type = bool
+ default = false
}
diff --git a/terraform/modules/libvirt_network/versions.tf b/terraform/modules/libvirt_network/versions.tf
@@ -1,7 +1,7 @@
terraform {
required_providers {
libvirt = {
- source = "erethon.com/third-party/libvirt"
+ source = "erethon.com/third-party/libvirt"
version = "0.6.2"
}
}