2021-03-22 19:52:11 +01:00
|
|
|
provider "opennebula" {
|
|
|
|
endpoint = var.one_endpoint
|
|
|
|
username = var.one_user
|
|
|
|
password = var.one_pass
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "dns" {
|
|
|
|
update {
|
|
|
|
server = var.dns_server
|
|
|
|
port = "53530"
|
|
|
|
key_name = var.dns_key_name
|
|
|
|
key_algorithm = var.dns_key_algo
|
|
|
|
key_secret = var.dns_key_secret
|
|
|
|
retries = 10
|
|
|
|
timeout = 300
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Production
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual networks
|
|
|
|
*/
|
|
|
|
resource "opennebula_virtual_network" "vnet"{
|
|
|
|
for_each = var.virtual_networks
|
|
|
|
name = each.key
|
|
|
|
vlan_id = each.value.vlan_id
|
|
|
|
permissions = "660"
|
|
|
|
bridge = var.one_vswitch
|
|
|
|
type = "ovswitch"
|
|
|
|
mtu = 1500
|
|
|
|
ar {
|
|
|
|
ar_type = each.value.adress_range.ar_type
|
|
|
|
size = each.value.adress_range.size
|
|
|
|
ip4 = each.value.adress_range.ip4
|
|
|
|
}
|
|
|
|
dns = each.value.dns
|
|
|
|
gateway = each.value.gateway
|
|
|
|
clusters = each.value.clusters
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VIRTUAL MACHINES
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Production
|
2021-03-22 21:04:38 +01:00
|
|
|
module "vms" {
|
2021-03-22 19:52:11 +01:00
|
|
|
source = "./modules/virtualMachine"
|
|
|
|
one_user = var.one_user
|
|
|
|
one_prod_ds = var.one_prod_ds
|
2021-03-22 21:04:38 +01:00
|
|
|
for_each = var.virtual_machines
|
2021-03-22 19:52:11 +01:00
|
|
|
|
2021-03-22 21:04:38 +01:00
|
|
|
vm_shortname = each.key
|
|
|
|
vm_fqdn = each.value.fqdn
|
2021-03-22 19:52:11 +01:00
|
|
|
vm_domain = var.dns_domain
|
2021-03-22 21:04:38 +01:00
|
|
|
dns_a_record = each.value.create_dns_a_record
|
2021-03-22 19:52:11 +01:00
|
|
|
|
2021-03-22 21:04:38 +01:00
|
|
|
cpu = each.value.cpu
|
|
|
|
vcpu = each.value.vcpu
|
|
|
|
ram = each.value.memory
|
2021-03-23 10:12:24 +01:00
|
|
|
dynamic "network_interfaces"
|
|
|
|
{
|
2021-03-23 10:06:27 +01:00
|
|
|
for_each = each.value.network_interfaces
|
2021-03-23 10:12:24 +01:00
|
|
|
content {
|
|
|
|
network_id = opennebula_virtual_network.vnet[each.value.network_name].id,
|
|
|
|
ip = opennebula_virtual_network.vnet[each.value.network_name].ip4
|
|
|
|
}
|
2021-03-23 10:06:27 +01:00
|
|
|
}
|
2021-03-22 21:04:38 +01:00
|
|
|
tag_labels = each.value.labels
|
2021-03-22 19:52:11 +01:00
|
|
|
|
2021-03-22 21:04:38 +01:00
|
|
|
system_image_name = each.value.disks.system.name
|
2021-03-22 19:52:11 +01:00
|
|
|
data_image_name = ""
|
|
|
|
|
2021-03-22 21:04:38 +01:00
|
|
|
system_image_source = each.value.disks.system.source
|
2021-03-22 19:52:11 +01:00
|
|
|
data_image_source = ""
|
|
|
|
|
2021-03-22 21:13:02 +01:00
|
|
|
depends = [
|
2021-03-22 21:48:32 +01:00
|
|
|
opennebula_virtual_network.vnet[each.value.depends[0]].id
|
2021-03-22 21:13:02 +01:00
|
|
|
]
|
2021-03-22 19:52:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Additionnal DNS Entry
|
|
|
|
module "ber_asso_fr" {
|
|
|
|
source = "./modules/cadolesDNS"
|
|
|
|
dns_domain = "cadoles.com."
|
|
|
|
dns_a_records = var.dns_a_records
|
|
|
|
dns_cname_records = var.dns_cname_records
|
|
|
|
depends = [ module.dns.virtual_machine_shortname ]
|
|
|
|
}
|
|
|
|
*/
|