Merge branch 'main' of code-repo.d4science.org:InfraScience/infrastructure-as-code

This commit is contained in:
Antonio Calanducci 2024-07-11 11:46:15 +02:00
commit 6cabc5631f
21 changed files with 13211 additions and 21 deletions

View File

@ -1,7 +1,7 @@
{
"version": 4,
"terraform_version": "1.7.5",
"serial": 587,
"serial": 589,
"lineage": "954b57a1-c68e-fa2b-cf2f-79cc54aea13e",
"outputs": {
"access_postgresql_security_group": {
@ -414,6 +414,81 @@
"string"
]
},
"shared_postgresql_network_data": {
"value": {
"admin_state_up": true,
"all_tags": [],
"availability_zone_hints": [],
"description": "Network used to communicate with the shared postgresql service",
"dns_domain": "cloud.d4science.org.",
"external": false,
"id": "f6450bc8-1345-4b52-8f34-2903c0cca7f8",
"mtu": 8942,
"name": "postgresql-srv-net",
"port_security_enabled": true,
"qos_policy_id": "",
"region": "isti_area_pi_1",
"segments": [],
"shared": false,
"tags": [],
"tenant_id": "1b45adf388934758b56d0dfdb4bfacf3",
"timeouts": null,
"transparent_vlan": false,
"value_specs": null
},
"type": [
"object",
{
"admin_state_up": "bool",
"all_tags": [
"set",
"string"
],
"availability_zone_hints": [
"set",
"string"
],
"description": "string",
"dns_domain": "string",
"external": "bool",
"id": "string",
"mtu": "number",
"name": "string",
"port_security_enabled": "bool",
"qos_policy_id": "string",
"region": "string",
"segments": [
"set",
[
"object",
{
"network_type": "string",
"physical_network": "string",
"segmentation_id": "number"
}
]
],
"shared": "bool",
"tags": [
"set",
"string"
],
"tenant_id": "string",
"timeouts": [
"object",
{
"create": "string",
"delete": "string"
}
],
"transparent_vlan": "bool",
"value_specs": [
"map",
"string"
]
}
]
},
"shared_postgresql_server_data": {
"value": {
"allocation_pool_end": "192.168.3.254",
@ -437,6 +512,98 @@
"string"
]
},
"shared_postgresql_subnet_data": {
"value": {
"all_tags": [],
"allocation_pool": [
{
"end": "192.168.3.254",
"start": "192.168.0.100"
}
],
"cidr": "192.168.0.0/22",
"description": "subnet used to connect to the shared PostgreSQL service",
"dns_nameservers": [
"146.48.29.97",
"146.48.29.98",
"146.48.29.99"
],
"enable_dhcp": true,
"gateway_ip": "",
"id": "761c3c40-5963-40df-a677-cd9b51b72b4d",
"ip_version": 4,
"ipv6_address_mode": "",
"ipv6_ra_mode": "",
"name": "shared-postgresql-subnet",
"network_id": "f6450bc8-1345-4b52-8f34-2903c0cca7f8",
"no_gateway": true,
"prefix_length": null,
"region": "isti_area_pi_1",
"service_types": [],
"subnetpool_id": "",
"tags": [],
"tenant_id": "1b45adf388934758b56d0dfdb4bfacf3",
"timeouts": null,
"value_specs": null
},
"type": [
"object",
{
"all_tags": [
"set",
"string"
],
"allocation_pool": [
"set",
[
"object",
{
"end": "string",
"start": "string"
}
]
],
"cidr": "string",
"description": "string",
"dns_nameservers": [
"list",
"string"
],
"enable_dhcp": "bool",
"gateway_ip": "string",
"id": "string",
"ip_version": "number",
"ipv6_address_mode": "string",
"ipv6_ra_mode": "string",
"name": "string",
"network_id": "string",
"no_gateway": "bool",
"prefix_length": "number",
"region": "string",
"service_types": [
"list",
"string"
],
"subnetpool_id": "string",
"tags": [
"set",
"string"
],
"tenant_id": "string",
"timeouts": [
"object",
{
"create": "string",
"delete": "string"
}
],
"value_specs": [
"map",
"string"
]
}
]
},
"smartexecutor_addresses": {
"value": {},
"type": [

View File

@ -1,5 +1,5 @@
variable "dns_zone_id" {
default = "74135b34-1a9c-4c01-8cf0-22450a5660c4"
default = "74135b34-1a9c-4c01-8cf0-22450a5660c4"
}
variable "main_private_network_id" {

View File

@ -0,0 +1,165 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = ">= 1.54.0"
}
}
}
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../project-setup/terraform.tfstate"
}
}
data "terraform_remote_state" "infrastructure_setup" {
backend = "local"
config = {
path = "../basic-infrastructure/terraform.tfstate"
}
}
#
# Uses common_variables as module
#
module "common_variables" {
source = "../../modules/common_variables"
}
# Module used
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
resource "openstack_networking_secgroup_v2" "d4science_db_access_list" {
name = "d4science_db_access_list"
delete_default_rules = "true"
description = "Allowed connections to the d4science database"
}
resource "openstack_networking_secgroup_rule_v2" "access_to_the_d4science_db" {
for_each = toset([var.d4science_db_allowed_sources.public])
security_group_id = openstack_networking_secgroup_v2.d4science_db_access_list.id
description = "Access to the d4science db"
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 5432
port_range_max = 5432
remote_ip_prefix = each.value
}
# Block device
resource "openstack_blockstorage_volume_v3" "d4science_db_data_vol" {
name = var.d4science_db_data.vol_data_name
size = var.d4science_db_data.vol_data_size
}
resource "openstack_blockstorage_volume_v3" "d4science_db_backup_vol" {
name = var.d4science_db_data.vol_backup_name
size = var.d4science_db_data.vol_backup_size
}
#
# Ports in d4science db network
resource "openstack_networking_port_v2" "d4science_db_port_on_main_net" {
name = "d4science_db_port_on_main_net"
network_id = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network_id
admin_state_up = "true"
fixed_ip {
subnet_id = data.terraform_remote_state.privnet_dns_router.outputs.main_subnet_network_id
}
security_group_ids = [
openstack_networking_secgroup_v2.d4science_db_access_list.id,
data.terraform_remote_state.infrastructure_setup.outputs.default_security_group.id
]
}
# Instance
resource "openstack_compute_instance_v2" "d4science_db_server" {
name = var.d4science_db_data.name
#availability_zone_hints = module.common_variables.availability_zone_no_gpu_name
flavor_name = var.d4science_db_data.flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = [data.terraform_remote_state.infrastructure_setup.outputs.default_security_group.name, data.terraform_remote_state.infrastructure_setup.outputs.access_postgresql_security_group.name, openstack_networking_secgroup_v2.d4science_db_access_list.name]
block_device {
uuid = module.common_variables.ubuntu_2204.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
network {
name = module.common_variables.networks_list.shared_postgresql
fixed_ip_v4 = var.d4science_db_data.server_ip
}
user_data = file("${module.common_variables.ubuntu2204_data_file}")
# Do not replace the instance when the ssh key changes
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
key_pair, user_data, network
]
}
}
resource "openstack_compute_volume_attach_v2" "d4science_db_attach_data_vol" {
instance_id = openstack_compute_instance_v2.d4science_db_server.id
volume_id = openstack_blockstorage_volume_v3.d4science_db_data_vol.id
device = var.d4science_db_data.vol_data_device
depends_on = [openstack_compute_instance_v2.d4science_db_server]
}
resource "openstack_compute_volume_attach_v2" "d4science_db_attach_backup_vol" {
instance_id = openstack_compute_instance_v2.d4science_db_server.id
volume_id = openstack_blockstorage_volume_v3.d4science_db_backup_vol.id
device = var.d4science_db_data.vol_backup_device
depends_on = [openstack_compute_instance_v2.d4science_db_server]
}
resource "openstack_compute_interface_attach_v2" "main_network_to_d4science_db" {
instance_id = openstack_compute_instance_v2.d4science_db_server.id
port_id = openstack_networking_port_v2.d4science_db_port_on_main_net.id
}
# Floating IP and DNS record
resource "openstack_networking_floatingip_v2" "d4science_db_ip" {
pool = data.terraform_remote_state.privnet_dns_router.outputs.floating_ip_pools.main_public_ip_pool
# The DNS association does not work because of a bug in the OpenStack API
description = "D4Science DB"
}
resource "openstack_networking_floatingip_associate_v2" "d4science_db_associate_floatingip" {
floating_ip = openstack_networking_floatingip_v2.d4science_db_ip.address
port_id = openstack_networking_port_v2.d4science_db_port_on_main_net.id
}
locals {
d4science_db_recordset_name = "d4science-db.${data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name}"
}
resource "openstack_dns_recordset_v2" "d4science_db_recordset" {
zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
name = local.d4science_db_recordset_name
description = "Public IP address of D4Science DB"
ttl = 8600
type = "A"
records = [openstack_networking_floatingip_v2.d4science_db_ip.address]
}
output "d4science_db_public_ip_address" {
value = openstack_networking_floatingip_v2.d4science_db_ip.address
}
output "d4science_db_hostname" {
value = openstack_dns_recordset_v2.d4science_db_recordset.name
}

