From 9f05f09e5d09c0275a43e0333a2dfc8f1be6ffaf Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Fri, 20 Jan 2023 13:18:20 +0100 Subject: [PATCH] fix(module): updating default values on virtualMachine --- modules/virtualMachine/main.tf | 19 +++++-------------- modules/virtualMachine/outputs.tf | 10 +++++++--- modules/virtualMachine/variables.tf | 4 ++++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/modules/virtualMachine/main.tf b/modules/virtualMachine/main.tf index 7a32671..d90c1dd 100644 --- a/modules/virtualMachine/main.tf +++ b/modules/virtualMachine/main.tf @@ -1,13 +1,6 @@ -// Dependencies management -resource "null_resource" "depends_on" { - triggers = { - depends_on = join("", var.depends) - } -} - // OpenNebula disk image ! resource "opennebula_image" "system" { - name = var.system_image_name + name = local.system_image_name description = "System disk image" datastore_id = var.one_prod_ds persistent = false @@ -21,7 +14,7 @@ resource "opennebula_image" "system" { } resource "opennebula_image" "data" { - name = var.data_image_name + name = local.data_image_name description = "Data disk image" datastore_id = var.one_prod_ds persistent = true @@ -78,12 +71,10 @@ resource "opennebula_template" "vm_template" { // OpenNebula Virtual Machine resource "opennebula_virtual_machine" "vm" { - name = var.vm_fqdn + name = local.fqdn group = var.group - timeout = 10 template_id = opennebula_template.vm_template.id - depends_on = [ opennebula_template.vm_template, - null_resource.depends_on ] + depends_on = [ opennebula_template.vm_template ] } resource "dns_a_record_set" "vm_dns_a_record" { @@ -102,7 +93,7 @@ resource "dns_cname_record" "vm_dns_cname_record" { zone = var.vm_domain name = each.value - cname = "${var.vm_fqdn}." + cname = "${local.fqdn}." ttl = 300 depends_on = [ opennebula_virtual_machine.vm ] diff --git a/modules/virtualMachine/outputs.tf b/modules/virtualMachine/outputs.tf index 70084b5..1dd24a1 100644 --- a/modules/virtualMachine/outputs.tf +++ b/modules/virtualMachine/outputs.tf @@ -1,9 +1,13 @@ -output "virtual_machine_shortname" { +output "shortname" { value = opennebula_virtual_machine.vm.name } -output "virtual_machine_nic0_mac" { - value = opennebula_virtual_machine.vm.nic[0].mac +output "fqdn" { + value = var.vm_fqdn +} + +output "first_nic_mac" { + value = opennebula_virtual_machine.vm.template_nic[0].computed_mac } output "network_interfaces" { diff --git a/modules/virtualMachine/variables.tf b/modules/virtualMachine/variables.tf index 31d9e69..e7dc32f 100644 --- a/modules/virtualMachine/variables.tf +++ b/modules/virtualMachine/variables.tf @@ -26,21 +26,25 @@ variable "vm_domain" { variable "system_image_name" { description = "System image disk name" type = string + default = "${var.vm_shortname}.system" } variable "system_image_source" { description = "Virtual Machine system image source" type = string + default = "https://marketplace.opennebula.io//appliance/251b0578-6c47-4ba4-b184-dc6e873201a2/download/0" } variable "data_image_name" { description = "Data image disk name" type = string + default = "${var.vm_shortname}.data" } variable "data_image_source" { description = "Virtual Machine data disk image source" type = string + default = "https://marketplace.opennebula.io//appliance/251b0578-6c47-4ba4-b184-dc6e873201a2/download/0" } variable "tag_labels" {