56 lines
857 B
HCL
56 lines
857 B
HCL
|
|
# Variables
|
|
# =====================
|
|
|
|
variable "tenant" {
|
|
description = "Tenant informations"
|
|
type = any
|
|
default = {
|
|
prefix = ""
|
|
}
|
|
}
|
|
|
|
variable "pools" {
|
|
description = "Pools definitions"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "pools_defaults" {
|
|
description = "Pools default definitions"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
|
|
locals {
|
|
defaults = {
|
|
root_dir = "/virt"
|
|
}
|
|
pools_defaults = merge(local.defaults, var.pools_defaults)
|
|
}
|
|
|
|
|
|
# Resources
|
|
# =====================
|
|
|
|
resource "libvirt_pool" "pooldef" {
|
|
for_each = var.pools
|
|
|
|
name = "${each.key}"
|
|
path = length(
|
|
regexall("^/", try( each.value.dir, ""))
|
|
) > 0 ? "${each.value.dir}" : "${local.pools_defaults.root_dir}/${try( each.value.dir, each.key)}"
|
|
type = "dir"
|
|
|
|
}
|
|
|
|
|
|
# Output
|
|
# =====================
|
|
|
|
output "pools" {
|
|
value = resource.libvirt_pool.pooldef
|
|
}
|
|
|