View File

@ -0,0 +1,3 @@
provider "openstack" {
cloud = "d4s-production"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
#D4Science DB variables
variable "d4science_db_data" {
type = map(string)
default = {
name = "d4science-db"
flavor = "m1.large"
vol_data_name = "d4science-db-data"
vol_data_size = "600"
vol_data_device = "/dev/vdb"
vol_backup_name = "d4science-db-backup"
vol_backup_size = "400"
vol_backup_device = "/dev/vdc"
server_ip = "192.168.0.20"
}
}
variable "d4science_db_allowed_sources" {
type = map(string)
default = {
"public" = "0.0.0.0/0"
}
}

View File

@ -0,0 +1,177 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = ">= 1.54.0"
}
}
}
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../project-setup/terraform.tfstate"
}
}
data "terraform_remote_state" "infrastructure_setup" {
backend = "local"
config = {
path = "../basic-infrastructure/terraform.tfstate"
}
}
#
# Uses common_variables as module
#
module "common_variables" {
source = "../../modules/common_variables"
}
# Module used
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
# Creating object bucket to store avatars
resource "openstack_objectstorage_container_v1" "keycloak_1" {
name = var.harbor_data.object_store_name
versioning = false
}
resource "openstack_networking_secgroup_v2" "harbor_access_list" {
name = "harbor_access_list"
delete_default_rules = "true"
description = "Allowed connections to the harbor server"
}
resource "openstack_networking_secgroup_rule_v2" "https_access_to_the_harbor_server" {
security_group_id = openstack_networking_secgroup_v2.harbor_access_list.id
description = "HTTPS access to the Harbor Server"
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 443
port_range_max = 443
remote_ip_prefix = "0.0.0.0/0"
}
resource "openstack_networking_secgroup_rule_v2" "http_access_to_the_harbor_server" {
security_group_id = openstack_networking_secgroup_v2.harbor_access_list.id
description = "HTTP access to the Harbor Server"
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 80
port_range_max = 80
remote_ip_prefix = "0.0.0.0/0"
}
# Block device
resource "openstack_blockstorage_volume_v3" "harbor_data_vol" {
name = var.harbor_data.vol_data_name
size = var.harbor_data.vol_data_size
}
resource "openstack_blockstorage_volume_v3" "harbor_docker_vol" {
name = var.harbor_data.vol_docker_name
size = var.harbor_data.vol_docker_size
}
#
# Port in the postgresql network
resource "openstack_networking_port_v2" "harbor_port_on_the_postgresql_net" {
name = "harbor_port_on_main_net"
network_id = data.terraform_remote_state.infrastructure_setup.outputs.shared_postgresql_network_data.id
admin_state_up = "true"
fixed_ip {
subnet_id = data.terraform_remote_state.infrastructure_setup.outputs.shared_postgresql_subnet_data.id
}
}
# Instance
resource "openstack_compute_instance_v2" "harbor_server" {
name = var.harbor_data.name
# availability_zone_hints = module.common_variables.availability_zone_no_gpu_name
flavor_name = var.harbor_data.flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = [data.terraform_remote_state.infrastructure_setup.outputs.default_security_group.name, openstack_networking_secgroup_v2.harbor_access_list.name]
block_device {
uuid = module.common_variables.ubuntu_2204.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
network {
name = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name
}
user_data = file("${module.common_variables.ubuntu2204_data_file}")
# Do not replace the instance when the ssh key changes
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
key_pair, user_data, network
]
}
}
resource "openstack_compute_volume_attach_v2" "harbor_data_attach_vol" {
instance_id = openstack_compute_instance_v2.harbor_server.id
volume_id = openstack_blockstorage_volume_v3.harbor_data_vol.id
device = var.harbor_data.vol_data_device
depends_on = [openstack_compute_instance_v2.harbor_server]
}
resource "openstack_compute_volume_attach_v2" "harbor_docker_attach_vol" {
instance_id = openstack_compute_instance_v2.harbor_server.id
volume_id = openstack_blockstorage_volume_v3.harbor_docker_vol.id
device = var.harbor_data.vol_docker_device
depends_on = [openstack_compute_instance_v2.harbor_server]
}
resource "openstack_networking_floatingip_v2" "harbor_ip" {
pool = data.terraform_remote_state.privnet_dns_router.outputs.floating_ip_pools.main_public_ip_pool
# The DNS association does not work because of a bug in the OpenStack API
description = "Harbor ip"
}
resource "openstack_compute_floatingip_associate_v2" "harbor_floatingip_associate" {
instance_id = openstack_compute_instance_v2.harbor_server.id
floating_ip = openstack_networking_floatingip_v2.harbor_ip.address
fixed_ip = openstack_compute_instance_v2.harbor_server.network[0].fixed_ip_v4
}
resource "openstack_compute_interface_attach_v2" "postgresql_network_to_harbor" {
instance_id = openstack_compute_instance_v2.harbor_server.id
port_id = openstack_networking_port_v2.harbor_port_on_the_postgresql_net.id
}
locals {
harbor_recordset_name = "harbor.${data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name}"
}
resource "openstack_dns_recordset_v2" "harbor_recordset" {
zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
name = local.harbor_recordset_name
description = "Public IP address of the Harbor Server"
ttl = 8600
type = "A"
records = [openstack_networking_floatingip_v2.harbor_ip.address]
}
output "harbor_public_ip_address" {
value = openstack_networking_floatingip_v2.harbor_ip.address
}
output "harbor_hostname" {
value = openstack_dns_recordset_v2.harbor_recordset.name
}

View File

@ -0,0 +1,3 @@
provider "openstack" {
cloud = "d4s-production"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
#Harbor variables
variable "harbor_data" {
type = map(string)
default = {
name = "harbor"
flavor = "m1.xxl"
vol_data_name = "harbor-data"
vol_data_size = "20"
vol_data_device = "/dev/vdb"
vol_docker_name = "harbor-docker"
vol_docker_size = "2000"
vol_docker_device = "/dev/vdc"
object_store_name = "harbor-registry"
}
}

View File

@ -0,0 +1,136 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = ">= 1.54.0"
}
}
}
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../project-setup/terraform.tfstate"
}
}
#
# Uses common_variables as module
#
module "common_variables" {
source = "../../modules/common_variables"
}
# Module used
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
# Instances
resource "openstack_compute_instance_v2" "icproxy1_prod" {
name = "registry1"
availability_zone_hints = module.common_variables.availability_zone_no_gpu_name
flavor_name = "m1.large"
key_pair = module.ssh_settings.ssh_key_name
security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name, data.terraform_remote_state.privnet_dns_router.outputs.security_group_list.http_and_https_from_the_load_balancers]
block_device {
uuid = module.common_variables.ubuntu_1804.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
# Creates the networks according to input networks
dynamic "network" {
for_each = toset([data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name])
content {
name = network.value
}
}
# user_data script used
user_data = file("${module.common_variables.ubuntu_1804.user_data_file}")
# Do not replace the instance when the ssh key changes
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
key_pair, user_data, network
]
}
}
resource "openstack_compute_instance_v2" "icproxy2_prod" {
name = "registry2"
availability_zone_hints = module.common_variables.availability_zone_no_gpu_name
flavor_name = "m1.large"
key_pair = module.ssh_settings.ssh_key_name
security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name, data.terraform_remote_state.privnet_dns_router.outputs.security_group_list.http_and_https_from_the_load_balancers]
block_device {
uuid = module.common_variables.ubuntu_1804.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
# Creates the networks according to input networks
dynamic "network" {
for_each = toset([data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name])
content {
name = network.value
}
}
# user_data script used
user_data = file("${module.common_variables.ubuntu_1804.user_data_file}")
# Do not replace the instance when the ssh key changes
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
key_pair, user_data, network
]
}
}
locals {
cname_target = "main-lb.${data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name}"
}
#
# Add DNS record/s
#
module "dns_records_create" {
source = "../../modules/dns_resources"
dns_resources_map = {
icproxy1-prod = {
zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
name = join(".", ["registry1", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name])
description = "ICProxy 1"
ttl = 8600
type = "CNAME"
records = [local.cname_target]
},
icproxy2-prod = {
zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
name = join(".", ["registry2", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name])
description = "ICProxy 2"
ttl = 8600
type = "CNAME"
records = [local.cname_target]
}
}
}

View File

@ -0,0 +1,3 @@
provider "openstack" {
cloud = "d4s-production"
}

View File

@ -0,0 +1,612 @@
{
"version": 4,
"terraform_version": "1.6.4",
"serial": 20,
"lineage": "f498a55a-94e0-5af6-6588-65158d0a22e7",
"outputs": {},
"resources": [
{
"mode": "data",
"type": "terraform_remote_state",
"name": "privnet_dns_router",
"provider": "provider[\"terraform.io/builtin/terraform\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"backend": "local",
"config": {
"value": {
"path": "../project-setup/terraform.tfstate"
},
"type": [
"object",
{
"path": "string"
}
]
},
"defaults": null,
"outputs": {
"value": {
"almalinux_9": {
"name": "AlmaLinux-9.0-20220718",
"uuid": "541650fc-dd19-4f38-bb1d-7333ed9dd688"
},
"availability_zone_no_gpu_name": "cnr-isti-nova-a",
"availability_zone_with_gpu_name": "cnr-isti-nova-gpu-a",
"availability_zones_names": {
"availability_zone_no_gpu": "cnr-isti-nova-a",
"availability_zone_with_gpu": "cnr-isti-nova-gpu-a"
},
"basic_services_ip": {
"ca": "10.1.40.4",
"ca_cidr": "10.1.40.4/32",
"haproxy_l7_1": "10.1.40.11",
"haproxy_l7_1_cidr": "10.1.40.11/32",
"haproxy_l7_2": "10.1.40.12",
"haproxy_l7_2_cidr": "10.1.40.12/32",
"octavia_main": "10.1.40.20",
"octavia_main_cidr": "10.1.40.20/32",
"prometheus": "10.1.40.10",
"prometheus_cidr": "10.1.40.10/32",
"ssh_jump": "10.1.40.5",
"ssh_jump_cidr": "10.1.40.5/32"
},
"centos_7": {
"name": "CentOS-7",
"uuid": "f0187a99-64f6-462a-ab5f-ef52fe62f2ca"
},
"default_security_group_name": "default_for_all",
"dns_zone": {
"description": "DNS primary zone for the d4s-production-cloud project",
"email": "postmaster@isti.cnr.it",
"ttl": "8600",
"zone_name": "cloud.d4science.org."
},
"dns_zone_id": "74135b34-1a9c-4c01-8cf0-22450a5660c4",
"el7_data_file": "../../openstack_vm_data_scripts/el7.sh",
"external_gateway_ip": [
{
"ip_address": "146.48.31.57",
"subnet_id": "57f87509-4016-46fb-b8c3-25fca7f72ccb"
}
],
"external_network": {
"id": "1d2ff137-6ff7-4017-be2b-0d6c4af2353b",
"name": "external-network"
},
"external_network_id": "1d2ff137-6ff7-4017-be2b-0d6c4af2353b",
"external_router": {
"description": "D4Science Production main router",
"id": "cc26064a-bb08-4c0b-929f-d0cb39f934a3",
"name": "d4s-production-cloud-external-router"
},
"flavor_list": {
"c1_large": "c1.large",
"c1_medium": "c1.medium",
"c1_small": "c1.small",
"c2_large": "c2.large",
"m1_large": "m1.large",
"m1_medium": "m1.medium",
"m1_xlarge": "m1.xlarge",
"m1_xxl": "m1.xxl",
"m2_large": "m2.large",
"m2_medium": "m2.medium",
"m2_small": "m2.small",
"m3_large": "m3.large"
},
"floating_ip_pools": {
"main_public_ip_pool": "external-network"
},
"haproxy_l7_data": {
"flavor": "m1.medium",
"haproxy_1": "haproxy-l7-1",
"haproxy_2": "haproxy-l7-2",
"name": "main-haproxy-l7",
"vm_count": "2"
},
"internal_ca_data": {
"flavor": "m1.small",
"name": "ca"
},
"main_haproxy_l7_ip": [
"10.1.40.11",
"10.1.40.12"
],
"main_private_network": {
"description": "D4Science Production private network (use this as the main network)",
"name": "d4s-production-cloud-main"
},
"main_private_network_id": "020df98d-ae72-452a-b376-3b6dc289acac",
"main_private_subnet": {
"allocation_end": "10.1.47.254",
"allocation_start": "10.1.41.100",
"cidr": "10.1.40.0/21",
"description": "D4Science Production main private subnet",
"gateway_ip": "10.1.40.1",
"name": "d4s-production-cloud-main-subnet"
},
"main_region": "isti_area_pi_1",
"main_subnet_network_id": "5d7b83ad-e058-4a3a-bfd8-d20ba6d42e1a",
"mtu_size": 8942,
"networks_list": {
"cassandra": "cassandra-net",
"orientdb": "orientdb-net",
"orientdb_se": "orientdb-se-net",
"shared_postgresql": "postgresql-srv-net",
"swarm": "swarm-nfs-net",
"timescaledb": "timescaledb-net"
},
"networks_with_d4s_services": {
"garr_ct1_net": "90.147.166.0/23",
"garr_na_net": "90.147.152.0/24",
"garr_pa1_net": "90.147.188.0/23",
"infrascience_net": "146.48.122.0/23",
"isti_net": "146.48.80.0/21",
"s2i2s_net": "146.48.28.0/22"
},
"nfs_share_no_ingress_secgroup_id": "167e4897-f776-4cbd-986f-77313aa68af2",
"octavia_information": {
"main_lb_description": "Main L4 load balancer for the D4Science production",
"main_lb_hostname": "main-lb",
"main_lb_name": "d4s-production-cloud-l4-load-balancer",
"octavia_flavor": "octavia_amphora-mvcpu-ha",
"octavia_flavor_id": "394988b5-6603-4a1e-a939-8e177c6681c7",
"swarm_lb_name": "d4s-production-cloud-l4-swarm-load-balancer"
},
"os_project_data": {
"id": "1b45adf388934758b56d0dfdb4bfacf3"
},
"policy_list": {
"affinity": "affinity",
"anti_affinity": "anti-affinity",
"soft_affinity": "soft-affinity",
"soft_anti_affinity": "soft-anti-affinity"
},
"prometheus_server_data": {
"flavor": "m1.medium",
"name": "prometheus",
"public_grafana_server_cidr": "146.48.28.103/32",
"vol_data_device": "/dev/vdb",
"vol_data_name": "prometheus-data",
"vol_data_size": "100"
},
"resolvers_ip": [
"146.48.29.97",
"146.48.29.98",
"146.48.29.99"
],
"resource_registry_addresses": {},
"security_group_list": {
"acaland": "acaland's dev machine",
"access_to_orientdb": "access_to_orientdb",
"access_to_orientdb_se": "access_to_orientdb_se",
"access_to_the_timescaledb_service": "access_to_the_timescaledb_service",
"cassandra": "Cassandra",
"dataminer-publish": "dataminer-publish",
"debugging_from_jump_node": "debugging_from_jump_node",
"default": "default",
"docker_swarm": "Docker Swarm",
"docker_swarm_NFS": "Docker Swarm NFS",
"haproxy": "traffic_from_main_lb_to_haproxy_l7",
"http_and_https_from_the_load_balancers": "traffic_from_the_main_load_balancers",
"limited_HTTPS_access": "restricted_web_service",
"limited_SSH_access": "Limited SSH access",
"mongo": "mongo",
"nfs_share_no_ingress": "nfs_share_no_ingress",
"orientdb_internal_docker_traffic": "orientdb_internal_docker_traffic",
"postgreSQL": "PostgreSQL service",
"public_HTTPS": "Public HTTPS"
},
"shared_postgresql_server_data": {
"allocation_pool_end": "192.168.3.254",
"allocation_pool_start": "192.168.0.100",
"flavor": "m1.medium",
"name": "shared-postgresql-server",
"network_cidr": "192.168.0.0/22",
"network_description": "Network used to communicate with the shared postgresql service",
"network_name": "postgresql-srv-net",
"server_cidr": "192.168.0.5/22",
"server_ip": "192.168.0.5",
"vol_data_device": "/dev/vdb",
"vol_data_name": "shared-postgresql-data",
"vol_data_size": "100"
},
"smartexecutor_addresses": {},
"ssh_jump_proxy": {
"flavor": "m2.small",
"name": "ssh-jump-proxy"
},
"ssh_sources": {
"d4s_vpn_1_cidr": "146.48.122.27/32",
"d4s_vpn_2_cidr": "146.48.122.49/32",
"infrascience_net_cidr": "146.48.122.0/23",
"s2i2s_vpn_1_cidr": "146.48.28.10/32",
"s2i2s_vpn_2_cidr": "146.48.28.11/32",
"shell_d4s_cidr": "146.48.122.95/32"
},
"storage_nfs_network_id": "5f4023cc-4016-404c-94e5-86220095fbaf",
"storage_nfs_subnet_id": "6ff0f9e8-0e74-4cc3-a268-7ed4af435696",
"ubuntu1804_data_file": "../../openstack_vm_data_scripts/ubuntu1804.sh",
"ubuntu2204_data_file": "../../openstack_vm_data_scripts/ubuntu2204.sh",
"ubuntu_1804": {
"name": "Ubuntu-Bionic-18.04",
"user_data_file": "../../openstack_vm_data_scripts/ubuntu1804.sh",
"uuid": "7ed6a2cd-2b07-482e-8ce4-f018dff16c89"
},
"ubuntu_2204": {
"name": "Ubuntu-Jammy-22.04",
"user_data_file": "../../openstack_vm_data_scripts/ubuntu2204.sh",
"uuid": "54768889-8556-4be4-a2eb-82a4d9b34627"
}
},
"type": [
"object",
{
"almalinux_9": [
"map",
"string"
],
"availability_zone_no_gpu_name": "string",
"availability_zone_with_gpu_name": "string",
"availability_zones_names": [
"map",
"string"
],
"basic_services_ip": [
"map",
"string"
],
"centos_7": [
"map",
"string"
],
"default_security_group_name": "string",
"dns_zone": [
"map",
"string"
],
"dns_zone_id": "string",
"el7_data_file": "string",
"external_gateway_ip": [
"list",
[
"object",
{
"ip_address": "string",
"subnet_id": "string"
}
]
],
"external_network": [
"map",
"string"
],
"external_network_id": "string",
"external_router": [
"map",
"string"
],
"flavor_list": [
"map",
"string"
],
"floating_ip_pools": [
"map",
"string"
],
"haproxy_l7_data": [
"map",
"string"
],
"internal_ca_data": [
"map",
"string"
],
"main_haproxy_l7_ip": [
"list",
"string"
],
"main_private_network": [
"map",
"string"
],
"main_private_network_id": "string",
"main_private_subnet": [
"map",
"string"
],
"main_region": "string",
"main_subnet_network_id": "string",
"mtu_size": "number",
"networks_list": [
"map",
"string"
],
"networks_with_d4s_services": [
"map",
"string"
],
"nfs_share_no_ingress_secgroup_id": "string",
"octavia_information": [
"map",
"string"
],
"os_project_data": [
"map",
"string"
],
"policy_list": [
"map",
"string"
],
"prometheus_server_data": [
"map",
"string"
],
"resolvers_ip": [
"list",
"string"
],
"resource_registry_addresses": [
"map",
"string"
],
"security_group_list": [
"map",
"string"
],
"shared_postgresql_server_data": [
"map",
"string"
],
"smartexecutor_addresses": [
"map",
"string"
],
"ssh_jump_proxy": [
"map",
"string"
],
"ssh_sources": [
"map",
"string"
],
"storage_nfs_network_id": "string",
"storage_nfs_subnet_id": "string",
"ubuntu1804_data_file": "string",
"ubuntu2204_data_file": "string",
"ubuntu_1804": [
"map",
"string"
],
"ubuntu_2204": [
"map",
"string"
]
}
]
},
"workspace": null
},
"sensitive_attributes": []
}
]
},
{
"mode": "managed",
"type": "openstack_compute_instance_v2",
"name": "icproxy1_prod",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"access_ip_v4": "10.1.44.3",
"access_ip_v6": "",
"admin_pass": null,
"all_metadata": {},
"all_tags": [],
"availability_zone": "cnr-isti-nova-a",
"availability_zone_hints": "cnr-isti-nova-a",
"block_device": [
{
"boot_index": 0,
"delete_on_termination": false,
"destination_type": "volume",
"device_type": "",
"disk_bus": "",
"guest_format": "",
"multiattach": false,
"source_type": "image",
"uuid": "7ed6a2cd-2b07-482e-8ce4-f018dff16c89",
"volume_size": 10,
"volume_type": ""
}
],
"config_drive": null,
"created": "2024-07-09 09:15:45 +0000 UTC",
"flavor_id": "9",
"flavor_name": "m1.large",
"force_delete": false,
"id": "dd71169f-2c22-422d-bb39-fd6068209d38",
"image_id": "Attempt to boot from volume - no image supplied",
"image_name": null,
"key_pair": "Giancarlo Panichi",
"metadata": null,
"name": "registry1",
"network": [
{
"access_network": false,
"fixed_ip_v4": "10.1.44.3",
"fixed_ip_v6": "",
"mac": "fa:16:3e:a9:c9:df",
"name": "d4s-production-cloud-main",
"port": "",
"uuid": "020df98d-ae72-452a-b376-3b6dc289acac"
}
],
"network_mode": null,
"personality": [],
"power_state": "active",
"region": "isti_area_pi_1",
"scheduler_hints": [],
"security_groups": [
"default_for_all",
"traffic_from_the_main_load_balancers"
],
"stop_before_destroy": false,
"tags": [],
"timeouts": null,
"updated": "2024-07-09 09:16:31 +0000 UTC",
"user_data": "47d4769e61324c305c4b70ed6673de4fad84150d",
"vendor_options": []
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInVwZGF0ZSI6MTgwMDAwMDAwMDAwMH19",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router"
]
}
]
},
{
"mode": "managed",
"type": "openstack_compute_instance_v2",
"name": "icproxy2_prod",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"access_ip_v4": "10.1.45.81",
"access_ip_v6": "",
"admin_pass": null,
"all_metadata": {},
"all_tags": [],
"availability_zone": "cnr-isti-nova-a",
"availability_zone_hints": "cnr-isti-nova-a",
"block_device": [
{
"boot_index": 0,
"delete_on_termination": false,
"destination_type": "volume",
"device_type": "",
"disk_bus": "",
"guest_format": "",
"multiattach": false,
"source_type": "image",
"uuid": "7ed6a2cd-2b07-482e-8ce4-f018dff16c89",
"volume_size": 10,
"volume_type": ""
}
],
"config_drive": null,
"created": "2024-07-09 09:15:45 +0000 UTC",
"flavor_id": "9",
"flavor_name": "m1.large",
"force_delete": false,
"id": "635a95a1-e0c2-465c-a574-cab3ef583c5e",
"image_id": "Attempt to boot from volume - no image supplied",
"image_name": null,
"key_pair": "Giancarlo Panichi",
"metadata": null,
"name": "registry2",
"network": [
{
"access_network": false,
"fixed_ip_v4": "10.1.45.81",
"fixed_ip_v6": "",
"mac": "fa:16:3e:69:e3:a3",
"name": "d4s-production-cloud-main",
"port": "",
"uuid": "020df98d-ae72-452a-b376-3b6dc289acac"
}
],
"network_mode": null,
"personality": [],
"power_state": "active",
"region": "isti_area_pi_1",
"scheduler_hints": [],
"security_groups": [
"default_for_all",
"traffic_from_the_main_load_balancers"
],
"stop_before_destroy": false,
"tags": [],
"timeouts": null,
"updated": "2024-07-09 09:16:50 +0000 UTC",
"user_data": "47d4769e61324c305c4b70ed6673de4fad84150d",
"vendor_options": []
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInVwZGF0ZSI6MTgwMDAwMDAwMDAwMH19",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router"
]
}
]
},
{
"module": "module.dns_records_create",
"mode": "managed",
"type": "openstack_dns_recordset_v2",
"name": "add_dns_recordset",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"index_key": "icproxy1-prod",
"schema_version": 0,
"attributes": {
"description": "ICProxy 1",
"disable_status_check": false,
"id": "74135b34-1a9c-4c01-8cf0-22450a5660c4/a853af7f-edb4-46d8-85be-c52701af07b6",
"name": "registry1.cloud.d4science.org.",
"project_id": "1b45adf388934758b56d0dfdb4bfacf3",
"records": [
"main-lb.cloud.d4science.org."
],
"region": "isti_area_pi_1",
"timeouts": null,
"ttl": 8600,
"type": "CNAME",
"value_specs": null,
"zone_id": "74135b34-1a9c-4c01-8cf0-22450a5660c4"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router"
]
},
{
"index_key": "icproxy2-prod",
"schema_version": 0,
"attributes": {
"description": "ICProxy 2",
"disable_status_check": false,
"id": "74135b34-1a9c-4c01-8cf0-22450a5660c4/af98500e-cd61-48fe-98a4-099061f7eeb9",
"name": "registry2.cloud.d4science.org.",
"project_id": "1b45adf388934758b56d0dfdb4bfacf3",
"records": [
"main-lb.cloud.d4science.org."
],
"region": "isti_area_pi_1",
"timeouts": null,
"ttl": 8600,
"type": "CNAME",
"value_specs": null,
"zone_id": "74135b34-1a9c-4c01-8cf0-22450a5660c4"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router"
]
}
]
}
],
"check_results": null
}

