Added server_groups_ids as input paramater and managed it
This commit is contained in:
parent
a08f44ee5b
commit
37ad816a69
|
@ -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" {
|
module "smartgears_service_generic" {
|
||||||
source = "../../modules/generic_smartgears_service"
|
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 = {
|
smartgears_service_instances_map = {
|
||||||
geoportal_service = {
|
geoportal_service = {
|
||||||
name = "geoportal-cms",
|
name = "geoportal-cms",
|
||||||
description = "The Geoportal instance",
|
description = "The Geoportal instance",
|
||||||
flavor = "m1.medium",
|
flavor = "m1.medium",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"]
|
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 = [openstack_compute_servergroup_v2.geoportal.id],
|
||||||
|
image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ module "geo_service" {
|
||||||
flavor = "m1.xlarge",
|
flavor = "m1.xlarge",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-geona_data_volume",
|
||||||
vol_data_size = "50"
|
vol_data_size = "50"
|
||||||
},
|
},
|
||||||
|
@ -43,7 +44,8 @@ module "geo_service" {
|
||||||
flavor = "m2.small",
|
flavor = "m2.small",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-esquiline_data_volume",
|
||||||
vol_data_size = "20"
|
vol_data_size = "20"
|
||||||
},
|
},
|
||||||
|
@ -53,7 +55,8 @@ module "geo_service" {
|
||||||
flavor = "m2.small",
|
flavor = "m2.small",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-ariadne_data_volume",
|
||||||
vol_data_size = "20"
|
vol_data_size = "20"
|
||||||
},
|
},
|
||||||
|
@ -63,7 +66,8 @@ module "geo_service" {
|
||||||
flavor = "m1.large",
|
flavor = "m1.large",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-grsf_data_volume",
|
||||||
vol_data_size = "40"
|
vol_data_size = "40"
|
||||||
},
|
},
|
||||||
|
@ -73,7 +77,8 @@ module "geo_service" {
|
||||||
flavor = "c1.large",
|
flavor = "c1.large",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-protectedareaimpactmaps_data_volume",
|
||||||
vol_data_size = "70"
|
vol_data_size = "70"
|
||||||
}
|
}
|
||||||
|
@ -83,7 +88,8 @@ module "geo_service" {
|
||||||
flavor = "m1.large",
|
flavor = "m1.large",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-sdi-lab_data_volume",
|
||||||
vol_data_size = "100"
|
vol_data_size = "100"
|
||||||
}
|
}
|
||||||
|
@ -93,7 +99,8 @@ module "geo_service" {
|
||||||
flavor = "m1.large",
|
flavor = "m1.large",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-tunaatlas_data_volume",
|
||||||
vol_data_size = "60"
|
vol_data_size = "60"
|
||||||
}
|
}
|
||||||
|
@ -103,7 +110,8 @@ module "geo_service" {
|
||||||
flavor = "m1.large",
|
flavor = "m1.large",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-wecafc-firms_data_volume",
|
||||||
vol_data_size = "40"
|
vol_data_size = "40"
|
||||||
}
|
}
|
||||||
|
@ -113,7 +121,8 @@ module "geo_service" {
|
||||||
flavor = "m1.large",
|
flavor = "m1.large",
|
||||||
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
networks = ["d4s-dev-cloud-main", "postgresql-srv-net"],
|
||||||
security_groups = ["default", "http and https from the load balancers"],
|
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_name = "geoserver-aquacultureatlas_data_volume",
|
||||||
vol_data_size = "50"
|
vol_data_size = "50"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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" {
|
module "smartgears_service_generic" {
|
||||||
source = "../../modules/generic_smartgears_service"
|
source = "../../modules/generic_smartgears_service"
|
||||||
|
|
||||||
smartgears_service_instances_map = {
|
smartgears_service_instances_map = {
|
||||||
|
# URI-Resolver instance 1
|
||||||
uri_resolver_service_i1 = {
|
uri_resolver_service_i1 = {
|
||||||
name = "data",
|
name = "data",
|
||||||
description = "The data instance",
|
description = "The data instance",
|
||||||
flavor = "m1.medium",
|
flavor = "m1.medium",
|
||||||
networks = ["d4s-dev-cloud-main"],
|
networks = ["d4s-dev-cloud-main"],
|
||||||
security_groups = ["default", "http and https from the load balancers"]
|
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 = [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 instance 2
|
||||||
uri_resolver_service_i2 = {
|
uri_resolver_service_i2 = {
|
||||||
|
@ -36,8 +54,9 @@ module "smartgears_service_generic" {
|
||||||
description = "The data1 instance",
|
description = "The data1 instance",
|
||||||
flavor = "m1.medium",
|
flavor = "m1.medium",
|
||||||
networks = ["d4s-dev-cloud-main"],
|
networks = ["d4s-dev-cloud-main"],
|
||||||
security_groups = ["default", "http and https from the load balancers"]
|
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 = [openstack_compute_servergroup_v2.uri-resolver.id],
|
||||||
|
image_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,3 +160,7 @@ output "octavia_information" {
|
||||||
value = var.octavia_information
|
value = var.octavia_information
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "policy_list" {
|
||||||
|
value = var.policy_list
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,6 +354,17 @@ 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" {
|
variable "networks_list" {
|
||||||
type = map(string)
|
type = map(string)
|
||||||
default = {
|
default = {
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
# Generic smartgears_service instance
|
|
||||||
|
|
||||||
|
# Module used
|
||||||
module "ssh_settings" {
|
module "ssh_settings" {
|
||||||
source = "../../modules/ssh-key-ref"
|
source = "../../modules/ssh-key-ref"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Module used
|
||||||
module "common_variables" {
|
module "common_variables" {
|
||||||
source = "../../modules/common_variables"
|
source = "../../modules/common_variables"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generic smartgears_service instance
|
||||||
resource "openstack_compute_instance_v2" "smartgears_service" {
|
resource "openstack_compute_instance_v2" "smartgears_service" {
|
||||||
for_each = var.smartgears_service_instances_map
|
for_each = var.smartgears_service_instances_map
|
||||||
name = each.value.name
|
name = each.value.name
|
||||||
|
@ -16,7 +18,7 @@ resource "openstack_compute_instance_v2" "smartgears_service" {
|
||||||
key_pair = module.ssh_settings.ssh_key_name
|
key_pair = module.ssh_settings.ssh_key_name
|
||||||
security_groups = each.value.security_groups
|
security_groups = each.value.security_groups
|
||||||
block_device {
|
block_device {
|
||||||
uuid = each.value.block_device_uuid
|
uuid = each.value.image_uuid
|
||||||
source_type = "image"
|
source_type = "image"
|
||||||
volume_size = 10
|
volume_size = 10
|
||||||
boot_index = 0
|
boot_index = 0
|
||||||
|
@ -24,6 +26,7 @@ resource "openstack_compute_instance_v2" "smartgears_service" {
|
||||||
delete_on_termination = false
|
delete_on_termination = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Creates the networks according to input networks
|
||||||
dynamic "network" {
|
dynamic "network" {
|
||||||
for_each = each.value.networks
|
for_each = each.value.networks
|
||||||
content {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
output "smartgears_service_instances_map" {
|
output "smartgears_service_instances_map" {
|
||||||
value = var.smartgears_service_instances_map
|
value = var.smartgears_service_instances_map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "user_data_var_file" {
|
||||||
|
value = var.user_data_var_file
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
#Default smartgears_service is EMPTY. Override it to create a proper smartegears plan
|
||||||
variable "smartgears_service_instances_map" {
|
variable "smartgears_service_instances_map" {
|
||||||
type = map(object({
|
type = map(object({
|
||||||
|
@ -7,10 +14,11 @@ variable "smartgears_service_instances_map" {
|
||||||
flavor = string
|
flavor = string
|
||||||
networks = list(string)
|
networks = list(string)
|
||||||
security_groups = list(string)
|
security_groups = list(string)
|
||||||
block_device_uuid = string
|
server_groups_ids = list(string)
|
||||||
|
image_uuid = string
|
||||||
}))
|
}))
|
||||||
default = {
|
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 = "" }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,29 @@ resource "openstack_compute_instance_v2" "geo_service" {
|
||||||
key_pair = module.ssh_settings.ssh_key_name
|
key_pair = module.ssh_settings.ssh_key_name
|
||||||
security_groups = each.value.security_groups
|
security_groups = each.value.security_groups
|
||||||
block_device {
|
block_device {
|
||||||
uuid = each.value.block_device_uuid
|
uuid = each.value.image_uuid
|
||||||
source_type = "image"
|
source_type = "image"
|
||||||
volume_size = 10
|
volume_size = 10
|
||||||
boot_index = 0
|
boot_index = 0
|
||||||
destination_type = "volume"
|
destination_type = "volume"
|
||||||
delete_on_termination = false
|
delete_on_termination = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Creates the networks according to input networks
|
||||||
dynamic "network" {
|
dynamic "network" {
|
||||||
for_each = each.value.networks
|
for_each = each.value.networks
|
||||||
content {
|
content {
|
||||||
name = network.value
|
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
|
user_data = file("${var.user_data_var_file.user_data_file}") #default is 18.04
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ variable "geo_instance_basic_data" {
|
||||||
variable "user_data_var_file" {
|
variable "user_data_var_file" {
|
||||||
type = map(string)
|
type = map(string)
|
||||||
default = {
|
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
|
flavor = string
|
||||||
networks = list(string)
|
networks = list(string)
|
||||||
security_groups = list(string)
|
security_groups = list(string)
|
||||||
block_device_uuid = string
|
server_groups_ids = list(string)
|
||||||
|
image_uuid = string
|
||||||
vol_data_name = string
|
vol_data_name = string
|
||||||
vol_data_size = string
|
vol_data_size = string
|
||||||
}))
|
}))
|
||||||
default = {
|
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 = "" }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue