diff --git a/terraform/main.tf b/terraform/main.tf index 7eac081..c337a79 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -40,12 +40,12 @@ module "vm-n8n" { module "inventory" { source = "./modules/proxmox_ansible_inventory" - filename = "${abspath("${path.root}/..")}/ansible/inventory/inventory.yml" + filename = "${path.root}/ansible/inventory/inventory.yml" instances = local.vm_created } module "vm_data" { source = "./modules/proxmox_vm_data" - filename = "${abspath("${path.root}/..")}/terraform/vm_data.yml" + filename = "${path.root}/terraform/vm_data.yml" instances = local.vm_created } diff --git a/terraform/variables.tf b/terraform/variables.tf index 1cb6ece..7555c66 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,40 +1,44 @@ variable "instance_mode" { - type = string - default = "single" + type = string + description = "single or multiple" + + validation { + condition = contains(["single", "multiple"], var.instance_mode) + error_message = "instance_mode must be either single or multiple." + } } variable "instance" { - description = "Single instance definition" type = object({ - service_name = string - vm_name = string - node_name = string - vm_cpu = optional(number) - vm_ram = optional(number) - vm_size = optional(string) - app_port = number - app_image = string - vm_tags = optional(list(string)) + service_name = string + vm_name = string + node_name = string + vm_cpu = optional(number) + vm_ram = optional(number) + vm_size = optional(string) + vm_tags = optional(list(string)) }) - default = null + default = null + nullable = true + description = "Used only when instance_mode = single." } variable "instances" { - description = "Multiple instance definitions" type = map(object({ - service_name = string - vm_name = string - node_name = string - vm_cpu = optional(number) - vm_ram = optional(number) - vm_size = optional(string) - app_port = number - app_image = string - vm_tags = optional(list(string)) + service_name = string + vm_name = string + node_name = string + vm_cpu = optional(number) + vm_ram = optional(number) + vm_size = optional(string) + vm_tags = optional(list(string)) })) - default = {} + default = {} + nullable = false + description = "Used only when instance_mode = multiple." } + variable "vm_defaults" { type = object({ node_datastore = string