View File

@ -0,0 +1,138 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = ">= 1.54.0"
}
}
}
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../project-setup/terraform.tfstate"
}
}
data "terraform_remote_state" "infrastructure_setup" {
backend = "local"
config = {
path = "../basic-infrastructure/terraform.tfstate"
}
}
#
# Uses common_variables as module
#
module "common_variables" {
source = "../../modules/common_variables"
}
# Module used
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
# Creating object bucket to store avatars
resource "openstack_objectstorage_container_v1" "keycloak_1" {
name = var.pwdns_data.object_store_name
versioning = false
}
resource "openstack_networking_secgroup_v2" "pwdns_access_list" {
name = "pwdns_access_list"
delete_default_rules = "true"
description = "Allowed connections to the powerdns server"
}
resource "openstack_networking_secgroup_rule_v2" "tcp_access_to_pwdns" {
security_group_id = openstack_networking_secgroup_v2.pwdns_access_list.id
description = "TCP access to the PowerDNS Server"
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 53
port_range_max = 53
remote_ip_prefix = "0.0.0.0/0"
}
resource "openstack_networking_secgroup_rule_v2" "upd_access_to_pwdns" {
security_group_id = openstack_networking_secgroup_v2.pwdns_access_list.id
description = "UDP access to the PowerDNS Server"
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 53
port_range_max = 53
remote_ip_prefix = "0.0.0.0/0"
}
# Instance
resource "openstack_compute_instance_v2" "pwdns_server" {
name = var.pwdns_data.name
flavor_name = var.pwdns_data.flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = [data.terraform_remote_state.infrastructure_setup.outputs.default_security_group.name, openstack_networking_secgroup_v2.pwdns_access_list.name]
block_device {
uuid = module.common_variables.ubuntu_2204.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
network {
name = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name
}
user_data = file("${module.common_variables.ubuntu2204_data_file}")
# Do not replace the instance when the ssh key changes
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
key_pair, user_data, network
]
}
}
resource "openstack_networking_floatingip_v2" "pwdns_ip" {
pool = data.terraform_remote_state.privnet_dns_router.outputs.floating_ip_pools.main_public_ip_pool
# The DNS association does not work because of a bug in the OpenStack API
description = "PowerDNS ip"
}
resource "openstack_compute_floatingip_associate_v2" "pwdns_floatingip_associate" {
instance_id = openstack_compute_instance_v2.pwdns_server.id
floating_ip = openstack_networking_floatingip_v2.pwdns_ip.address
fixed_ip = openstack_compute_instance_v2.pwdns_server.network[0].fixed_ip_v4
}
locals {
pwdns_recordset_name = "powerdns.${data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name}"
}
resource "openstack_dns_recordset_v2" "pwdns_recordset" {
zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
name = local.pwdns_recordset_name
description = "Public IP address of the PowerDNS Server"
ttl = 8600
type = "A"
records = [openstack_networking_floatingip_v2.pwdns_ip.address]
}
output "pwdns_public_ip_address" {
value = openstack_networking_floatingip_v2.pwdns_ip.address
}
output "pwdns_hostname" {
value = openstack_dns_recordset_v2.pwdns_recordset.name
}

