An attempt on using modules. Add orientdb.

This commit is contained in:
Andrea Dell'Amico 2023-11-16 18:55:24 +01:00
parent bdcff8147e
commit d59195c253
Signed by untrusted user: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
27 changed files with 1830 additions and 143 deletions

View File

@ -1,7 +1,7 @@
# #
# This is the security group that should be added to every instance # This is the security group that should be added to every instance
resource "openstack_networking_secgroup_v2" "default" { resource "openstack_networking_secgroup_v2" "default" {
name = "default_for_all" name = var.default_security_group_name
delete_default_rules = "true" delete_default_rules = "true"
description = "Default security group with rules for ssh access via jump proxy, prometheus scraping" description = "Default security group with rules for ssh access via jump proxy, prometheus scraping"
} }

View File

@ -4,7 +4,7 @@ resource "openstack_compute_instance_v2" "ssh_jump_proxy" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.ssh_jump_proxy.flavor flavor_name = var.ssh_jump_proxy.flavor
key_pair = var.ssh_key_file.name key_pair = var.ssh_key_file.name
security_groups = [openstack_networking_secgroup_v2.default.name,openstack_networking_secgroup_v2.access_to_the_jump_proxy.name] security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.access_to_the_jump_proxy.name]
block_device { block_device {
uuid = var.ubuntu_2204.uuid uuid = var.ubuntu_2204.uuid
source_type = "image" source_type = "image"

View File

@ -3,7 +3,7 @@ resource "openstack_compute_instance_v2" "internal_ca" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.internal_ca_data.flavor flavor_name = var.internal_ca_data.flavor
key_pair = var.ssh_key_file.name key_pair = var.ssh_key_file.name
security_groups = [openstack_networking_secgroup_v2.default.name] security_groups = [var.default_security_group_name]
block_device { block_device {
uuid = var.ubuntu_2204.uuid uuid = var.ubuntu_2204.uuid
source_type = "image" source_type = "image"

View File

@ -9,7 +9,7 @@ resource "openstack_compute_instance_v2" "prometheus_server" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.prometheus_server_data.flavor flavor_name = var.prometheus_server_data.flavor
key_pair = var.ssh_key_file.name key_pair = var.ssh_key_file.name
security_groups = [openstack_networking_secgroup_v2.default.name,openstack_networking_secgroup_v2.restricted_web.name,openstack_networking_secgroup_v2.prometheus_access_from_grafana.name] security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.restricted_web.name,openstack_networking_secgroup_v2.prometheus_access_from_grafana.name]
block_device { block_device {
uuid = var.ubuntu_2204.uuid uuid = var.ubuntu_2204.uuid
source_type = "image" source_type = "image"

View File

@ -58,7 +58,7 @@ resource "openstack_compute_instance_v2" "shared_postgresql_server" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.shared_postgresql_server_data.flavor flavor_name = var.shared_postgresql_server_data.flavor
key_pair = var.ssh_key_file.name key_pair = var.ssh_key_file.name
security_groups = [openstack_networking_secgroup_v2.default.name,openstack_networking_secgroup_v2.shared_postgresql_access.name] security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.shared_postgresql_access.name]
block_device { block_device {
uuid = var.ubuntu_2204.uuid uuid = var.ubuntu_2204.uuid
source_type = "image" source_type = "image"

View File

@ -116,7 +116,7 @@ resource "openstack_compute_instance_v2" "main_haproxy_l7" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.haproxy_l7_data.flavor flavor_name = var.haproxy_l7_data.flavor
key_pair = var.ssh_key_file.name key_pair = var.ssh_key_file.name
security_groups = [openstack_networking_secgroup_v2.default.name,openstack_networking_secgroup_v2.main_lb_to_haproxy_l7.name] security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.main_lb_to_haproxy_l7.name]
scheduler_hints { scheduler_hints {
group = openstack_compute_servergroup_v2.main_haproxy_l7.id group = openstack_compute_servergroup_v2.main_haproxy_l7.id
} }

View File

@ -1,10 +0,0 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53.0"
}
}
}

View File

@ -0,0 +1,65 @@
output "mtu_size_value" {
value = var.mtu_size
}
output "main_region_name" {
value = var.main_region
}
output "resolvers_ip" {
value = var.resolvers_ip
}
output "external_network_name" {
value = var.external_network.name
}
output "external_network_id" {
value = var.external_network.id
}
output "availability_zone_no_gpu_name" {
value = var.availability_zones_names.availability_zone_no_gpu
}
output "availability_zone_with_gpu_name" {
value = var.availability_zones_names.availability_zone_with_gpu
}
output "ssh_sources_list" {
value = var.ssh_sources
}
output "ssh_key_file_config" {
value = var.ssh_key_file
}
output "ubuntu1804_img" {
value = var.ubuntu_1804
}
output "ubuntu2204_img" {
value = var.ubuntu_2204
}
output "centos7_img" {
value = var.centos_7
}
output "almalinux9_img" {
value = var.almalinux_9
}
output "ubuntu1804_datafile" {
value = var.ubuntu1804_data_file
}
output "ubuntu2204_datafile" {
value = var.ubuntu2204_data_file
}
output "el7_datafile" {
value = var.el7_data_file
}

View File

@ -1,3 +1,54 @@
# Global definitions
variable "main_region" {
type = string
default = "isti_area_pi_1"
}
variable "external_network" {
type = map(string)
default = {
name = "external-network"
id = "1d2ff137-6ff7-4017-be2b-0d6c4af2353b"
}
}
variable "floating_ip_pools" {
type = map(string)
default = {
main_public_ip_pool = "external-network"
}
}
variable "resolvers_ip" {
type = list(string)
default = ["146.48.29.97", "146.48.29.98", "146.48.29.99"]
}
variable "mtu_size" {
type = number
default = 8942
}
variable "availability_zones_names" {
type = map(string)
default = {
availability_zone_no_gpu = "cnr-isti-nova-a"
availability_zone_with_gpu = "cnr-isti-nova-gpu-a"
}
}
variable "ssh_sources" {
type = map(string)
default = {
s2i2s_vpn_1_cidr = "146.48.28.10/32"
s2i2s_vpn_2_cidr = "146.48.28.11/32"
d4s_vpn_1_cidr = "146.48.122.27/32"
d4s_vpn_2_cidr = "146.48.122.49/32"
shell_d4s_cidr = "146.48.122.95/32"
infrascience_net_cidr = "146.48.122.0/23"
}
}
variable "ssh_key_file" { variable "ssh_key_file" {
type = map(string) type = map(string)
default = { default = {
@ -110,3 +161,19 @@ variable "haproxy_l7_data" {
vm_count = "2" vm_count = "2"
} }
} }
variable "default_security_group_name" {
default = "default_for_all"
}
variable "resource_registry_addresses" {
type = map(string)
default = {
}
}
variable "smartexecutor_addresses" {
type = map(string)
default = {
}
}

View File

@ -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:ZSJPqrlaHQ3sj7wyJuPSG+NblFZbAA6Y0d3GjSJf3o8=",
"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",
]
}

View File

@ -0,0 +1,4 @@
provider "openstack" {
cloud = "d4s-dev"
}

View File

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

View File

@ -0,0 +1 @@
../../modules/common_variables/external-network-and-resolvers.tf

View File

@ -0,0 +1,26 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53.0"
}
}
}
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../project-setup/terraform.tfstate"
}
}
# module "variables" {
# source = "../variables"
# }
# module "orientdb" {
# source = "../../modules/orientdb"
# }

