Terraform setup for dev.

This commit is contained in:
Andrea Dell'Amico 2023-11-20 18:37:55 +01:00
parent 8350b51931
commit 4038690933
Signed by untrusted user: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
14 changed files with 513 additions and 22 deletions

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

@ -21,6 +21,6 @@ data "terraform_remote_state" "privnet_dns_router" {
# source = "../variables"
# }
# module "orientdb" {
# module "timescaledb" {
# source = "../../modules/timescaledb"
# }

View File

@ -1 +1 @@
../../common_variables/outputs.tf
../../modules/common_variables/outputs.tf

View File

@ -0,0 +1,458 @@
{
"version": 4,
"terraform_version": "1.6.4",
"serial": 9,
"lineage": "bf9ecdb8-7459-9f10-1cdf-ba4f9ac6fc36",
"outputs": {
"almalinux9_img": {
"value": {
"name": "AlmaLinux-9.0-20220718",
"uuid": "541650fc-dd19-4f38-bb1d-7333ed9dd688"
},
"type": [
"map",
"string"
]
},
"availability_zone_no_gpu_name": {
"value": "cnr-isti-nova-a",
"type": "string"
},
"availability_zone_with_gpu_name": {
"value": "cnr-isti-nova-gpu-a",
"type": "string"
},
"centos7_img": {
"value": {
"name": "CentOS-7",
"uuid": "f0187a99-64f6-462a-ab5f-ef52fe62f2ca"
},
"type": [
"map",
"string"
]
},
"el7_datafile": {
"value": "../../openstack_vm_data_scripts/el7.sh",
"type": "string"
},
"external_network_id": {
"value": "1d2ff137-6ff7-4017-be2b-0d6c4af2353b",
"type": "string"
},
"external_network_name": {
"value": "external-network",
"type": "string"
},
"main_region_name": {
"value": "isti_area_pi_1",
"type": "string"
},
"mtu_size_value": {
"value": 8942,
"type": "number"
},
"resolvers_ip": {
"value": [
"146.48.29.97",
"146.48.29.98",
"146.48.29.99"
],
"type": [
"list",
"string"
]
},
"ssh_key_file_config": {
"value": {
"file": "~/.ssh/id_ed25519",
"name": "adellam"
},
"type": [
"map",
"string"
]
},
"ssh_sources_list": {
"value": {
"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"
},
"type": [
"map",
"string"
]
},
"ubuntu1804_datafile": {
"value": "../../openstack_vm_data_scripts/ubuntu1804.sh",
"type": "string"
},
"ubuntu1804_img": {
"value": {
"name": "Ubuntu-Bionic-18.04",
"uuid": "7ed6a2cd-2b07-482e-8ce4-f018dff16c89"
},
"type": [
"map",
"string"
]
},
"ubuntu2204_datafile": {
"value": "../../openstack_vm_data_scripts/ubuntu2204.sh",
"type": "string"
},
"ubuntu2204_img": {
"value": {
"name": "Ubuntu-Jammy-22.04",
"uuid": "54768889-8556-4be4-a2eb-82a4d9b34627"
},
"type": [
"map",
"string"
]
}
},
"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": {
"dns_zone_id": "cbae638a-9d99-44aa-946c-0f5ffb7fc488",
"external_gateway_ip": "146.48.31.109",
"main_private_network_id": "e0af5eba-f24a-4d0d-8184-bc654b980c4a",
"main_subnet_network_id": "2aa977f2-80b4-447c-a6b0-dfa06bf68751"
},
"type": [
"object",
{
"dns_zone_id": "string",
"external_gateway_ip": "string",
"main_private_network_id": "string",
"main_subnet_network_id": "string"
}
]
},
"workspace": null
},
"sensitive_attributes": []
}
]
},
{
"mode": "managed",
"type": "openstack_compute_instance_v2",
"name": "timescaledb_server",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
"access_ip_v4": "10.1.29.68",
"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": "54768889-8556-4be4-a2eb-82a4d9b34627",
"volume_size": 10,
"volume_type": ""
},
{
"boot_index": -1,
"delete_on_termination": false,
"destination_type": "volume",
"device_type": "",
"disk_bus": "",
"guest_format": "",
"multiattach": false,
"source_type": "blank",
"uuid": "",
"volume_size": 20,
"volume_type": ""
}
],
"config_drive": null,
"created": "2023-11-20 17:33:21 +0000 UTC",
"flavor_id": "4",
"flavor_name": "m1.medium",
"floating_ip": null,
"force_delete": false,
"id": "d7eb9df4-3c31-439e-b82b-bb55221a5ebb",
"image_id": "Attempt to boot from volume - no image supplied",
"image_name": null,
"key_pair": "adellam",
"metadata": null,
"name": "timescaledb",
"network": [
{
"access_network": false,
"fixed_ip_v4": "10.1.29.68",
"fixed_ip_v6": "",
"floating_ip": "",
"mac": "fa:16:3e:76:2f:cd",
"name": "d4s-dev-cloud-main",
"port": "",
"uuid": "e0af5eba-f24a-4d0d-8184-bc654b980c4a"
},
{
"access_network": false,
"fixed_ip_v4": "192.168.11.5",
"fixed_ip_v6": "",
"floating_ip": "",
"mac": "fa:16:3e:c3:c4:36",
"name": "timescaledb-net",
"port": "",
"uuid": "ec57aa06-17c8-4475-b4c2-3783f3c7ec7a"
}
],
"network_mode": null,
"personality": [],
"power_state": "active",
"region": "isti_area_pi_1",
"scheduler_hints": [
{
"additional_properties": null,
"build_near_host_ip": "",
"different_cell": [],
"different_host": [],
"group": "7cffdd37-180e-412e-b836-6052f616fbe3",
"query": [],
"same_host": [],
"target_cell": ""
}
],
"security_groups": [
"access_to_the_timescaledb_service",
"default"
],
"stop_before_destroy": false,
"tags": null,
"timeouts": null,
"updated": "2023-11-20 17:34:00 +0000 UTC",
"user_data": "bb83b25fd1219aa1b850ece9be8d7b0f31714608",
"vendor_options": [],
"volume": []
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInVwZGF0ZSI6MTgwMDAwMDAwMDAwMH19",
"dependencies": [
"openstack_compute_servergroup_v2.timescaledb_cluster",
"openstack_networking_network_v2.timescaledb_net",
"openstack_networking_secgroup_v2.timescaledb_access",
"openstack_networking_subnet_v2.timescaledb_subnet"
]
}
]
},
{
"mode": "managed",
"type": "openstack_compute_servergroup_v2",
"name": "timescaledb_cluster",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "7cffdd37-180e-412e-b836-6052f616fbe3",
"members": [],
"name": "timescaledb_cluster",
"policies": [
"soft-anti-affinity"
],
"region": "isti_area_pi_1",
"rules": [
{
"max_server_per_host": 0
}
],
"value_specs": null
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
},
{
"mode": "managed",
"type": "openstack_networking_network_v2",
"name": "timescaledb_net",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"admin_state_up": true,
"all_tags": [],
"availability_zone_hints": [],
"description": "Network used by the Timescaledb cluster and to access the service",
"dns_domain": "cloud-dev.d4science.org.",
"external": false,
"id": "ec57aa06-17c8-4475-b4c2-3783f3c7ec7a",
"mtu": 8942,
"name": "timescaledb-net",
"port_security_enabled": true,
"qos_policy_id": "",
"region": "isti_area_pi_1",
"segments": [],
"shared": false,
"tags": [],
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null,
"transparent_vlan": false,
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0="
}
]
},
{
"mode": "managed",
"type": "openstack_networking_secgroup_rule_v2",
"name": "timescaledb_access_from_dedicated_subnet",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"description": "Allow connections to port 5432 from the 192.168.11.0/24 network",
"direction": "ingress",
"ethertype": "IPv4",
"id": "fbcc6b71-0675-4187-83a9-e48cbafbeaa0",
"port_range_max": 5432,
"port_range_min": 5432,
"protocol": "tcp",
"region": "isti_area_pi_1",
"remote_group_id": "",
"remote_ip_prefix": "192.168.11.0/24",
"security_group_id": "5031077a-d6ca-4bf8-a8b7-efa5235fde03",
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjo2MDAwMDAwMDAwMDB9fQ==",
"dependencies": [
"openstack_networking_secgroup_v2.timescaledb_access"
]
}
]
},
{
"mode": "managed",
"type": "openstack_networking_secgroup_v2",
"name": "timescaledb_access",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"all_tags": [],
"delete_default_rules": true,
"description": "Access the shared TimeScaleDB service using the dedicated network",
"id": "5031077a-d6ca-4bf8-a8b7-efa5235fde03",
"name": "access_to_the_timescaledb_service",
"region": "isti_area_pi_1",
"tags": [],
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjo2MDAwMDAwMDAwMDB9fQ=="
}
]
},
{
"mode": "managed",
"type": "openstack_networking_subnet_v2",
"name": "timescaledb_subnet",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"all_tags": [],
"allocation_pool": [
{
"end": "192.168.11.254",
"start": "192.168.11.20"
}
],
"allocation_pools": [
{
"end": "192.168.11.254",
"start": "192.168.11.20"
}
],
"cidr": "192.168.11.0/24",
"description": "subnet used to connect to the shared TimeScaleDB service",
"dns_nameservers": [
"146.48.29.97",
"146.48.29.98",
"146.48.29.99"
],
"enable_dhcp": true,
"gateway_ip": "",
"host_routes": [],
"id": "37cab9bc-9154-4d95-8f9a-83df111f6e37",
"ip_version": 4,
"ipv6_address_mode": "",
"ipv6_ra_mode": "",
"name": "timescaledb-subnet",
"network_id": "ec57aa06-17c8-4475-b4c2-3783f3c7ec7a",
"no_gateway": true,
"prefix_length": null,
"region": "isti_area_pi_1",
"service_types": [],
"subnetpool_id": "",
"tags": [],
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null,
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"openstack_networking_network_v2.timescaledb_net"
]
}
]
}
],
"check_results": null
}

