Migrated services to generic module

This commit is contained in:
Luca Frosini 2023-12-05 15:56:40 +01:00
parent 58991984a3
commit 2f676b6130
5 changed files with 72 additions and 42 deletions

View File

@ -17,26 +17,42 @@ data "terraform_remote_state" "privnet_dns_router" {
} }
} }
#
# Uses common_variables as module
#
module "common_variables" {
source = "../../modules/common_variables"
}
module "smartgears_service_generic" { #
source = "../../modules/generic_smartgears_service" # Creates the server group "accounting-service"
#
resource "openstack_compute_servergroup_v2" "accounting_service_server_group" {
name = "accounting-service"
policies = [module.common_variables.policy_list.soft_anti_affinity]
}
smartgears_service_instances_map = { module "instance_without_data_volume" {
source = "../../modules/instance_without_data_volume"
instances_without_data_volume_map = {
accounting_service_1 = { accounting_service_1 = {
name = "accounting-service-1", name = "accounting-service-1",
description = "This instance serves accounting service", description = "This instance serves accounting service",
flavor = "m1.medium", flavor = module.common_variables.flavor_list.m1_medium,
networks = ["d4s-dev-cloud-main", "timescaledb-net"], networks = ["d4s-dev-cloud-main", "timescaledb-net"],
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],
block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV server_groups_ids = [openstack_compute_servergroup_v2.accounting_service_server_group.id],
image_ref = module.common_variables.ubuntu_1804
}, },
accounting_service_2 = { accounting_service_2 = {
name = "accounting-service-2", name = "accounting-service-2",
description = "This instance serves accounting service", description = "This instance serves accounting service",
flavor = "m1.medium", flavor = module.common_variables.flavor_list.m1_medium,
networks = ["d4s-dev-cloud-main", "timescaledb-net"], networks = ["d4s-dev-cloud-main", "timescaledb-net"],
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],
block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV server_groups_ids = [openstack_compute_servergroup_v2.accounting_service_server_group.id],
image_ref = module.common_variables.ubuntu_1804
} }
} }
} }

View File

