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
|
|
|
|
*/
|
2021-03-23 10:47:39 +01:00
|
|
|
resource "opennebula_virtual_network" "vnets"{
|
2021-03-22 19:52:11 +01:00
|
|
|
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
|
|
|
|
module "vms" {
|
|
|
|
source = "./modules/virtualMachine"
|
|
|
|
one_user = var.one_user
|
|
|
|
one_prod_ds = var.one_prod_ds
|
|
|
|
for_each = var.virtual_machines
|
|
|
|
|
|
|
|
vm_shortname = each.key
|
|
|
|
vm_fqdn = each.value.fqdn
|
|
|
|
vm_domain = var.dns_domain
|
|
|
|
dns_a_record = each.value.create_dns_a_record
|
|
|
|
|
|
|
|
cpu = each.value.cpu
|
|
|
|
vcpu = each.value.vcpu
|
|
|
|
ram = each.value.memory
|
|
|
|
|
2021-03-23 10:47:39 +01:00
|
|
|
vnets = opennebula_virtual_network.vnets
|
2021-03-22 19:52:11 +01:00
|
|
|
network_interfaces = each.value.network_interfaces
|
|
|
|
|
|
|
|
tag_labels = each.value.labels
|
|
|
|
|
|
|
|
system_image_name = each.value.disks.system.name
|
|
|
|
data_image_name = ""
|
|
|
|
|
|
|
|
system_image_source = each.value.disks.system.source
|
|
|
|
data_image_source = ""
|
|
|
|
|
2021-03-23 10:47:39 +01:00
|
|
|
depends = [
|
|
|
|
for dp in each.value.network_interfaces:
|
|
|
|
opennebula_virtual_network.vnets[dp.network_name].id
|
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 ]
|
|
|
|
}
|
|
|
|
*/
|