Merge pull request 'main' (#3) from francesco.mangiacrapa/infrastructure-as-code:main into main
Reviewed-on: #3
This commit is contained in:
commit
90a9ed4f95
|
@ -1 +0,0 @@
|
|||
../../modules/geoserver/variables-geoserver.tf
|
|
@ -0,0 +1,30 @@
|
|||
#Default geoserver vol_data_device
|
||||
variable "geoserver_basic_data" {
|
||||
type = map(string)
|
||||
default = {
|
||||
vol_data_device = "/dev/vdb"
|
||||
}
|
||||
}
|
||||
|
||||
#Geoserver instances Map
|
||||
variable "geoserver_instances_map" {
|
||||
type = map(object({
|
||||
name = string
|
||||
description = string
|
||||
flavor = string
|
||||
vol_data_name = string
|
||||
vol_data_size = string
|
||||
}))
|
||||
default = {
|
||||
geona = { name = "geoserver-geona", description = "Geoserver geona instance", flavor = "m1.xlarge", vol_data_name = "geoserver-geona_data_volume", vol_data_size = "50" }
|
||||
esquiline = { name = "geoserver-esquiline", description = "Geoserver esquiline instance", flavor = "m2.small", vol_data_name = "geoserver-esquiline_data_volume", vol_data_size = "20" }
|
||||
ariadne = { name = "geoserver-ariadne", description = "Geoserver ariadne instance", flavor = "m2.small", vol_data_name = "geoserver-ariadne_data_volume", vol_data_size = "20" }
|
||||
grsf = { name = "geoserver-grsf", description = "Geoserver grsf instance", flavor = "m1.large", vol_data_name = "geoserver-grsf_data_volume", vol_data_size = "40" }
|
||||
protectedareaimpactmaps = { name = "geoserver-protectedareaimpactmaps", description = "Geoserver protectedareaimpactmaps instance", flavor = "c1.large", 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", vol_data_name = "geoserver-sdi-lab_data_volume", vol_data_size = "100" }
|
||||
tunaatlas = { name = "geoserver-tunaatlas", description = "Geoserver tunaatlas instance", flavor = "m1.large", 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", vol_data_name = "geoserver-wecafc-firms_data_volume", vol_data_size = "40" }
|
||||
aquacultureatlas = { name = "geoserver-aquacultureatlas", description = "Geoserver aquacultureatlas instance", flavor = "m1.large", vol_data_name = "geoserver-aquacultureatlas_data_volume", vol_data_size = "50" }
|
||||
}
|
||||
|
||||
}
|
|
@ -205,3 +205,19 @@ variable "smartexecutor_addresses" {
|
|||
module "ssh_settings" {
|
||||
source = "../../modules/ssh-key-ref"
|
||||
}
|
||||
|
||||
# Added by Francesco
|
||||
variable "flavor_list" {
|
||||
type = map(string)
|
||||
default = {
|
||||
c1_small = "c1.small" #RAM 2 - VCPUs 2
|
||||
c1_medium = "c1.medium" #RAM 4 - VCPUs 4
|
||||
c1_large = "c1.large" #RAM 8 - VCPUs 8
|
||||
m1_medium = "m1.medium" #RAM 4 - VCPUs 2
|
||||
m1_large = "m1.large" #RAM 8 - VCPUs 4
|
||||
m1_xlarge = "m1.xlarge" #RAM 16 - VCPUs 8
|
||||
m2_small = "m2.small" #RAM 8 - VCPUs 2
|
||||
m2_medium = "m2.medium" #RAM 16 - VCPUs 4
|
||||
m2_large = "m2.large" #RAM 32 - VCPUs 8
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,74 @@
|
|||
# Creates single geoserver instance
|
||||
|
||||
# # Geoserver attached volume - used for 'geoserver_data'
|
||||
# resource "openstack_blockstorage_volume_v3" "geoserver_data_vol" {
|
||||
# name = var.geoserver_basic_data.vol_data_name
|
||||
# size = var.geoserver_basic_data.vol_data_size
|
||||
# }
|
||||
|
||||
# # Geoserver instance
|
||||
# resource "openstack_compute_instance_v2" "geoserver" {
|
||||
# name = var.geoserver_basic.name
|
||||
# availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
|
||||
# flavor_name = var.geoserver_basic.flavor
|
||||
# key_pair = module.ssh_settings.ssh_key_name
|
||||
# security_groups = [var.security_group_list.default, var.security_group_list.http_and_https_from_the_load_balancers]
|
||||
# block_device {
|
||||
# uuid = var.ubuntu_1804.uuid
|
||||
# source_type = "image"
|
||||
# volume_size = 10
|
||||
# boot_index = 0
|
||||
# destination_type = "volume"
|
||||
# delete_on_termination = false
|
||||
# }
|
||||
# network {
|
||||
# name = var.main_private_network.name
|
||||
# }
|
||||
# network {
|
||||
# name = var.shared_postgresql_server_data.network_name
|
||||
# }
|
||||
# user_data = file("${var.ubuntu1804_data_file}")
|
||||
# }
|
||||
|
||||
|
||||
# # Attach the additional volume
|
||||
# resource "openstack_compute_volume_attach_v2" "geoserver_data_attach_vol" {
|
||||
# instance_id = openstack_compute_instance_v2.geoserver.id
|
||||
# volume_id = openstack_blockstorage_volume_v3.geoserver_data_vol.id
|
||||
# device = var.geoserver_basic_data.vol_data_device
|
||||
# depends_on = [openstack_compute_instance_v2.geoserver]
|
||||
# }
|
||||
|
||||
|
||||
# Creates all the geoserver instances with volumes declared in the var.geoserver_instances_map
|
||||
|
||||
# variable "geoserver_instances" {
|
||||
# type = map(object({
|
||||
# name = string
|
||||
# description = string
|
||||
# flavor = string
|
||||
# vol_data_name = string
|
||||
# vol_data_size = string
|
||||
# }))
|
||||
# default = {
|
||||
# geoserver = { name = "", description = "", flavor = "", vol_data_name = "", vol_data_size = "" }
|
||||
# }
|
||||
|
||||
# }
|
||||
|
||||
# Geoserver attached volume - used for 'geoserver_data'
|
||||
resource "openstack_blockstorage_volume_v3" "geoserver_data_vol" {
|
||||
name = var.geoserver_basic_data.vol_data_name
|
||||
size = var.geoserver_basic_data.vol_data_size
|
||||
resource "openstack_blockstorage_volume_v3" "geoserver_data_volume" {
|
||||
for_each = var.geoserver_instances_map
|
||||
name = each.value.vol_data_name
|
||||
size = each.value.vol_data_size
|
||||
}
|
||||
|
||||
# Geoserver instance
|
||||
resource "openstack_compute_instance_v2" "geoserver" {
|
||||
name = var.geoserver_basic.name
|
||||
for_each = var.geoserver_instances_map
|
||||
name = each.value.name
|
||||
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
|
||||
flavor_name = var.geoserver_basic.flavor
|
||||
flavor_name = each.value.flavor
|
||||
key_pair = module.ssh_settings.ssh_key_name
|
||||
security_groups = [var.security_group_list.default, var.security_group_list.http_and_https_from_the_load_balancers]
|
||||
block_device {
|
||||
|
@ -32,8 +91,9 @@ resource "openstack_compute_instance_v2" "geoserver" {
|
|||
|
||||
# Attach the additional volume
|
||||
resource "openstack_compute_volume_attach_v2" "geoserver_data_attach_vol" {
|
||||
instance_id = openstack_compute_instance_v2.geoserver.id
|
||||
volume_id = openstack_blockstorage_volume_v3.geoserver_data_vol.id
|
||||
for_each = var.geoserver_instances_map
|
||||
instance_id = openstack_compute_instance_v2.geoserver[each.key].id
|
||||
volume_id = openstack_blockstorage_volume_v3.geoserver_data_volume[each.key].id
|
||||
device = var.geoserver_basic_data.vol_data_device
|
||||
depends_on = [openstack_compute_instance_v2.geoserver]
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#Not used
|
||||
variable "geoserver_basic" {
|
||||
type = map(string)
|
||||
default = {
|
||||
|
@ -7,11 +8,25 @@ variable "geoserver_basic" {
|
|||
}
|
||||
}
|
||||
|
||||
#Default geoserver vol_data_device
|
||||
variable "geoserver_basic_data" {
|
||||
type = map(string)
|
||||
default = {
|
||||
vol_data_name = "geoserver_data_volume"
|
||||
vol_data_size = "20"
|
||||
vol_data_device = "/dev/vdb"
|
||||
}
|
||||
}
|
||||
|
||||
#Default geoserver_instances_map is EMPTY. Override it to create a proper geoserver plan
|
||||
variable "geoserver_instances_map" {
|
||||
type = map(object({
|
||||
name = string
|
||||
description = string
|
||||
flavor = string
|
||||
vol_data_name = string
|
||||
vol_data_size = string
|
||||
}))
|
||||
default = {
|
||||
geoserver = { name = "", description = "", flavor = "", vol_data_name = "", vol_data_size = "" }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue