Adding vm definition

This commit is contained in:
Philippe Caseiro 2021-03-22 21:04:38 +01:00
parent f4dc2409dd
commit fa4724f6b1
3 changed files with 65 additions and 21 deletions

View File

@ -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 ]
},

View File

@ -45,38 +45,30 @@ resource "opennebula_virtual_network" "vnet"{
*/ */
// Production // Production
module "vms" {
/* Amon
module "amon" {
source = "./modules/virtualMachine" source = "./modules/virtualMachine"
one_user = var.one_user one_user = var.one_user
one_prod_ds = var.one_prod_ds one_prod_ds = var.one_prod_ds
for_each = var.virtual_machines
vm_shortname = "amon" vm_shortname = each.key
vm_fqdn = "amon.ber.asso.fr" vm_fqdn = each.value.fqdn
vm_domain = var.dns_domain vm_domain = var.dns_domain
dns_a_record = "no" dns_a_record = each.value.create_dns_a_record
cpu = 0.4 cpu = each.value.cpu
vcpu = 4 vcpu = each.value.vcpu
ram = 4096 ram = each.value.memory
network_interfaces = [ network_interfaces = each.value.network_interfaces
{ network_id = opennebula_virtual_network.internet.id, ip = "192.168.1.2"}, tag_labels = each.value.labels
{ network_id = opennebula_virtual_network.production.id, ip = "192.168.5.254"},
{ network_id = opennebula_virtual_network.office.id, ip = "192.168.10.254"},
]
tag_labels = "Production,Infrastructure,Amon,Firewall,EOLE" system_image_name = each.value.disks.system.name
system_image_name = "PROD-AMON-STATIC"
data_image_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 = "" data_image_source = ""
depends = [ depends = each.value.depends
opennebula_virtual_network.production.id
]
} }

View File

@ -74,3 +74,9 @@ variable "virtual_networks" {
type = map type = map
default = {} default = {}
} }
variable "virtual_machines" {
description = "OpenNebula virtual machines definition"
type = map
default = {}
}