From 37ad816a696fa1f6c4f97a70e676d76cc55a2c9f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 5 Dec 2023 10:06:23 +0100 Subject: [PATCH 1/2] Added server_groups_ids as input paramater and managed it --- openstack-tf/d4s-dev/geoportal/main.tf | 30 ++++++++++++++-- openstack-tf/d4s-dev/geoserver_new/main.tf | 27 +++++++++----- openstack-tf/d4s-dev/uri-resolver/main.tf | 27 +++++++++++--- .../modules/common_variables/outputs.tf | 36 ++++++++++--------- .../modules/common_variables/variables.tf | 23 ++++++++---- .../generic_smartgears_service.tf | 18 ++++++++-- .../generic_smartgears_service/outputs.tf | 4 +++ .../variables_generic_smartgears_service.tf | 12 +++++-- .../modules/geo_services/geo_service.tf | 12 ++++++- openstack-tf/modules/geo_services/inputs.tf | 7 ++-- 10 files changed, 150 insertions(+), 46 deletions(-) diff --git a/openstack-tf/d4s-dev/geoportal/main.tf b/openstack-tf/d4s-dev/geoportal/main.tf index 4755adb8..c7ce5cd2 100644 --- a/openstack-tf/d4s-dev/geoportal/main.tf +++ b/openstack-tf/d4s-dev/geoportal/main.tf @@ -18,17 +18,43 @@ data "terraform_remote_state" "privnet_dns_router" { } +# +# Uses common_variables as module +# +module "common_variables" { + source = "../../modules/common_variables" +} + + +# +# Creates the server group "geoportal" +# +resource "openstack_compute_servergroup_v2" "geoportal" { + name = "geoportal" + policies = [module.common_variables.policy_list.soft_anti_affinity] +} + + +# +# Uses the "generic_smartgears_service" as module +# module "smartgears_service_generic" { source = "../../modules/generic_smartgears_service" + # Here, you can overwrite the openstack_vm_data_scripts to run for ubuntuXYZ.sh + # user_data_var_file = { + # user_data_file = "../../openstack_vm_data_scripts/ubuntu2204.sh" + # } + smartgears_service_instances_map = { geoportal_service = { name = "geoportal-cms", description = "The Geoportal instance", flavor = "m1.medium", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"] - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + security_groups = ["default", "http and https from the load balancers"], + server_groups_ids = [openstack_compute_servergroup_v2.geoportal.id], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV } } } diff --git a/openstack-tf/d4s-dev/geoserver_new/main.tf b/openstack-tf/d4s-dev/geoserver_new/main.tf index 65d6a740..e24cd14d 100644 --- a/openstack-tf/d4s-dev/geoserver_new/main.tf +++ b/openstack-tf/d4s-dev/geoserver_new/main.tf @@ -33,7 +33,8 @@ module "geo_service" { flavor = "m1.xlarge", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-geona_data_volume", vol_data_size = "50" }, @@ -43,7 +44,8 @@ module "geo_service" { flavor = "m2.small", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-esquiline_data_volume", vol_data_size = "20" }, @@ -53,7 +55,8 @@ module "geo_service" { flavor = "m2.small", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-ariadne_data_volume", vol_data_size = "20" }, @@ -63,7 +66,8 @@ module "geo_service" { flavor = "m1.large", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-grsf_data_volume", vol_data_size = "40" }, @@ -73,7 +77,8 @@ module "geo_service" { flavor = "c1.large", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-protectedareaimpactmaps_data_volume", vol_data_size = "70" } @@ -83,7 +88,8 @@ module "geo_service" { flavor = "m1.large", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-sdi-lab_data_volume", vol_data_size = "100" } @@ -93,7 +99,8 @@ module "geo_service" { flavor = "m1.large", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-tunaatlas_data_volume", vol_data_size = "60" } @@ -103,7 +110,8 @@ module "geo_service" { flavor = "m1.large", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-wecafc-firms_data_volume", vol_data_size = "40" } @@ -113,7 +121,8 @@ module "geo_service" { flavor = "m1.large", networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], security_groups = ["default", "http and https from the load balancers"], - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + server_groups_ids = [], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV vol_data_name = "geoserver-aquacultureatlas_data_volume", vol_data_size = "50" } diff --git a/openstack-tf/d4s-dev/uri-resolver/main.tf b/openstack-tf/d4s-dev/uri-resolver/main.tf index ac1cd99c..414c97e1 100644 --- a/openstack-tf/d4s-dev/uri-resolver/main.tf +++ b/openstack-tf/d4s-dev/uri-resolver/main.tf @@ -17,18 +17,36 @@ data "terraform_remote_state" "privnet_dns_router" { } } +# +# Uses common_variables as module +# +module "common_variables" { + source = "../../modules/common_variables" +} + + +# +# Creates the server group "uri-resolver" +# +resource "openstack_compute_servergroup_v2" "uri-resolver" { + name = "uri-resolver" + policies = [module.common_variables.policy_list.soft_anti_affinity] +} + module "smartgears_service_generic" { source = "../../modules/generic_smartgears_service" smartgears_service_instances_map = { + # URI-Resolver instance 1 uri_resolver_service_i1 = { name = "data", description = "The data instance", flavor = "m1.medium", networks = ["d4s-dev-cloud-main"], - security_groups = ["default", "http and https from the load balancers"] - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + security_groups = ["default", "http and https from the load balancers"], + server_groups_ids = [openstack_compute_servergroup_v2.uri-resolver.id], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV }, # URI-Resolver instance 2 uri_resolver_service_i2 = { @@ -36,8 +54,9 @@ module "smartgears_service_generic" { description = "The data1 instance", flavor = "m1.medium", networks = ["d4s-dev-cloud-main"], - security_groups = ["default", "http and https from the load balancers"] - block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + security_groups = ["default", "http and https from the load balancers"], + server_groups_ids = [openstack_compute_servergroup_v2.uri-resolver.id], + image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV } } } diff --git a/openstack-tf/modules/common_variables/outputs.tf b/openstack-tf/modules/common_variables/outputs.tf index 3814d5a3..78120331 100644 --- a/openstack-tf/modules/common_variables/outputs.tf +++ b/openstack-tf/modules/common_variables/outputs.tf @@ -4,20 +4,20 @@ output "main_region" { } output "external_network" { - value = var.external_network + value = var.external_network } output "external_network_id" { - value = var.external_network.id + value = var.external_network.id } output "floating_ip_pools" { - value = var.floating_ip_pools - + value = var.floating_ip_pools + } output "resolvers_ip" { - value = var.resolvers_ip + value = var.resolvers_ip } output "mtu_size" { @@ -29,15 +29,15 @@ output "availability_zones_names" { } output "availability_zone_no_gpu_name" { - value = var.availability_zones_names.availability_zone_no_gpu + value = var.availability_zones_names.availability_zone_no_gpu } output "availability_zone_with_gpu_name" { - value = var.availability_zones_names.availability_zone_with_gpu + value = var.availability_zones_names.availability_zone_with_gpu } output "ssh_sources" { - value = var.ssh_sources + value = var.ssh_sources } output "networks_with_d4s_services" { @@ -55,16 +55,16 @@ output "networks_with_d4s_services" { # } output "dns_zone" { - value = var.dns_zone + value = var.dns_zone } output "dns_zone_id" { - value = var.dns_zone_id + value = var.dns_zone_id } output "main_private_network" { value = { - name = var.main_private_network.name - description = var.main_private_network.description + name = var.main_private_network.name + description = var.main_private_network.description } } @@ -77,7 +77,7 @@ output "main_private_subnet" { } output "main_private_subnet_id" { - value = var.main_private_subnet_id + value = var.main_private_subnet_id } output "external_router" { @@ -101,15 +101,15 @@ output "almalinux_9" { } output "ubuntu1804_data_file" { - value = var.ubuntu1804_data_file + value = var.ubuntu1804_data_file } output "ubuntu2204_data_file" { - value = var.ubuntu2204_data_file + value = var.ubuntu2204_data_file } output "el7_data_file" { - value = var.el7_data_file + value = var.el7_data_file } output "ssh_jump_proxy" { @@ -160,3 +160,7 @@ output "octavia_information" { value = var.octavia_information } +output "policy_list" { + value = var.policy_list +} + diff --git a/openstack-tf/modules/common_variables/variables.tf b/openstack-tf/modules/common_variables/variables.tf index 89ea6716..eadca814 100644 --- a/openstack-tf/modules/common_variables/variables.tf +++ b/openstack-tf/modules/common_variables/variables.tf @@ -354,14 +354,25 @@ variable "security_group_list" { } } +# Added by Francesco +variable "policy_list" { + type = map(string) + default = { + soft_anti_affinity = "soft-anti-affinity" + anti_affinity = "anti-affinity" + affinity = "affinity" + soft_affinity = "soft-affinity" + } +} + variable "networks_list" { type = map(string) default = { shared_postgresql = "postgresql-srv-net" - swarm = "swarm-nfs-net" - timescaledb = "timescaledb-net" - orientdb = "orientdb-net" - orientdb_se = "orientdb-se-net" + swarm = "swarm-nfs-net" + timescaledb = "timescaledb-net" + orientdb = "orientdb-net" + orientdb_se = "orientdb-se-net" } - -} \ No newline at end of file + +} diff --git a/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf b/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf index c04c39d2..6f486aa7 100644 --- a/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf +++ b/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf @@ -1,13 +1,15 @@ -# Generic smartgears_service instance +# Module used module "ssh_settings" { source = "../../modules/ssh-key-ref" } +# Module used module "common_variables" { source = "../../modules/common_variables" } +# Generic smartgears_service instance resource "openstack_compute_instance_v2" "smartgears_service" { for_each = var.smartgears_service_instances_map name = each.value.name @@ -16,7 +18,7 @@ resource "openstack_compute_instance_v2" "smartgears_service" { key_pair = module.ssh_settings.ssh_key_name security_groups = each.value.security_groups block_device { - uuid = each.value.block_device_uuid + uuid = each.value.image_uuid source_type = "image" volume_size = 10 boot_index = 0 @@ -24,6 +26,7 @@ resource "openstack_compute_instance_v2" "smartgears_service" { delete_on_termination = false } + # Creates the networks according to input networks dynamic "network" { for_each = each.value.networks content { @@ -31,5 +34,14 @@ resource "openstack_compute_instance_v2" "smartgears_service" { } } - user_data = file("${module.common_variables.ubuntu1804_data_file}") + # Creates the scheduler_hints (i.e. server groups) according to input server_groups_ids + dynamic "scheduler_hints" { + for_each = each.value.server_groups_ids + content { + group = scheduler_hints.value + } + } + + #user_data script used + user_data = file("${var.user_data_var_file.user_data_file}") #default is 18.04 } diff --git a/openstack-tf/modules/generic_smartgears_service/outputs.tf b/openstack-tf/modules/generic_smartgears_service/outputs.tf index 5c320ee3..0d2d4440 100644 --- a/openstack-tf/modules/generic_smartgears_service/outputs.tf +++ b/openstack-tf/modules/generic_smartgears_service/outputs.tf @@ -2,3 +2,7 @@ output "smartgears_service_instances_map" { value = var.smartgears_service_instances_map } + +output "user_data_var_file" { + value = var.user_data_var_file +} diff --git a/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf b/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf index dd761c85..8a892339 100644 --- a/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf +++ b/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf @@ -1,4 +1,11 @@ +variable "user_data_var_file" { + type = map(string) + default = { + user_data_file = "../../openstack_vm_data_scripts/ubuntu1804.sh" #default is 18.04 + } +} + #Default smartgears_service is EMPTY. Override it to create a proper smartegears plan variable "smartgears_service_instances_map" { type = map(object({ @@ -7,10 +14,11 @@ variable "smartgears_service_instances_map" { flavor = string networks = list(string) security_groups = list(string) - block_device_uuid = string + server_groups_ids = list(string) + image_uuid = string })) default = { - smartgears_service = { name = "", description = "", flavor = "", networks = [], security_groups = [], block_device_uuid = "" } + smartgears_service = { name = "", description = "", flavor = "", networks = [], security_groups = [], server_groups_ids = [], image_uuid = "" } } } diff --git a/openstack-tf/modules/geo_services/geo_service.tf b/openstack-tf/modules/geo_services/geo_service.tf index 63e22d6e..0c12dd10 100644 --- a/openstack-tf/modules/geo_services/geo_service.tf +++ b/openstack-tf/modules/geo_services/geo_service.tf @@ -22,19 +22,29 @@ resource "openstack_compute_instance_v2" "geo_service" { key_pair = module.ssh_settings.ssh_key_name security_groups = each.value.security_groups block_device { - uuid = each.value.block_device_uuid + uuid = each.value.image_uuid source_type = "image" volume_size = 10 boot_index = 0 destination_type = "volume" delete_on_termination = false } + + # Creates the networks according to input networks dynamic "network" { for_each = each.value.networks content { name = network.value } } + + # Creates the scheduler_hints (i.e. server groups) according to input server_groups_ids + dynamic "scheduler_hints" { + for_each = each.value.server_groups_ids + content { + group = scheduler_hints.value + } + } user_data = file("${var.user_data_var_file.user_data_file}") #default is 18.04 } diff --git a/openstack-tf/modules/geo_services/inputs.tf b/openstack-tf/modules/geo_services/inputs.tf index df294857..ddf17364 100644 --- a/openstack-tf/modules/geo_services/inputs.tf +++ b/openstack-tf/modules/geo_services/inputs.tf @@ -10,7 +10,7 @@ variable "geo_instance_basic_data" { variable "user_data_var_file" { type = map(string) default = { - user_data_file = "../../openstack_vm_data_scripts/ubuntu1804.sh" + user_data_file = "../../openstack_vm_data_scripts/ubuntu1804.sh" #default is 18.04 } } @@ -22,12 +22,13 @@ variable "geo_service_instances_map" { flavor = string networks = list(string) security_groups = list(string) - block_device_uuid = string + server_groups_ids = list(string) + image_uuid = string vol_data_name = string vol_data_size = string })) default = { - geoserver = { name = "", description = "", flavor = "", networks = [], security_groups = [], block_device_uuid = "", vol_data_name = "", vol_data_size = "" } + geoserver = { name = "", description = "", flavor = "", networks = [], security_groups = [], server_groups_ids = [], image_uuid = "", vol_data_name = "", vol_data_size = "" } } } From 74516812b3a778c9e2fc7b16cfac34a19b7e191c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 5 Dec 2023 11:22:22 +0100 Subject: [PATCH 2/2] Managed image_ref as map of string --- openstack-tf/d4s-dev/geoportal/main.tf | 13 +-- openstack-tf/d4s-dev/geoserver_new/main.tf | 86 ++++++++++--------- openstack-tf/d4s-dev/uri-resolver/main.tf | 17 ++-- .../modules/common_variables/outputs.tf | 17 ++++ .../modules/common_variables/variables.tf | 10 ++- .../.terraform.lock.hcl | 24 ++++++ .../generic_smartgears_service.tf | 4 +- .../generic_smartgears_service/outputs.tf | 4 - .../variables_generic_smartgears_service.tf | 11 +-- .../modules/geo_services/geo_service.tf | 4 +- openstack-tf/modules/geo_services/inputs.tf | 11 +-- openstack-tf/modules/geo_services/outputs.tf | 4 - 12 files changed, 112 insertions(+), 93 deletions(-) create mode 100644 openstack-tf/modules/generic_smartgears_service/.terraform.lock.hcl diff --git a/openstack-tf/d4s-dev/geoportal/main.tf b/openstack-tf/d4s-dev/geoportal/main.tf index c7ce5cd2..d355f0d6 100644 --- a/openstack-tf/d4s-dev/geoportal/main.tf +++ b/openstack-tf/d4s-dev/geoportal/main.tf @@ -41,20 +41,15 @@ resource "openstack_compute_servergroup_v2" "geoportal" { module "smartgears_service_generic" { source = "../../modules/generic_smartgears_service" - # Here, you can overwrite the openstack_vm_data_scripts to run for ubuntuXYZ.sh - # user_data_var_file = { - # user_data_file = "../../openstack_vm_data_scripts/ubuntu2204.sh" - # } - smartgears_service_instances_map = { geoportal_service = { name = "geoportal-cms", description = "The Geoportal instance", - flavor = "m1.medium", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_medium, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [openstack_compute_servergroup_v2.geoportal.id], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 } } } diff --git a/openstack-tf/d4s-dev/geoserver_new/main.tf b/openstack-tf/d4s-dev/geoserver_new/main.tf index e24cd14d..86531d43 100644 --- a/openstack-tf/d4s-dev/geoserver_new/main.tf +++ b/openstack-tf/d4s-dev/geoserver_new/main.tf @@ -17,112 +17,116 @@ data "terraform_remote_state" "privnet_dns_router" { } } + +# +# Uses common_variables as module +# +module "common_variables" { + source = "../../modules/common_variables" +} + + module "geo_service" { source = "../../modules/geo_services" - # Here, you can overwrite the openstack_vm_data_scripts to run for ubuntuXYZ.sh - # user_data_var_file = { - # user_data_file = "../../openstack_vm_data_scripts/ubuntu2204.sh" - # } - geo_service_instances_map = { geona = { name = "geoserver-geona", description = "Geoserver geona instance", - flavor = "m1.xlarge", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-geona_data_volume", vol_data_size = "50" }, esquiline = { name = "geoserver-esquiline", description = "Geoserver esquiline instance", - flavor = "m2.small", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m2_small, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-esquiline_data_volume", vol_data_size = "20" }, ariadne = { name = "geoserver-ariadne", description = "Geoserver ariadne instance", - flavor = "m2.small", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m2_small, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-ariadne_data_volume", vol_data_size = "20" }, grsf = { name = "geoserver-grsf", description = "Geoserver grsf instance", - flavor = "m1.large", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-grsf_data_volume", vol_data_size = "40" }, protectedareaimpactmaps = { name = "geoserver-protectedareaimpactmaps", description = "Geoserver protectedareaimpactmaps instance", - flavor = "c1.large", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.c1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-protectedareaimpactmaps_data_volume", vol_data_size = "70" } sdi-lab = { name = "geoserver-sdi-lab", description = "Geoserver sdi-lab instance", - flavor = "m1.large", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-sdi-lab_data_volume", vol_data_size = "100" } tunaatlas = { name = "geoserver-tunaatlas", description = "Geoserver tunaatlas instance", - flavor = "m1.large", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-tunaatlas_data_volume", vol_data_size = "60" } wecafc-firms = { name = "geoserver-wecafc-firms", description = "Geoserver wecafc-firms instance", - flavor = "m1.large", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-wecafc-firms_data_volume", vol_data_size = "40" } aquacultureatlas = { name = "geoserver-aquacultureatlas", description = "Geoserver aquacultureatlas instance", - flavor = "m1.large", - networks = ["d4s-dev-cloud-main", "postgresql-srv-net"], - security_groups = ["default", "http and https from the load balancers"], + flavor = module.common_variables.flavor_list.m1_large, + networks = ["d4s-dev-cloud-main", module.common_variables.networks_list.shared_postgresql], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 vol_data_name = "geoserver-aquacultureatlas_data_volume", vol_data_size = "50" } diff --git a/openstack-tf/d4s-dev/uri-resolver/main.tf b/openstack-tf/d4s-dev/uri-resolver/main.tf index 414c97e1..6a26c074 100644 --- a/openstack-tf/d4s-dev/uri-resolver/main.tf +++ b/openstack-tf/d4s-dev/uri-resolver/main.tf @@ -40,25 +40,24 @@ module "smartgears_service_generic" { smartgears_service_instances_map = { # URI-Resolver instance 1 uri_resolver_service_i1 = { - name = "data", + name = "data-1", description = "The data instance", - flavor = "m1.medium", + flavor = module.common_variables.flavor_list.m1_medium, networks = ["d4s-dev-cloud-main"], - security_groups = ["default", "http and https from the load balancers"], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [openstack_compute_servergroup_v2.uri-resolver.id], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 }, # URI-Resolver instance 2 uri_resolver_service_i2 = { - name = "data1", + name = "data-2", description = "The data1 instance", - flavor = "m1.medium", + flavor = module.common_variables.flavor_list.m1_medium, networks = ["d4s-dev-cloud-main"], - security_groups = ["default", "http and https from the load balancers"], + security_groups = [module.common_variables.security_group_list.default, module.common_variables.security_group_list.http_and_https_from_the_load_balancers], server_groups_ids = [openstack_compute_servergroup_v2.uri-resolver.id], - image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV + image_ref = module.common_variables.ubuntu_1804 } } } - diff --git a/openstack-tf/modules/common_variables/outputs.tf b/openstack-tf/modules/common_variables/outputs.tf index 78120331..d55e0196 100644 --- a/openstack-tf/modules/common_variables/outputs.tf +++ b/openstack-tf/modules/common_variables/outputs.tf @@ -160,7 +160,24 @@ output "octavia_information" { value = var.octavia_information } +#Added by Francesco output "policy_list" { value = var.policy_list } +#Added by Francesco +output "flavor_list" { + value = var.flavor_list +} + +#Added by Francesco +output "security_group_list" { + value = var.security_group_list +} + +#Added by Francesco +output "networks_list" { + value = var.networks_list +} + + diff --git a/openstack-tf/modules/common_variables/variables.tf b/openstack-tf/modules/common_variables/variables.tf index eadca814..348af37d 100644 --- a/openstack-tf/modules/common_variables/variables.tf +++ b/openstack-tf/modules/common_variables/variables.tf @@ -120,16 +120,18 @@ variable "ubuntu_1804" { type = map(string) default = { - name = "Ubuntu-Bionic-18.04" - uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" + name = "Ubuntu-Bionic-18.04" + uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" + user_data_file = "../../openstack_vm_data_scripts/ubuntu1804.sh" } } variable "ubuntu_2204" { type = map(string) default = { - name = "Ubuntu-Jammy-22.04" - uuid = "54768889-8556-4be4-a2eb-82a4d9b34627" + name = "Ubuntu-Jammy-22.04" + uuid = "54768889-8556-4be4-a2eb-82a4d9b34627" + user_data_file = "../../openstack_vm_data_scripts/ubuntu2204.sh" } } diff --git a/openstack-tf/modules/generic_smartgears_service/.terraform.lock.hcl b/openstack-tf/modules/generic_smartgears_service/.terraform.lock.hcl new file mode 100644 index 00000000..95c8b6a2 --- /dev/null +++ b/openstack-tf/modules/generic_smartgears_service/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/terraform-provider-openstack/openstack" { + version = "1.53.0" + constraints = "~> 1.53.0" + hashes = [ + "h1:YLGvYkSuagyP5orUTyKNK+JhzS17EFTUDpZ5R5/fFv4=", + "zh:09da7ca98ffd3de7b9ce36c4c13446212a6e763ba1162be71b50f95d453cb68e", + "zh:14041bcbb87312411d88612056ed185650bfd01284b8ea0761ce8105a331708e", + "zh:35bf4c788fdbc17c8e40ebc7b33c7de4b45a2fa2efaa657b10f0e3bd37c9627f", + "zh:46ede8ef4cfa12d654c538afc1e1ec34a1f3e8eb4e986ee23dceae398b7176a6", + "zh:59675734990dab1e8d87997853ea75e8104bba730b3f5a7146ac735540c9d6bf", + "zh:6de52428849806498670e827b54810be7510a2a79449602c1aede4235a0ec036", + "zh:78b2a20601272afceffac8f8ca78a6b647b84196c0dd8dc710fae297f6be15a4", + "zh:7c41ed3a4fac09677e676ecf9f9edd1e38eef449e656cb01a848d2c799c6de8f", + "zh:852800228f4118a4aa6cfaa4468b851247cbed6f037fd204f08de69eb1edc149", + "zh:86d618e7f9a07d978b8bc4b190be350a00de64ec535f9c8f5dfe133542a55483", + "zh:963a9e72b66d8bcf43de9b14a674ae3ca3719ce2f829217f7a65b66fc3773397", + "zh:a8e72ab67795071bda61f99a6de3d2d40122fb51971768fd75e1324abe874ced", + "zh:ce1890cf3af17d569af3bc7673cec0a8f78e6f5d701767593f3d29c551f44848", + "zh:e6f1b96eb684f527a47f71923f268c86a36d7894751b31ee9e726d7502a639cd", + ] +} diff --git a/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf b/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf index 6f486aa7..9e57e4f7 100644 --- a/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf +++ b/openstack-tf/modules/generic_smartgears_service/generic_smartgears_service.tf @@ -18,7 +18,7 @@ resource "openstack_compute_instance_v2" "smartgears_service" { key_pair = module.ssh_settings.ssh_key_name security_groups = each.value.security_groups block_device { - uuid = each.value.image_uuid + uuid = each.value.image_ref.uuid source_type = "image" volume_size = 10 boot_index = 0 @@ -43,5 +43,5 @@ resource "openstack_compute_instance_v2" "smartgears_service" { } #user_data script used - user_data = file("${var.user_data_var_file.user_data_file}") #default is 18.04 + user_data = file("${each.value.image_ref.user_data_file}") } diff --git a/openstack-tf/modules/generic_smartgears_service/outputs.tf b/openstack-tf/modules/generic_smartgears_service/outputs.tf index 0d2d4440..5c320ee3 100644 --- a/openstack-tf/modules/generic_smartgears_service/outputs.tf +++ b/openstack-tf/modules/generic_smartgears_service/outputs.tf @@ -2,7 +2,3 @@ output "smartgears_service_instances_map" { value = var.smartgears_service_instances_map } - -output "user_data_var_file" { - value = var.user_data_var_file -} diff --git a/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf b/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf index 8a892339..d6525f7a 100644 --- a/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf +++ b/openstack-tf/modules/generic_smartgears_service/variables_generic_smartgears_service.tf @@ -1,11 +1,4 @@ -variable "user_data_var_file" { - type = map(string) - default = { - user_data_file = "../../openstack_vm_data_scripts/ubuntu1804.sh" #default is 18.04 - } -} - #Default smartgears_service is EMPTY. Override it to create a proper smartegears plan variable "smartgears_service_instances_map" { type = map(object({ @@ -15,10 +8,10 @@ variable "smartgears_service_instances_map" { networks = list(string) security_groups = list(string) server_groups_ids = list(string) - image_uuid = string + image_ref = map(string) })) default = { - smartgears_service = { name = "", description = "", flavor = "", networks = [], security_groups = [], server_groups_ids = [], image_uuid = "" } + smartgears_service = { name = "", description = "", flavor = "", networks = [], security_groups = [], server_groups_ids = [], image_ref = {} } } } diff --git a/openstack-tf/modules/geo_services/geo_service.tf b/openstack-tf/modules/geo_services/geo_service.tf index 0c12dd10..4ae83cbe 100644 --- a/openstack-tf/modules/geo_services/geo_service.tf +++ b/openstack-tf/modules/geo_services/geo_service.tf @@ -22,7 +22,7 @@ resource "openstack_compute_instance_v2" "geo_service" { key_pair = module.ssh_settings.ssh_key_name security_groups = each.value.security_groups block_device { - uuid = each.value.image_uuid + uuid = each.value.image_ref.uuid source_type = "image" volume_size = 10 boot_index = 0 @@ -45,7 +45,7 @@ resource "openstack_compute_instance_v2" "geo_service" { group = scheduler_hints.value } } - user_data = file("${var.user_data_var_file.user_data_file}") #default is 18.04 + user_data = file("${each.value.image_ref.user_data_file}") } diff --git a/openstack-tf/modules/geo_services/inputs.tf b/openstack-tf/modules/geo_services/inputs.tf index ddf17364..c41bbffc 100644 --- a/openstack-tf/modules/geo_services/inputs.tf +++ b/openstack-tf/modules/geo_services/inputs.tf @@ -7,13 +7,6 @@ variable "geo_instance_basic_data" { } } -variable "user_data_var_file" { - type = map(string) - default = { - user_data_file = "../../openstack_vm_data_scripts/ubuntu1804.sh" #default is 18.04 - } -} - #Default geo_service_instances_map is EMPTY. Override it to create a proper geoserver plan variable "geo_service_instances_map" { type = map(object({ @@ -23,12 +16,12 @@ variable "geo_service_instances_map" { networks = list(string) security_groups = list(string) server_groups_ids = list(string) - image_uuid = string + image_ref = map(string) vol_data_name = string vol_data_size = string })) default = { - geoserver = { name = "", description = "", flavor = "", networks = [], security_groups = [], server_groups_ids = [], image_uuid = "", vol_data_name = "", vol_data_size = "" } + geoserver = { name = "", description = "", flavor = "", networks = [], security_groups = [], server_groups_ids = [], image_ref = {}, vol_data_name = "", vol_data_size = "" } } } diff --git a/openstack-tf/modules/geo_services/outputs.tf b/openstack-tf/modules/geo_services/outputs.tf index a030e922..7fa72bb4 100644 --- a/openstack-tf/modules/geo_services/outputs.tf +++ b/openstack-tf/modules/geo_services/outputs.tf @@ -6,8 +6,4 @@ output "geo_instance_basic_data" { value = var.geo_instance_basic_data } -output "user_data_var_file" { - value = var.user_data_var_file -} -