Fixes to the orientdb module.

This commit is contained in:
Andrea Dell'Amico 2023-12-13 18:08:24 +01:00
parent fe5fcfeb37
commit 5548041553
Signed by untrusted user: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
5 changed files with 59 additions and 24 deletions

View File

@ -2,7 +2,7 @@
#
resource "openstack_compute_servergroup_v2" "orientdb_cluster" {
name = "orientdb_cluster"
policies = ["soft-anti-affinity"]
policies = [var.orientdb_affinity_policy]
}
#
# Network for the cluster traffic
@ -12,10 +12,10 @@ resource "openstack_networking_network_v2" "orientdb_network" {
admin_state_up = "true"
external = "false"
description = var.orientdb_net.network_description
mtu = var.mtu_size
mtu = module.common_variables.mtu_size
port_security_enabled = true
shared = false
region = var.main_region
region = module.common_variables.main_region
}
# Subnet
@ -24,7 +24,7 @@ resource "openstack_networking_subnet_v2" "orientdb_subnet" {
description = "Subnet used by the OrientDB service"
network_id = openstack_networking_network_v2.orientdb_network.id
cidr = var.orientdb_net.network_cidr
dns_nameservers = var.resolvers_ip
dns_nameservers = module.common_variables.resolvers_ip
ip_version = 4
enable_dhcp = true
no_gateway = true
@ -42,10 +42,10 @@ resource "openstack_networking_network_v2" "orientdb_se_network" {
admin_state_up = "true"
external = "false"
description = var.orientdb_se_net.network_description
mtu = var.mtu_size
mtu = module.common_variables.mtu_size
port_security_enabled = true
shared = false
region = var.main_region
region = module.common_variables.main_region
}
# Subnet
@ -54,7 +54,7 @@ resource "openstack_networking_subnet_v2" "orientdb_se_subnet" {
description = "Subnet used by the OrientDB for Smart Executor"
network_id = openstack_networking_network_v2.orientdb_se_network.id
cidr = var.orientdb_se_net.network_cidr
dns_nameservers = var.resolvers_ip
dns_nameservers = module.common_variables.resolvers_ip
ip_version = 4
enable_dhcp = true
no_gateway = true
@ -70,7 +70,7 @@ resource "openstack_networking_subnet_v2" "orientdb_se_subnet" {
# Main OrientDB service
# Between OrientDB nodes
resource "openstack_networking_secgroup_v2" "orientdb_internal_traffic" {
name = "orientdb_internal_docker_traffic"
name = "orientdb_internal_traffic"
delete_default_rules = "true"
description = "Traffic between the OrientDB nodes"
}
@ -93,7 +93,7 @@ resource "openstack_networking_secgroup_v2" "access_to_orientdb" {
description = "Clients that talk to the OrientDB service"
}
resource "openstack_networking_secgroup_rule_v2" "access_to_orient_from_clients" {
for_each = toset([var.basic_services_ip.ssh_jump_cidr, openstack_networking_subnet_v2.orientdb_subnet.cidr])
for_each = toset([data.terraform_remote_state.privnet_dns_router.outputs.basic_services_ip.ssh_jump_cidr, openstack_networking_subnet_v2.orientdb_subnet.cidr])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb.id
description = "TCP traffic from the resource registries and the SSH jump server"
port_range_min = 2424
@ -104,7 +104,7 @@ resource "openstack_networking_secgroup_rule_v2" "access_to_orient_from_clients"
remote_ip_prefix = each.value
}
resource "openstack_networking_secgroup_rule_v2" "access_to_orient_from_haproxy" {
for_each = toset( [var.basic_services_ip.haproxy_l7_1_cidr, var.basic_services_ip.haproxy_l7_2_cidr])
for_each = toset( [data.terraform_remote_state.privnet_dns_router.outputs.basic_services_ip.haproxy_l7_1_cidr, data.terraform_remote_state.privnet_dns_router.outputs.basic_services_ip.haproxy_l7_2_cidr])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb.id
description = "TCP traffic from the load balancers"
port_range_min = 2480
@ -123,7 +123,7 @@ resource "openstack_networking_secgroup_v2" "access_to_orientdb_se" {
description = "Clients that talk to the OrientDB SE service"
}
resource "openstack_networking_secgroup_rule_v2" "access_to_orient_se_from_clients" {
for_each = toset([var.basic_services_ip.ssh_jump_cidr, openstack_networking_subnet_v2.orientdb_se_subnet.cidr])
for_each = toset([data.terraform_remote_state.privnet_dns_router.outputs.basic_services_ip.ssh_jump_cidr, openstack_networking_subnet_v2.orientdb_se_subnet.cidr])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb_se.id
description = "TCP traffic from the smart executors and the SSH jump server"
port_range_min = 2424
@ -134,7 +134,7 @@ resource "openstack_networking_secgroup_rule_v2" "access_to_orient_se_from_clien
remote_ip_prefix = each.value
}
resource "openstack_networking_secgroup_rule_v2" "access_to_orient_se_from_haproxy" {
for_each = toset( [var.basic_services_ip.haproxy_l7_1_cidr, var.basic_services_ip.haproxy_l7_2_cidr])
for_each = toset( [data.terraform_remote_state.privnet_dns_router.outputs.basic_services_ip.haproxy_l7_1_cidr, data.terraform_remote_state.privnet_dns_router.outputs.basic_services_ip.haproxy_l7_2_cidr])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb_se.id
description = "TCP traffic from the load balancers"
port_range_min = 2480
@ -152,15 +152,16 @@ resource "openstack_networking_secgroup_rule_v2" "access_to_orient_se_from_hapro
resource "openstack_compute_instance_v2" "orientdb_servers" {
count = var.orientdb_nodes_count
name = format("%s-%02d", var.orientdb_data.node_name, count.index+1)
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
availability_zone_hints = module.common_variables.availability_zones_names.availability_zone_no_gpu
image_name = var.orientdb_image_name
flavor_name = var.orientdb_node_flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.orientdb_internal_traffic.name,openstack_networking_secgroup_v2.access_to_orientdb.name]
security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name,openstack_networking_secgroup_v2.orientdb_internal_traffic.name,openstack_networking_secgroup_v2.access_to_orientdb.name]
scheduler_hints {
group = openstack_compute_servergroup_v2.orientdb_cluster.id
}
block_device {
uuid = var.ubuntu_2204.uuid
uuid = var.orientdb_image_uuid
source_type = "image"
volume_size = 10
boot_index = 0
@ -177,26 +178,27 @@ resource "openstack_compute_instance_v2" "orientdb_servers" {
}
network {
name = var.main_private_network.name
name = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name
}
network {
name = var.orientdb_net.network_name
fixed_ip_v4 = var.orientdb_ip.*[count.index]
}
user_data = "${file("${var.ubuntu2204_data_file}")}"
user_data = "${file("${module.common_variables.ubuntu_2204.user_data_file}")}"
depends_on = [ openstack_networking_subnet_v2.orientdb_subnet ]
}
# Instance used by the smart executors
resource "openstack_compute_instance_v2" "orientdb_se_server" {
name = "orientdb-se"
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
availability_zone_hints = module.common_variables.availability_zones_names.availability_zone_no_gpu
image_name = var.orientdb_se_image_name
flavor_name = var.orientdb_se_node_flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.access_to_orientdb_se.name]
security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name,openstack_networking_secgroup_v2.access_to_orientdb_se.name]
block_device {
uuid = var.ubuntu_2204.uuid
uuid = var.orientdb_image_uuid
source_type = "image"
volume_size = 10
boot_index = 0
@ -213,14 +215,14 @@ resource "openstack_compute_instance_v2" "orientdb_se_server" {
}
network {
name = var.main_private_network.name
name = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name
}
network {
name = var.orientdb_se_net.network_name
fixed_ip_v4 = var.orientdb_se_ip
}
user_data = "${file("${var.ubuntu2204_data_file}")}"
user_data = "${file("${module.common_variables.ubuntu_2204.user_data_file}")}"
depends_on = [ openstack_networking_subnet_v2.orientdb_se_subnet ]
}

View File

@ -1 +0,0 @@
../common_variables/outputs.tf

View File

@ -9,3 +9,21 @@ required_version = ">= 0.14.0"
}
}
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../project-setup/terraform.tfstate"
}
}
# SSH settings
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
# Global variables (constants, really)
module "common_variables" {
source = "../../modules/common_variables"
}

View File

@ -7,6 +7,9 @@ variable "orientdb_data" {
}
}
variable "orientdb_affinity_policy" {
default = "soft-anti-affinity"
}
variable "orientdb_node_flavor" {
default = ""
}
@ -15,6 +18,20 @@ variable "orientdb_nodes_count" {
default = ""
}
variable "orientdb_image_name" {
default = ""
}
variable "orientdb_se_image_name" {
default = ""
}
variable "orientdb_image_uuid" {
default = ""
}
variable "orientdb_se_image_uuid" {
default = ""
}
variable "orientdb_ip" {
type = list(string)
default = [ "192.168.10.5", "192.168.10.6", "192.168.10.7"]

View File

@ -1 +0,0 @@
../common_variables/variables.tf