View File

@ -0,0 +1,3 @@
timescaledb_nodes_count = 1
timescaledb_node_flavor = "m1.medium"
timescaledb_ip = ["192.168.11.5"]

View File

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

View File

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

View File

@ -1 +1 @@
../../common_variables/variables.tf
../../modules/common_variables/variables.tf

View File

@ -21,6 +21,10 @@ variable "dns_zone_id" {
default = ""
}
variable "default_security_group_name" {
default = "default"
}
variable "main_private_network" {
type = map(string)
default = {

View File

@ -21,6 +21,10 @@ variable "dns_zone_id" {
default = "74135b34-1a9c-4c01-8cf0-22450a5660c4"
}
variable "default_security_group_name" {
default = "default_for_all"
}
variable "main_private_network" {
type = map(string)
default = {

View File

@ -174,10 +174,6 @@ variable "haproxy_l7_data" {
}
}
variable "default_security_group_name" {
default = "default_for_all"
}
variable "resource_registry_addresses" {
type = map(string)
default = {

View File

@ -1,10 +1,10 @@
# TimeScaleDB shared server
# Network
resource "openstack_networking_network_v2" "timescaledb_net" {
name = var.timescaledb_server_data.network_name
name = var.timescaledb_net.network_name
admin_state_up = "true"
external = "false"
description = var.timescaledb_server_data.network_description
description = var.timescaledb_net.network_description
dns_domain = var.dns_zone.zone_name
mtu = var.mtu_size
port_security_enabled = true
@ -17,14 +17,14 @@ resource "openstack_networking_subnet_v2" "timescaledb_subnet" {
name = "timescaledb-subnet"
description = "subnet used to connect to the shared TimeScaleDB service"
network_id = openstack_networking_network_v2.timescaledb_net.id
cidr = var.timescaledb_server_data.network_cidr
cidr = var.timescaledb_net.network_cidr
dns_nameservers = var.resolvers_ip
ip_version = 4
enable_dhcp = true
no_gateway = true
allocation_pool {
start = var.timescaledb_server_data.allocation_pool_start
end = var.timescaledb_server_data.allocation_pool_end
start = var.timescaledb_net.allocation_pool_start
end = var.timescaledb_net.allocation_pool_end
}
}
@ -43,7 +43,7 @@ resource "openstack_networking_secgroup_rule_v2" "timescaledb_access_from_dedica
protocol = "tcp"
port_range_min = 5432
port_range_max = 5432
remote_ip_prefix = var.timescaledb_server_data.network_cidr
remote_ip_prefix = var.timescaledb_net.network_cidr
}
resource "openstack_compute_servergroup_v2" "timescaledb_cluster" {
@ -53,10 +53,10 @@ resource "openstack_compute_servergroup_v2" "timescaledb_cluster" {
# Instances with an additional block device
resource "openstack_compute_instance_v2" "timescaledb_server" {
count = var.timescaledb_machines_count
name = var.timescaledb_server_data.name
count = var.timescaledb_nodes_count
name = var.timescaledb_server_data.node_name
availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu
flavor_name = var.timescaledb_server_data.flavor
flavor_name = var.timescaledb_node_flavor
key_pair = var.ssh_key_file.name
security_groups = [var.default_security_group_name,openstack_networking_secgroup_v2.timescaledb_access.name]
scheduler_hints {
@ -73,7 +73,7 @@ resource "openstack_compute_instance_v2" "timescaledb_server" {
block_device {
source_type = "blank"
volume_size = var.timescaledb_data.node_data_disk_size
volume_size = var.timescaledb_server_data.node_data_disk_size
boot_index = -1
destination_type = "volume"
delete_on_termination = false
@ -83,7 +83,7 @@ resource "openstack_compute_instance_v2" "timescaledb_server" {
name = var.main_private_network.name
}
network {
name = var.timescaledb_server_data.network_name
name = var.timescaledb_net.network_name
fixed_ip_v4 = var.timescaledb_ip.*[count.index]
}
@ -91,3 +91,4 @@ resource "openstack_compute_instance_v2" "timescaledb_server" {
depends_on = [openstack_networking_subnet_v2.timescaledb_subnet]
}

View File

@ -1,8 +1,8 @@
variable "timescaledb_data" {
variable "timescaledb_server_data" {
type = map(string)
default = {
node_name = "timescaledb"
node_data_disk_size = 10
node_data_disk_size = 20
node_data_disk_device = "/dev/vdb"
}
}
@ -12,7 +12,7 @@ variable "timescaledb_node_flavor" {
}
variable "timescaledb_nodes_count" {
default = 1
default = 0
}
variable "timescaledb_ip" {