@ -34,10 +34,10 @@ resource "openstack_compute_servergroup_v2" "gcat_server_group" {
} }
module "smartgears_service_generic" { module "instance_without_data_volume" {
source = "../../modules/generic_smartgears_service" source = "../../modules/instance_without_data_volume"
smartgears_service_instances_map = { instances_without_data_volume_map = {
gcat_1 = { gcat_1 = {
name = "gcat-1", name = "gcat-1",
description = "This instance serves gcat service", description = "This instance serves gcat service",

View File

@ -1,7 +1,7 @@
{ {
"version": 4, "version": 4,
"terraform_version": "1.6.4", "terraform_version": "1.6.4",
"serial": 14, "serial": 19,
"lineage": "8a740e95-13ce-029b-b372-f1b423772e3f", "lineage": "8a740e95-13ce-029b-b372-f1b423772e3f",
"outputs": {}, "outputs": {},
"resources": [ "resources": [
@ -61,8 +61,8 @@
"attributes": { "attributes": {
"id": "f580e6ef-93ec-4926-b7fb-6db6fc7160a5", "id": "f580e6ef-93ec-4926-b7fb-6db6fc7160a5",
"members": [ "members": [
"3cdfe9a1-61c4-4c3e-8f8e-5af2fa2e6f3d", "60eb54dd-39c7-42d9-8231-f360492e9405",
"d92bed2c-cca3-4681-8a40-d01a639ff6f3" "4f58c353-0a5c-46a9-9ffb-19d70de366cb"
], ],
"name": "gcat", "name": "gcat",
"policies": [ "policies": [
@ -82,7 +82,7 @@
] ]
}, },
{ {
"module": "module.smartgears_service_generic", "module": "module.instance_without_data_volume",
"mode": "managed", "mode": "managed",
"type": "openstack_compute_instance_v2", "type": "openstack_compute_instance_v2",
"name": "smartgears_service", "name": "smartgears_service",
@ -92,7 +92,7 @@
"index_key": "gcat_1", "index_key": "gcat_1",
"schema_version": 0, "schema_version": 0,
"attributes": { "attributes": {
"access_ip_v4": "10.1.30.176", "access_ip_v4": "10.1.28.132",
"access_ip_v6": "", "access_ip_v6": "",
"admin_pass": null, "admin_pass": null,
"all_metadata": {}, "all_metadata": {},
@ -115,12 +115,12 @@
} }
], ],
"config_drive": null, "config_drive": null,
"created": "2023-12-05 11:41:32 +0000 UTC", "created": "2023-12-05 14:43:16 +0000 UTC",
"flavor_id": "4", "flavor_id": "4",
"flavor_name": "m1.medium", "flavor_name": "m1.medium",
"floating_ip": null, "floating_ip": null,
"force_delete": false, "force_delete": false,
"id": "60eb54dd-39c7-42d9-8231-f360492e9405", "id": "5d8ebe4f-b77b-4fbf-9991-ea402da3d98c",
"image_id": "Attempt to boot from volume - no image supplied", "image_id": "Attempt to boot from volume - no image supplied",
"image_name": null, "image_name": null,
"key_pair": "pc-frosini_key", "key_pair": "pc-frosini_key",
@ -129,10 +129,10 @@
"network": [ "network": [
{ {
"access_network": false, "access_network": false,
"fixed_ip_v4": "10.1.30.176", "fixed_ip_v4": "10.1.28.132",
"fixed_ip_v6": "", "fixed_ip_v6": "",
"floating_ip": "", "floating_ip": "",
"mac": "fa:16:3e:31:89:35", "mac": "fa:16:3e:73:dd:c3",
"name": "d4s-dev-cloud-main", "name": "d4s-dev-cloud-main",
"port": "", "port": "",
"uuid": "e0af5eba-f24a-4d0d-8184-bc654b980c4a" "uuid": "e0af5eba-f24a-4d0d-8184-bc654b980c4a"
@ -161,7 +161,7 @@
"stop_before_destroy": false, "stop_before_destroy": false,
"tags": null, "tags": null,
"timeouts": null, "timeouts": null,
"updated": "2023-12-05 11:42:04 +0000 UTC", "updated": "2023-12-05 14:43:49 +0000 UTC",
"user_data": "ef3d6e5deb29bd1e5de5a76ae6860f3ee872738c", "user_data": "ef3d6e5deb29bd1e5de5a76ae6860f3ee872738c",
"vendor_options": [], "vendor_options": [],
"volume": [] "volume": []
@ -176,7 +176,7 @@
"index_key": "gcat_2", "index_key": "gcat_2",
"schema_version": 0, "schema_version": 0,
"attributes": { "attributes": {
"access_ip_v4": "10.1.28.116", "access_ip_v4": "10.1.28.210",
"access_ip_v6": "", "access_ip_v6": "",
"admin_pass": null, "admin_pass": null,
"all_metadata": {}, "all_metadata": {},
@ -199,12 +199,12 @@
} }
], ],
"config_drive": null, "config_drive": null,
"created": "2023-12-05 11:41:31 +0000 UTC", "created": "2023-12-05 14:43:15 +0000 UTC",
"flavor_id": "4", "flavor_id": "4",
"flavor_name": "m1.medium", "flavor_name": "m1.medium",
"floating_ip": null, "floating_ip": null,
"force_delete": false, "force_delete": false,
"id": "4f58c353-0a5c-46a9-9ffb-19d70de366cb", "id": "91fe0237-c8ba-4396-ba8e-b66d33aeeffa",
"image_id": "Attempt to boot from volume - no image supplied", "image_id": "Attempt to boot from volume - no image supplied",
"image_name": null, "image_name": null,
"key_pair": "pc-frosini_key", "key_pair": "pc-frosini_key",
@ -213,10 +213,10 @@
"network": [ "network": [
{ {
"access_network": false, "access_network": false,
"fixed_ip_v4": "10.1.28.116", "fixed_ip_v4": "10.1.28.210",
"fixed_ip_v6": "", "fixed_ip_v6": "",
"floating_ip": "", "floating_ip": "",
"mac": "fa:16:3e:a0:2f:e6", "mac": "fa:16:3e:9d:22:fd",
"name": "d4s-dev-cloud-main", "name": "d4s-dev-cloud-main",
"port": "", "port": "",
"uuid": "e0af5eba-f24a-4d0d-8184-bc654b980c4a" "uuid": "e0af5eba-f24a-4d0d-8184-bc654b980c4a"
@ -245,7 +245,7 @@
"stop_before_destroy": false, "stop_before_destroy": false,
"tags": null, "tags": null,
"timeouts": null, "timeouts": null,
"updated": "2023-12-05 11:42:08 +0000 UTC", "updated": "2023-12-05 14:43:53 +0000 UTC",
"user_data": "ef3d6e5deb29bd1e5de5a76ae6860f3ee872738c", "user_data": "ef3d6e5deb29bd1e5de5a76ae6860f3ee872738c",
"vendor_options": [], "vendor_options": [],
"volume": [] "volume": []

View File

@ -17,26 +17,42 @@ data "terraform_remote_state" "privnet_dns_router" {
} }
} }
#
# Uses common_variables as module
#
module "common_variables" {
source = "../../modules/common_variables"
}
module "smartgears_service_generic" { #
source = "../../modules/generic_smartgears_service" # Creates the server group "grsf-publisher"
#
resource "openstack_compute_servergroup_v2" "grsf_publisher_server_group" {
name = "grsf-publisher"
policies = [module.common_variables.policy_list.soft_anti_affinity]
}
smartgears_service_instances_map = { module "instance_without_data_volume" {
source = "../../modules/instance_without_data_volume"
instances_without_data_volume_map = {
grsf_publisher_1 = { grsf_publisher_1 = {
name = "grsf-publisher-1", name = "grsf-publisher-1",
description = "This instance serves GRSF Publisher service", description = "This instance serves GRSF Publisher service",
flavor = "m1.medium", flavor = module.common_variables.flavor_list.m1_medium,
networks = ["d4s-dev-cloud-main"], 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],
block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV server_groups_ids = [openstack_compute_servergroup_v2.grsf_publisher_server_group.id],
image_ref = module.common_variables.ubuntu_1804
}, },
grsf_publisher_2 = { grsf_publisher_2 = {
name = "grsf-publisher-2", name = "grsf-publisher-2",
description = "This instance serves GRSF Publisher service", description = "This instance serves GRSF Publisher service",
flavor = "m1.medium", flavor = module.common_variables.flavor_list.m1_medium,
networks = ["d4s-dev-cloud-main"], 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],
block_device_uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89" #ubuntu_18_04.uuid of DEV server_groups_ids = [openstack_compute_servergroup_v2.grsf_publisher_server_group.id],
image_ref = module.common_variables.ubuntu_1804
} }
} }
} }

View File

@ -24,7 +24,6 @@ module "common_variables" {
source = "../../modules/common_variables" source = "../../modules/common_variables"
} }
# #
# Creates the server group "resource-registry" # Creates the server group "resource-registry"
# #
@ -33,11 +32,10 @@ resource "openstack_compute_servergroup_v2" "resource_registry_server_group" {
policies = [module.common_variables.policy_list.soft_anti_affinity] policies = [module.common_variables.policy_list.soft_anti_affinity]
} }
module "instance_without_data_volume" {
source = "../../modules/instance_without_data_volume"
module "smartgears_service_generic" { instances_without_data_volume_map = {
source = "../../modules/generic_smartgears_service"
smartgears_service_instances_map = {
resource_registry_1 = { resource_registry_1 = {
name = "resource-registry-1", name = "resource-registry-1",
description = "This instance serves resource-registry service", description = "This instance serves resource-registry service",