diff --git a/terraform/04-virtual-machines.tfvars b/terraform/04-virtual-machines.tfvars index e69de29..c461ca6 100644 --- a/terraform/04-virtual-machines.tfvars +++ b/terraform/04-virtual-machines.tfvars @@ -0,0 +1,46 @@ +virtual_machines = { + amon = { + fqdn = "amon.fabrica.local", + domain = "fabrica.local", + create_dns_a_record = "no", + cpu = 0.4, + vcpu = 4, + memory = 4096, + network_interfaces = [ + { network_name = "internet", ip = "192.168.1.3" }, + { network_name = "office", ip = "192.168.10.254" } + ], + + labels = "Production, Amon, Infra, Backup, EOLE" + + disks = { + system = { + name = "prod-amon-static", + source = "http://localhost/fabrica/infra/production/amon.fabrica.local/system/amon.fabrica.local" + } + ] + + depends = [ opennebula_virtual_network.production.id ] + }, + scribe = { + fqdn = "scribe.fabrica.local", + domain = "fabrica.local", + create_dns_a_record = "no", + cpu = 0.4, + vcpu = 4, + memory = 4096, + network_interfaces = [ + { network_name = "office", ip = "192.168.10.200" } + ], + + labels = "Production, Scribe, Infra, Backup, EOLE" + + disks = { + system = { + name = "prod-scribe-static", + source = "http://localhost/fabrica/infra/production/scribe.fabrica.local/system/scribe.fabrica.local" + } + ] + + depends = [ opennebula_virtual_network.production.id ] + }, \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index ff88288..bc2e165 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -45,38 +45,30 @@ resource "opennebula_virtual_network" "vnet"{ */ // Production - -/* Amon -module "amon" { +module "vms" { source = "./modules/virtualMachine" one_user = var.one_user one_prod_ds = var.one_prod_ds + for_each = var.virtual_machines - vm_shortname = "amon" - vm_fqdn = "amon.ber.asso.fr" + vm_shortname = each.key + vm_fqdn = each.value.fqdn vm_domain = var.dns_domain - dns_a_record = "no" + dns_a_record = each.value.create_dns_a_record - cpu = 0.4 - vcpu = 4 - ram = 4096 - network_interfaces = [ - { network_id = opennebula_virtual_network.internet.id, ip = "192.168.1.2"}, - { network_id = opennebula_virtual_network.production.id, ip = "192.168.5.254"}, - { network_id = opennebula_virtual_network.office.id, ip = "192.168.10.254"}, - ] + cpu = each.value.cpu + vcpu = each.value.vcpu + ram = each.value.memory + network_interfaces = each.value.network_interfaces + tag_labels = each.value.labels - tag_labels = "Production,Infrastructure,Amon,Firewall,EOLE" - - system_image_name = "PROD-AMON-STATIC" + system_image_name = each.value.disks.system.name data_image_name = "" - system_image_source = "http://hapy-ber.ber.asso.fr/factory/ber/production/amon.ber.asso.fr/system/amon.ber.asso.fr_latest.img" + system_image_source = each.value.disks.system.source data_image_source = "" - depends = [ - opennebula_virtual_network.production.id - ] + depends = each.value.depends } diff --git a/terraform/variables.tf b/terraform/variables.tf index 9ad8df0..2cf3ece 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -73,4 +73,10 @@ variable "virtual_networks" { description = "OpenNebula virtual networks definition" type = map default = {} +} + +variable "virtual_machines" { + description = "OpenNebula virtual machines definition" + type = map + default = {} } \ No newline at end of file