View File

@ -0,0 +1,18 @@
orientdb_nodes_count = 3
orientdb_node_flavor = "m1.medium"
orientdb_se_node_flavor = "m1.medium"
orientdb_se_ip = "192.168.10.4"
orientdb_se_cidr = "192.168.10.4/32"
default_security_group_name = "default"
resource_registry_addresses = {
r1 = "10.1.28.73/32"
r2 = "10.1.28.157/32"
}
smartexecutor_addresses = {
sm1 = "10.1.31.225/32"
sm2 = "10.1.28.168/32"
sm3 = "10.1.30.101/32"
sm4 = "10.1.31.253/32"
}

View File

@ -0,0 +1 @@
../../modules/orientdb/orientdb.tf

View File

@ -0,0 +1 @@
../../modules/common_variables/projects-and-users-vars.tf

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
../../modules/orientdb/variables-orientdb.tf

View File

@ -1,3 +1,4 @@
#
variable "os_project_data" { variable "os_project_data" {
type = map(string) type = map(string)
default = { default = {
@ -80,7 +81,6 @@ variable "basic_services_ip" {
variable "main_haproxy_l7_ip" { variable "main_haproxy_l7_ip" {
type = list(string) type = list(string)
default = ["10.1.28.50", "10.1.30.241"] default = ["10.1.28.50", "10.1.30.241"]
} }
variable "octavia_information" { variable "octavia_information" {
@ -93,3 +93,23 @@ variable "octavia_information" {
main_lb_hostname = "main-lb" main_lb_hostname = "main-lb"
} }
} }
variable "default_security_group_name" {
default = "default"
}
variable "resource_registry_addresses" {
type = map(string)
default = {
r1 = "10.1.28.73"
r2 = "10.1.28.157"
}
}
variable "smartexecutor_addresses" {
type = map(string)
default = {
r1 = "10.1.28.73"
r2 = "10.1.28.157"
}
}

View File

@ -1,3 +1,5 @@
default_security_group_name = "default_for_all"
shared_postgresql_server_data = { shared_postgresql_server_data = {
name ="shared-postgresql-server" name ="shared-postgresql-server"
flavor = "m1.large" flavor = "m1.large"

View File

@ -0,0 +1,52 @@
variable "ssh_key_file" {
type = map(string)
default = {
file = "~/.ssh/id_ed25519"
name = "adellam"
}
}
variable "ubuntu_1804" {
type = map(string)
default = {
name = "Ubuntu-Bionic-18.04"
uuid = "7ed6a2cd-2b07-482e-8ce4-f018dff16c89"
}
}
variable "ubuntu_2204" {
type = map(string)
default = {
name = "Ubuntu-Jammy-22.04"
uuid = "54768889-8556-4be4-a2eb-82a4d9b34627"
}
}
variable "centos_7" {
type = map(string)
default = {
name = "CentOS-7"
uuid = "f0187a99-64f6-462a-ab5f-ef52fe62f2ca"
}
}
variable "almalinux_9" {
type = map(string)
default = {
name = "AlmaLinux-9.0-20220718"
uuid = "541650fc-dd19-4f38-bb1d-7333ed9dd688"
}
}
variable "ubuntu1804_data_file" {
default = "../../openstack_vm_data_scripts/ubuntu1804.sh"
}
variable "ubuntu2204_data_file" {
default = "../../openstack_vm_data_scripts/ubuntu2204.sh"
}
variable "el7_data_file" {
default = "../../openstack_vm_data_scripts/el7.sh"
}

View File

@ -1,50 +0,0 @@
# Global definitions
variable "main_region" {
type = string
default = "isti_area_pi_1"
}
variable "external_network" {
type = map(string)
default = {
name = "external-network"
id = "1d2ff137-6ff7-4017-be2b-0d6c4af2353b"
}
}
variable "floating_ip_pools" {
type = map(string)
default = {
main_public_ip_pool = "external-network"
}
}
variable "resolvers_ip" {
type = list(string)
default = ["146.48.29.97", "146.48.29.98", "146.48.29.99"]
}
variable "mtu_size" {
type = number
default = 8942
}
variable "availability_zones_names" {
type = map(string)
default = {
availability_zone_no_gpu = "cnr-isti-nova-a"
availability_zone_with_gpu = "cnr-isti-nova-gpu-a"
}
}
variable "ssh_sources" {
type = map(string)
default = {
s2i2s_vpn_1_cidr = "146.48.28.10/32"
s2i2s_vpn_2_cidr = "146.48.28.11/32"
d4s_vpn_1_cidr = "146.48.122.27/32"
d4s_vpn_2_cidr = "146.48.122.49/32"
shell_d4s_cidr = "146.48.122.95/32"
infrascience_net_cidr = "146.48.122.0/23"
}
}

View File

@ -1,95 +1,65 @@
variable "os_project_data" { # Define required providers
type = map(string) terraform {
default = { required_version = ">= 0.14.0"
id = "e8f8ca72f30648a8b389b4e745ac83a9" required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53.0"
}
} }
} }
variable "dns_zone" { # Global definitions
variable "main_region" {
type = string
default = "isti_area_pi_1"
}
variable "external_network" {
type = map(string) type = map(string)
default = { default = {
zone_name = "cloud-dev.d4science.org." name = "external-network"
email = "postmaster@isti.cnr.it" id = "1d2ff137-6ff7-4017-be2b-0d6c4af2353b"
description = "DNS primary zone for the d4s-dev-cloud project"
ttl = 8600
} }
} }
variable "dns_zone_id" { variable "floating_ip_pools" {
# Set with the correct value after the setup is complete
default = ""
}
variable "main_private_network" {
type = map(string) type = map(string)
default = { default = {
name = "d4s-dev-cloud-main" main_public_ip_pool = "external-network"
description = "D4Science DEV private network (use this as the main network)"
}
}
variable "main_private_network_id" {
# Set with the correct value after the setup is complete
default = ""
}
variable "main_private_subnet" {
type = map(string)
default = {
name = "d4s-dev-cloud-sub"
description = "D4Science DEV main private subnet"
cidr = "10.1.28.0/22"
gateway_ip = "10.1.28.1"
allocation_start = "10.1.28.30"
allocation_end = "10.1.31.254"
}
}
variable "main_private_subnet_id" {
# Set with the correct value after the setup is complete
default = ""
}
variable "external_router" {
type = map(string)
default = {
name = "d4s-dev-cloud-external-router"
description = "D4Science DEV main router"
id = "2ae28c5f-036b-45db-bc9f-5bab8fa3e914"
}
}
variable "basic_services_ip" {
type = map(string)
default = {
ca = "10.1.29.247"
ca_cidr = "10.1.29.247/32"
ssh_jump = "10.1.29.164"
ssh_jump_cidr = "10.1.29.164/32"
prometheus = "10.1.30.129"
prometheus_cidr = "10.1.30.129/32"
haproxy_l7_1 = "10.1.28.50"
haproxy_l7_1_cidr = "10.1.28.50/32"
haproxy_l7_2 = "10.1.30.241"
haproxy_l7_2_cidr = "10.1.30.241/32"
octavia_main = "10.1.28.227"
octavia_main_cidr = "10.1.28.227/32"
} }
} }
variable "main_haproxy_l7_ip" { variable "resolvers_ip" {
type = list(string) type = list(string)
default = ["10.1.28.50", "10.1.30.241"] default = ["146.48.29.97", "146.48.29.98", "146.48.29.99"]
} }
variable "octavia_information" { variable "mtu_size" {
type = number
default = 8942
}
variable "availability_zones_names" {
type = map(string) type = map(string)
default = { default = {
main_lb_name = "lb-dev-l4" availability_zone_no_gpu = "cnr-isti-nova-a"
main_lb_description = "Main L4 load balancer for the D4Science DEV" availability_zone_with_gpu = "cnr-isti-nova-gpu-a"
octavia_flavor = "octavia_amphora-mvcpu-ha"
octavia_flavor_id = "394988b5-6603-4a1e-a939-8e177c6681c7"
main_lb_hostname = "main-lb"
} }
} }
variable "ssh_sources" {
type = map(string)
default = {
s2i2s_vpn_1_cidr = "146.48.28.10/32"
s2i2s_vpn_2_cidr = "146.48.28.11/32"
d4s_vpn_1_cidr = "146.48.122.27/32"
d4s_vpn_2_cidr = "146.48.122.49/32"
shell_d4s_cidr = "146.48.122.95/32"
infrascience_net_cidr = "146.48.122.0/23"
}
}
output "mtu_size" {
value = var.mtu_size
}

View File

@ -0,0 +1,348 @@
# Define required providers
# terraform {
# required_version = ">= 0.14.0"
# required_providers {
# openstack = {
# source = "terraform-provider-openstack/openstack"
# version = "~> 1.53.0"
# }
# }
# }
#
# module "common_variables" {
# source = "../../modules/common_variables"
# }
#
# Server group
#
# resource "openstack_compute_servergroup_v2" "orientdb_cluster" {
# name = "orientdb_cluster"
# policies = ["soft-anti-affinity"]
# }
# #
# # Network for the cluster traffic
# #
# resource "openstack_networking_network_v2" "orientdb_network" {
# name = var.orientdb_net.network_name
# admin_state_up = "true"
# external = "false"
# description = var.orientdb_net.network_description
# mtu = module.common_variables.mtu_size_value
# port_security_enabled = true
# shared = false
# region = module.common_variables.main_region_name
# }
# # Subnet
# resource "openstack_networking_subnet_v2" "orientdb_subnet" {
# name = "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 = module.common_variables.resolvers_ip
# ip_version = 4
# enable_dhcp = true
# no_gateway = true
# allocation_pool {
# start = var.orientdb_net.allocation_pool_start
# end = var.orientdb_net.allocation_pool_end
# }
# }
# #
# # Security groups
# #
# # Between OrientDB nodes
# resource "openstack_networking_secgroup_v2" "orientdb_internal_traffic" {
# name = "orientdb_internal_docker_traffic"
# delete_default_rules = "true"
# description = "Traffic between the OrientDB nodes"
# }
# resource "openstack_networking_secgroup_rule_v2" "everything_udp" {
# count = var.orientdb_nodes_count
# security_group_id = openstack_networking_secgroup_v2.orientdb_internal_traffic.id
# description = "UDP traffic between OrientDB nodes"
# direction = "ingress"
# ethertype = "IPv4"
# protocol = "udp"
# remote_ip_prefix = var.orientdb_ip.*[count.index]/32
# }
# resource "openstack_networking_secgroup_rule_v2" "everything_tcp" {
# count = var.orientdb_nodes_count
# security_group_id = openstack_networking_secgroup_v2.orientdb_internal_traffic.id
# description = "TCP traffic between OrientDB nodes"
# direction = "ingress"
# ethertype = "IPv4"
# protocol = "tcp"
# remote_ip_prefix = var.orientdb_ip.*[count.index]/32
# }
# resource "openstack_networking_secgroup_v2" "access_to_orientdb" {
# name = "access_to_orientdb"
# delete_default_rules = "true"
# description = "Clients that talk to the OrientDB service"
# }
# resource "openstack_networking_secgroup_rule_v2" "access_to_orient_udp" {
# security_group_id = openstack_networking_secgroup_v2.access_to_orientdb.id
# description = "UDP traffic"
# direction = "ingress"
# ethertype = "IPv4"
# protocol = "udp"
# remote_ip_prefix = openstack_networking_subnet_v2.orientdb_subnet.cidr
# }
# resource "openstack_networking_secgroup_rule_v2" "access_to_orient_tcp" {
# security_group_id = openstack_networking_secgroup_v2.access_to_orientdb.id
# description = "TCP traffic"
# direction = "ingress"
# ethertype = "IPv4"
# protocol = "tcp"
# remote_ip_prefix = openstack_networking_subnet_v2.orientdb_subnet.cidr
# }
# #
# # OrientDB
# #
# # Instance
# resource "openstack_compute_instance_v2" "orientdb_servers" {
# count = local.orientdb_nodes_count
# name = format("%s-%02d", var.orientdb_data.node_name, count.index+1)
# availability_zone_hints = module.common_variables.availability_zone_no_gpu_name
# flavor_name = var.orientdb_data.node_flavor
# key_pair = module.common_variables.ssh_key_file_config
# security_groups = [openstack_networking_secgroup_v2.default.name,openstack_networking_secgroup_v2.orientdb_internal_traffic.name]
# scheduler_hints {
# group = openstack_compute_servergroup_v2.orientdb_cluster.id
# }
# block_device {
# uuid = module.ubuntu2204.uuid
# source_type = "image"
# volume_size = 10
# boot_index = 0
# destination_type = "volume"
# delete_on_termination = false
# }
# block_device {
# source_type = "blank"
# volume_size = var.orientdb_data.node_data_disk_size
# boot_index = -1
# destination_type = "volume"
# delete_on_termination = false
# }
# network {
# name = var.main_private_network.name
# }
# network {
# name = var.orientdb_net.network_name
# fixed_ip_v4 = var.orientdb_ip.*[count.index]
# }
# user_data = "${file("${module.common_variables.ubuntu2204_datafile}")}"
# depends_on = [ openstack_networking_subnet_v2.orientdb_subnet ]
# }
# locals {
# orientdb_nodes_count = 3
# }
#
# Not using modules here
#
resource "openstack_compute_servergroup_v2" "orientdb_cluster" {
name = "orientdb_cluster"
policies = ["soft-anti-affinity"]
}
#
# Network for the cluster traffic
#
resource "openstack_networking_network_v2" "orientdb_network" {
name = var.orientdb_net.network_name
admin_state_up = "true"
external = "false"
description = var.orientdb_net.network_description
mtu = var.mtu_size
port_security_enabled = true
shared = false
region = var.main_region
}
# Subnet
resource "openstack_networking_subnet_v2" "orientdb_subnet" {
name = "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
ip_version = 4
enable_dhcp = true
no_gateway = true
allocation_pool {
start = var.orientdb_net.allocation_pool_start
end = var.orientdb_net.allocation_pool_end
}
}
#
# Security groups
#
# Main OrientDB service
# Between OrientDB nodes
resource "openstack_networking_secgroup_v2" "orientdb_internal_traffic" {
name = "orientdb_internal_docker_traffic"
delete_default_rules = "true"
description = "Traffic between the OrientDB nodes"
}
resource "openstack_networking_secgroup_rule_v2" "orientdb_ports" {
count = var.orientdb_nodes_count
security_group_id = openstack_networking_secgroup_v2.orientdb_internal_traffic.id
description = "TCP traffic between OrientDB nodes"
port_range_min = 2424
port_range_max = 2490
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
# remote_ip_prefix = format("%s-%02d", var.orientdb_ip, count.index+1, "/32")
remote_ip_prefix = var.orientdb_cidr.*[count.index]
}
# Access from the clients
resource "openstack_networking_secgroup_v2" "access_to_orientdb" {
name = "access_to_orientdb"
delete_default_rules = "true"
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, var.resource_registry_addresses.r1, var.resource_registry_addresses.r2])
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
port_range_max = 2490
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
remote_ip_prefix = each.key
}
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])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb.id
description = "TCP traffic from the load balancers"
port_range_min = 2424
port_range_max = 2424
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
remote_ip_prefix = each.key
}
# OrientDB for the Smart Executor nodes
# Access from the clients
resource "openstack_networking_secgroup_v2" "access_to_orientdb_se" {
name = "access_to_orientdb_se"
delete_default_rules = "true"
description = "Clients that talk to the OrientDB service"
}
resource "openstack_networking_secgroup_rule_v2" "access_to_orient_se_from_clients" {
for_each = toset([var.basic_services_ip.ssh_jump_cidr, var.smartexecutor_addresses.sm1, var.smartexecutor_addresses.sm2,var.smartexecutor_addresses.sm3, var.smartexecutor_addresses.sm4])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb_se.id
description = "TCP traffic from the resource registries and the SSH jump server"
port_range_min = 2424
port_range_max = 2490
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
remote_ip_prefix = each.key
}
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])
security_group_id = openstack_networking_secgroup_v2.access_to_orientdb_se.id
description = "TCP traffic from the load balancers"
port_range_min = 2424
port_range_max = 2424
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
remote_ip_prefix = each.key
}
#
# Swarm Manager VMs
#
# Instance
resource "openstack_compute_instance_v2" "orientdb_servers" {
count = local.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
flavor_name = var.orientdb_node_flavor
key_pair = var.ssh_key_file.name
security_groups = [var.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
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
block_device {
source_type = "blank"
volume_size = var.orientdb_data.node_data_disk_size
boot_index = -1
destination_type = "volume"
delete_on_termination = false
}
network {
name = var.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}")}"
depends_on = [ openstack_networking_subnet_v2.orientdb_subnet ]
}
resource "openstack_compute_instance_v2" "orientdb_se_server" {
name = "orientdb-se"
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.orientdb_se_node_flavor
key_pair = var.ssh_key_file.name
security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.access_to_orientdb_se.name]
block_device {
uuid = var.ubuntu_2204.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
block_device {
source_type = "blank"
volume_size = var.orientdb_data.node_data_disk_size
boot_index = -1
destination_type = "volume"
delete_on_termination = false
}
network {
name = var.main_private_network.name
}
network {
name = var.orientdb_net.network_name
fixed_ip_v4 = var.orientdb_se_ip
}
user_data = "${file("${var.ubuntu2204_data_file}")}"
depends_on = [ openstack_networking_subnet_v2.orientdb_subnet ]
}
locals {
orientdb_nodes_count = var.orientdb_nodes_count
}

View File

@ -0,0 +1,48 @@
variable "orientdb_data" {
type = map(string)
default = {
node_name = "orientdb"
node_data_disk_size = 10
node_data_disk_device = "/dev/vdb"
}
}
variable "orientdb_node_flavor" {
default = ""
}
variable "orientdb_nodes_count" {
default = ""
}
variable "orientdb_ip" {
type = list(string)
default = [ "192.168.10.5", "192.168.10.6", "192.168.10.7"]
}
variable "orientdb_cidr" {
type = list(string)
default = [ "192.168.10.5/32", "192.168.10.6/32", "192.168.10.7/32" ]
}
variable "orientdb_se_node_flavor" {
default = ""
}
variable "orientdb_se_ip" {
default = ""
}
variable "orientdb_se_cidr" {
default = ""
}
variable "orientdb_net" {
type = map(string)
default = {
network_name = "orientdb-net"
network_description = "Network used by the OrientDB cluster and to access the service"
network_cidr = "192.168.10.0/24"
allocation_pool_start = "192.168.10.11"
allocation_pool_end = "192.168.10.254"
}
}