View File

@ -0,0 +1,3 @@
provider "openstack" {
cloud = "d4s-production"
}

View File

@ -0,0 +1,10 @@
#Harbor variables
variable "pwdns_data" {
type = map(string)
default = {
name = "powerdns"
flavor = "c1.small"
object_store_name = "pwdns-registry"
}
}

View File

@ -31,10 +31,10 @@ output "main_haproxy_l7_ip" {
}
output "octavia_information" {
value = var.octavia_information
value = var.octavia_information
}
output "access_postgresql_security_group" {
value = openstack_networking_secgroup_v2.shared_postgresql_access
value = openstack_networking_secgroup_v2.shared_postgresql_access
}

View File

@ -1,10 +1,10 @@
# Main load balancer. L4, backed by Octavia
resource "openstack_lb_loadbalancer_v2" "main_lb" {
vip_subnet_id = var.main_private_subnet_id
name = var.octavia_information.main_lb_name
description = var.octavia_information.main_lb_description
flavor_id = var.octavia_information.octavia_flavor_id
vip_address = var.basic_services_ip.octavia_main
vip_subnet_id = var.main_private_subnet_id
name = var.octavia_information.main_lb_name
description = var.octavia_information.main_lb_description
flavor_id = var.octavia_information.octavia_flavor_id
vip_address = var.basic_services_ip.octavia_main
# availability_zone = var.availability_zones_names.availability_zone_no_gpu
loadbalancer_provider = "amphora"
}
@ -133,15 +133,15 @@ resource "openstack_lb_monitor_v2" "main_haproxy_http_monitor" {
# Main HAPROXY HTTPS
resource "openstack_lb_listener_v2" "main_haproxy_https_listener" {
loadbalancer_id = openstack_lb_loadbalancer_v2.main_lb.id
protocol = "TCP"
protocol_port = 443
description = "HTTPS listener of the main HAPROXY instances"
name = "main_haproxy_https_listener"
timeout_client_data = 3600000
loadbalancer_id = openstack_lb_loadbalancer_v2.main_lb.id
protocol = "TCP"
protocol_port = 443
description = "HTTPS listener of the main HAPROXY instances"
name = "main_haproxy_https_listener"
timeout_client_data = 3600000
timeout_member_connect = 10000
timeout_member_data = 7200000
admin_state_up = true
timeout_member_data = 7200000
admin_state_up = true
}
resource "openstack_lb_pool_v2" "main_haproxy_https_pool" {

View File

@ -94,3 +94,12 @@ resource "openstack_compute_volume_attach_v2" "shared_postgresql_data_attach_vol
device = var.shared_postgresql_server_data.vol_data_device
depends_on = [openstack_compute_instance_v2.shared_postgresql_server]
}
output "shared_postgresql_network_data" {
value = openstack_networking_network_v2.shared_postgresql_net
}
output "shared_postgresql_subnet_data" {
value = openstack_networking_subnet_v2.shared_postgresql_subnet
}

View File

@ -77,10 +77,10 @@ resource "openstack_dns_recordset_v2" "alertmanager_server_recordset" {
}
output "prometheus_public_ip_address" {
value = openstack_networking_floatingip_v2.prometheus_server_ip.address
value = openstack_networking_floatingip_v2.prometheus_server_ip.address
}
output "prometheus_server_hostname" {
value = openstack_dns_recordset_v2.prometheus_server_recordset.name
value = openstack_dns_recordset_v2.prometheus_server_recordset.name
}

View File

@ -96,7 +96,7 @@ resource "openstack_compute_instance_v2" "docker_swarm_managers" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.docker_swarm_data.mgr_flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = [openstack_networking_secgroup_v2.default.name, openstack_networking_secgroup_v2.swarm_internal_traffic.name,"default","nfs_share_no_ingress"]
security_groups = [openstack_networking_secgroup_v2.default.name, openstack_networking_secgroup_v2.swarm_internal_traffic.name, "default", "nfs_share_no_ingress"]
scheduler_hints {
group = openstack_compute_servergroup_v2.swarm_masters.id
}
@ -145,7 +145,7 @@ resource "openstack_compute_instance_v2" "docker_swarm_workers" {
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.docker_swarm_data.worker_flavor
key_pair = module.ssh_settings.ssh_key_name
security_groups = ["default", var.default_security_group_name, openstack_networking_secgroup_v2.swarm_internal_traffic.name,"nfs_share_no_ingress"]
security_groups = ["default", var.default_security_group_name, openstack_networking_secgroup_v2.swarm_internal_traffic.name, "nfs_share_no_ingress"]
scheduler_hints {
group = openstack_compute_servergroup_v2.swarm_workers.id
}
@ -270,6 +270,13 @@ resource "openstack_compute_instance_v2" "swarm_nfs_server" {
user_data = file("${var.ubuntu2204_data_file}")
depends_on = [openstack_networking_subnet_v2.swarm_nfs_subnet]
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
key_pair, user_data, network
]
}
}
# Attach the additional volume