143 lines
2.8 KiB
HCL
143 lines
2.8 KiB
HCL
|
|
# Variables
|
|
# =====================
|
|
|
|
variable "tenant" {
|
|
description = "Tenant informations"
|
|
type = any
|
|
default = {
|
|
prefix = ""
|
|
}
|
|
}
|
|
|
|
variable "instance_defaults" {
|
|
description = "Instances default definitions"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
// variable "networks_catalog" {
|
|
// description = "Known networks to find domain"
|
|
// type = any
|
|
// default = {}
|
|
// }
|
|
|
|
// variable "images_catalog" {
|
|
// description = "Available images"
|
|
// type = any
|
|
// default = {}
|
|
// }
|
|
|
|
// variable "oses_catalog" {
|
|
// description = "Available OS images"
|
|
// type = any
|
|
// default = {}
|
|
// }
|
|
|
|
// variable "flavors_catalog" {
|
|
// description = "Available falvors"
|
|
// type = any
|
|
// default = {}
|
|
// }
|
|
|
|
variable "catalog" {
|
|
description = "Existing catalog"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "instances" {
|
|
description = "Instances definitions"
|
|
type = any
|
|
default = []
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Resources
|
|
# =====================
|
|
|
|
// locals {
|
|
// pre_default = {
|
|
// network = "default"
|
|
// domain = "no_domain22"
|
|
// }
|
|
// default_network = try(var.networks_catalog[var.instances_defaults.default_network], null) != null ? var.instances_defaults.default_network : local.pre_default.network
|
|
|
|
// networks = local.default_network != null ? [{ name = "${var.tenant.prefix}${local.default_network}" }] : []
|
|
// domain = try( var.networks_catalog[local.default_network].domain, local.pre_default.domain)
|
|
|
|
// # Recommended default flavor
|
|
// default = {
|
|
// number = 1
|
|
// instance_pool = "default"
|
|
// flavor = "default"
|
|
|
|
// # From images !
|
|
// images = {}
|
|
// disk_gb = 14
|
|
// os = "cirros_0.5"
|
|
// memory = 1024
|
|
// user = ""
|
|
// image_base_pool = "default"
|
|
// image_base_file = "missing.qcow2"
|
|
// metadata = {}
|
|
|
|
// vcpu = 1
|
|
// disks = []
|
|
// volumes = []
|
|
// name_fqdn = true
|
|
// wait_for_lease = false
|
|
// password_hash = ""
|
|
// authorized_key = ""
|
|
|
|
// prefix = var.tenant.prefix
|
|
// default_network = local.default_network
|
|
// networks = local.networks
|
|
// domain = local.domain
|
|
// }
|
|
// instances_defaults = merge(local.default, var.instances_defaults)
|
|
// }
|
|
|
|
|
|
module "cloud_instances" {
|
|
source = "../cloud_instance"
|
|
|
|
for_each = { for v in var.instances : v.name => merge(var.instance_defaults, v) }
|
|
|
|
// count = var.instances
|
|
|
|
tenant = var.tenant
|
|
instance_defaults = var.instance_defaults
|
|
|
|
|
|
catalog = var.catalog
|
|
// networks_catalog = var.networks_catalog
|
|
// images_catalog = var.images_catalog
|
|
// oses_catalog = var.oses_catalog
|
|
// flavors_catalog = var.flavors_catalog
|
|
|
|
// instance = var.instances[count.index]
|
|
instance = each.value
|
|
}
|
|
|
|
|
|
|
|
|
|
# Outputs
|
|
# =====================
|
|
output "instances" {
|
|
value = module.cloud_instances
|
|
}
|
|
|
|
# output "DEBUG" {
|
|
# value = {
|
|
# NORMAL = module.virt_instances
|
|
# INSTANCES = var.instances
|
|
# INSTANCES_defaults = var.instances_defaults
|
|
# }
|
|
# }
|
|
|