Resources for the CKAN legacy VM.

This commit is contained in:
Andrea Dell'Amico 2024-11-14 18:04:24 +01:00
parent b6e3efb344
commit 31699a8ca2
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
4 changed files with 853 additions and 0 deletions

View File

@ -0,0 +1,102 @@
# 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"
}
}
# SSH settings
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
# Global variables (constants, really)
module "common_variables" {
source = "../../modules/garr_common_variables"
}
# SCILake server. All in one, everything docker
resource "openstack_blockstorage_volume_v3" "ckan_legacy_pg_vol" {
name = "CKAN legacy postgresql data"
size = 20
}
resource "openstack_blockstorage_volume_v3" "ckan_legacy_solr_vol" {
name = "CKAN legacy SOLR data"
size = 10
}
resource "openstack_networking_port_v2" "ckan_legacy_ip_in_main_net" {
name = "ckan_legacy_main"
admin_state_up = "true"
network_id = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.id
security_group_ids = [
data.terraform_remote_state.privnet_dns_router.outputs.default_security_group.id,
]
}
resource "openstack_compute_instance_v2" "ckan_dev_legacy_server" {
name = "CKAN dev legacy server"
availability_zone_hints = "nova"
flavor_name = "m2.medium"
key_pair = module.ssh_settings.ssh_key_name
block_device {
uuid = module.common_variables.ubuntu_2404.uuid
source_type = "image"
volume_size = 10
boot_index = 0
destination_type = "volume"
delete_on_termination = true
}
network {
port = openstack_networking_port_v2.ckan_legacy_ip_in_main_net.id
}
user_data = file("${module.common_variables.ubuntu2404_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" "postgresql_data_attach_vol" {
instance_id = openstack_compute_instance_v2.ckan_dev_legacy_server.id
volume_id = openstack_blockstorage_volume_v3.ckan_legacy_pg_vol.id
device = "/dev/vdb"
}
resource "openstack_compute_volume_attach_v2" "solr_data_attach_vol" {
instance_id = openstack_compute_instance_v2.ckan_dev_legacy_server.id
volume_id = openstack_blockstorage_volume_v3.ckan_legacy_solr_vol.id
device = "/dev/vdc"
}
#
resource "openstack_networking_floatingip_v2" "ckan_dev_legacy_floating_ip" {
pool = data.terraform_remote_state.privnet_dns_router.outputs.external_network.name
description = "CKAN dev legacy"
}
resource "openstack_networking_floatingip_associate_v2" "ckan_dev_legacy_server" {
floating_ip = openstack_networking_floatingip_v2.ckan_dev_legacy_floating_ip.address
port_id = openstack_networking_port_v2.ckan_legacy_ip_in_main_net.id
}

View File

@ -0,0 +1,8 @@
output "ckan_dev_legacy_instance" {
value = openstack_compute_instance_v2.ckan_dev_legacy_server
sensitive = true
}
output "ckan_dev_legacy_floating_ip" {
value = openstack_networking_floatingip_v2.ckan_dev_legacy_floating_ip
}

View File

@ -0,0 +1,4 @@
provider "openstack" {
cloud = "garr-na"
}

View File

@ -0,0 +1,739 @@
{
"version": 4,
"terraform_version": "1.9.8",
"serial": 19,
"lineage": "9ffd71a5-c991-1a69-d543-a52a4ce53bea",
"outputs": {
"ckan_dev_legacy_floating_ip": {
"value": {
"address": "90.147.152.55",
"all_tags": [],
"description": "CKAN dev legacy",
"dns_domain": "",
"dns_name": "",
"fixed_ip": "192.168.102.199",
"id": "78785b82-e88f-4df6-841c-d8d637d99025",
"pool": "floating-ip",
"port_id": "084a4d8d-9e70-482b-9ee9-cea4ee11c395",
"region": "garr-na",
"subnet_id": null,
"subnet_ids": null,
"tags": [],
"tenant_id": "a2de533851354b1f8d99ac6b6216d92e",
"timeouts": null,
"value_specs": null
},
"type": [
"object",
{
"address": "string",
"all_tags": [
"set",
"string"
],
"description": "string",
"dns_domain": "string",
"dns_name": "string",
"fixed_ip": "string",
"id": "string",
"pool": "string",
"port_id": "string",
"region": "string",
"subnet_id": "string",
"subnet_ids": [
"list",
"string"
],
"tags": [
"set",
"string"
],
"tenant_id": "string",
"timeouts": [
"object",
{
"create": "string",
"delete": "string"
}
],
"value_specs": [
"map",
"string"
]
}
]
},
"ckan_dev_legacy_instance": {
"value": {
"access_ip_v4": "192.168.102.199",
"access_ip_v6": "",
"admin_pass": null,
"all_metadata": {},
"all_tags": [],
"availability_zone": "nova",
"availability_zone_hints": "nova",
"block_device": [
{
"boot_index": 0,
"delete_on_termination": true,
"destination_type": "volume",
"device_type": "",
"disk_bus": "",
"guest_format": "",
"multiattach": false,
"source_type": "image",
"uuid": "b2f00e68-3847-4f48-a8a6-b28012d57095",
"volume_size": 10,
"volume_type": ""
}
],
"config_drive": null,
"created": "2024-11-14 15:21:33 +0000 UTC",
"flavor_id": "dc8ccff9-2554-4bc4-ac88-b5f99b7b3789",
"flavor_name": "m2.medium",
"force_delete": false,
"id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3",
"image_id": "Attempt to boot from volume - no image supplied",
"image_name": null,
"key_pair": "adellam-ed25519",
"metadata": null,
"name": "CKAN dev legacy server",
"network": [
{
"access_network": false,
"fixed_ip_v4": "192.168.102.199",
"fixed_ip_v6": "",
"mac": "fa:16:3e:3b:60:a5",
"name": "isti-VM-NA-net",
"port": "084a4d8d-9e70-482b-9ee9-cea4ee11c395",
"uuid": "a326a836-6883-43ef-9383-64f0876b0a25"
}
],
"network_mode": null,
"personality": [],
"power_state": "active",
"region": "garr-na",
"scheduler_hints": [],
"security_groups": [
"default"
],
"stop_before_destroy": false,
"tags": [],
"timeouts": null,
"updated": "2024-11-14 15:22:38 +0000 UTC",
"user_data": "164cdf695f3b4a01a2f8b9dc0af2f87629bd89a7",
"vendor_options": []
},
"type": [
"object",
{
"access_ip_v4": "string",
"access_ip_v6": "string",
"admin_pass": "string",
"all_metadata": [
"map",
"string"
],
"all_tags": [
"set",
"string"
],
"availability_zone": "string",
"availability_zone_hints": "string",
"block_device": [
"list",
[
"object",
{
"boot_index": "number",
"delete_on_termination": "bool",
"destination_type": "string",
"device_type": "string",
"disk_bus": "string",
"guest_format": "string",
"multiattach": "bool",
"source_type": "string",
"uuid": "string",
"volume_size": "number",
"volume_type": "string"
}
]
],
"config_drive": "bool",
"created": "string",
"flavor_id": "string",
"flavor_name": "string",
"force_delete": "bool",
"id": "string",
"image_id": "string",
"image_name": "string",
"key_pair": "string",
"metadata": [
"map",
"string"
],
"name": "string",
"network": [
"list",
[
"object",
{
"access_network": "bool",
"fixed_ip_v4": "string",
"fixed_ip_v6": "string",
"mac": "string",
"name": "string",
"port": "string",
"uuid": "string"
}
]
],
"network_mode": "string",
"personality": [
"set",
[
"object",
{
"content": "string",
"file": "string"
}
]
],
"power_state": "string",
"region": "string",
"scheduler_hints": [
"set",
[
"object",
{
"additional_properties": [
"map",
"string"
],
"build_near_host_ip": "string",
"different_cell": [
"list",
"string"
],
"different_host": [
"list",
"string"
],
"group": "string",
"query": [
"list",
"string"
],
"same_host": [
"list",
"string"
],
"target_cell": "string"
}
]
],
"security_groups": [
"set",
"string"
],
"stop_before_destroy": "bool",
"tags": [
"set",
"string"
],
"timeouts": [
"object",
{
"create": "string",
"delete": "string",
"update": "string"
}
],
"updated": "string",
"user_data": "string",
"vendor_options": [
"set",
[
"object",
{
"detach_ports_before_destroy": "bool",
"ignore_resize_confirmation": "bool"
}
]
]
}
],
"sensitive": true
}
},
"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": {
"availability_zone": {
"name": "nova"
},
"default_security_group": {
"id": "b1dca1a8-4eb4-43b0-9fe1-e6a399e23fbb",
"name": "default"
},
"external_network": {
"id": "8a14fb84-2ab4-4114-a95e-1acc029850ff",
"name": "floating-ip"
},
"external_router": {
"description": "GARR-NA main router",
"name": "isti-router"
},
"jump_proxy_ssh_shell": {
"cidr": "192.168.102.151/24",
"hostname": "shell.garr-na1.d4science.org",
"private_ip": "192.168.102.151",
"public_ip": "90.147.152.217"
},
"main_private_network": {
"description": "GARR NA main network",
"id": "a326a836-6883-43ef-9383-64f0876b0a25",
"name": "isti-VM-NA-net"
},
"main_private_subnet": {
"allocation_end": "192.168.102.250",
"allocation_start": "192.168.102.2",
"cidr": "192.168.102.0/24",
"description": "GARR-NA main subnet",
"gateway_ip": "192.168.102.1",
"id": "dd42322a-a4c4-4364-9d23-1e9806e9b9fa",
"name": "isti-na-subnet"
},
"mtu_size": 9000,
"os_project_data": {
"id": "a2de533851354b1f8d99ac6b6216d92e"
},
"os_region_data": {
"name": "garr-na"
},
"prometheus_host": {
"hostname": "prometheus-na1.garr.d4science.net",
"private_ip": "192.168.102.12",
"public_ip": "90.147.152.45"
},
"resolvers_ip": [
"193.206.141.38",
"193.206.141.42"
]
},
"type": [
"object",
{
"availability_zone": [
"map",
"string"
],
"default_security_group": [
"map",
"string"
],
"external_network": [
"map",
"string"
],
"external_router": [
"map",
"string"
],
"jump_proxy_ssh_shell": [
"map",
"string"
],
"main_private_network": [
"map",
"string"
],
"main_private_subnet": [
"map",
"string"
],
"mtu_size": "number",
"os_project_data": [
"map",
"string"
],
"os_region_data": [
"map",
"string"
],
"prometheus_host": [
"map",
"string"
],
"resolvers_ip": [
"list",
"string"
]
}
]
},
"workspace": null
},
"sensitive_attributes": []
}
]
},
{
"mode": "managed",
"type": "openstack_blockstorage_volume_v3",
"name": "ckan_legacy_pg_vol",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"attachment": [],
"availability_zone": "nova",
"backup_id": "",
"consistency_group_id": null,
"description": "",
"enable_online_resize": null,
"id": "477cf81d-521a-4afd-8c8b-8290f44af485",
"image_id": null,
"metadata": {},
"name": "CKAN legacy postgresql data",
"region": "garr-na",
"scheduler_hints": [],
"size": 20,
"snapshot_id": "",
"source_replica": null,
"source_vol_id": "",
"timeouts": null,
"volume_type": "__DEFAULT__"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0="
}
]
},
{
"mode": "managed",
"type": "openstack_blockstorage_volume_v3",
"name": "ckan_legacy_solr_vol",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"attachment": [],
"availability_zone": "nova",
"backup_id": "",
"consistency_group_id": null,
"description": "",
"enable_online_resize": null,
"id": "d2d23a77-9785-40e1-9baa-8e6b76e6023c",
"image_id": null,
"metadata": {},
"name": "CKAN legacy SOLR data",
"region": "garr-na",
"scheduler_hints": [],
"size": 10,
"snapshot_id": "",
"source_replica": null,
"source_vol_id": "",
"timeouts": null,
"volume_type": "__DEFAULT__"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0="
}
]
},
{
"mode": "managed",
"type": "openstack_compute_instance_v2",
"name": "ckan_dev_legacy_server",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"access_ip_v4": "192.168.102.199",
"access_ip_v6": "",
"admin_pass": null,
"all_metadata": {},
"all_tags": [],
"availability_zone": "nova",
"availability_zone_hints": "nova",
"block_device": [
{
"boot_index": 0,
"delete_on_termination": true,
"destination_type": "volume",
"device_type": "",
"disk_bus": "",
"guest_format": "",
"multiattach": false,
"source_type": "image",
"uuid": "b2f00e68-3847-4f48-a8a6-b28012d57095",
"volume_size": 10,
"volume_type": ""
}
],
"config_drive": null,
"created": "2024-11-14 15:21:33 +0000 UTC",
"flavor_id": "dc8ccff9-2554-4bc4-ac88-b5f99b7b3789",
"flavor_name": "m2.medium",
"force_delete": false,
"id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3",
"image_id": "Attempt to boot from volume - no image supplied",
"image_name": null,
"key_pair": "adellam-ed25519",
"metadata": null,
"name": "CKAN dev legacy server",
"network": [
{
"access_network": false,
"fixed_ip_v4": "192.168.102.199",
"fixed_ip_v6": "",
"mac": "fa:16:3e:3b:60:a5",
"name": "isti-VM-NA-net",
"port": "084a4d8d-9e70-482b-9ee9-cea4ee11c395",
"uuid": "a326a836-6883-43ef-9383-64f0876b0a25"
}
],
"network_mode": null,
"personality": [],
"power_state": "active",
"region": "garr-na",
"scheduler_hints": [],
"security_groups": [
"default"
],
"stop_before_destroy": false,
"tags": [],
"timeouts": null,
"updated": "2024-11-14 15:22:38 +0000 UTC",
"user_data": "164cdf695f3b4a01a2f8b9dc0af2f87629bd89a7",
"vendor_options": []
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "admin_pass"
}
]
],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInVwZGF0ZSI6MTgwMDAwMDAwMDAwMH19",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router",
"openstack_networking_port_v2.ckan_legacy_ip_in_main_net"
]
}
]
},
{
"mode": "managed",
"type": "openstack_compute_volume_attach_v2",
"name": "postgresql_data_attach_vol",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"device": "/dev/vdc",
"id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3/477cf81d-521a-4afd-8c8b-8290f44af485",
"instance_id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3",
"multiattach": null,
"region": "garr-na",
"tag": null,
"timeouts": null,
"vendor_options": [],
"volume_id": "477cf81d-521a-4afd-8c8b-8290f44af485"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router",
"openstack_blockstorage_volume_v3.ckan_legacy_pg_vol",
"openstack_compute_instance_v2.ckan_dev_legacy_server",
"openstack_networking_port_v2.ckan_legacy_ip_in_main_net"
]
}
]
},
{
"mode": "managed",
"type": "openstack_compute_volume_attach_v2",
"name": "solr_data_attach_vol",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"device": "/dev/vdb",
"id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3/d2d23a77-9785-40e1-9baa-8e6b76e6023c",
"instance_id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3",
"multiattach": null,
"region": "garr-na",
"tag": null,
"timeouts": null,
"vendor_options": [],
"volume_id": "d2d23a77-9785-40e1-9baa-8e6b76e6023c"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router",
"openstack_blockstorage_volume_v3.ckan_legacy_solr_vol",
"openstack_compute_instance_v2.ckan_dev_legacy_server",
"openstack_networking_port_v2.ckan_legacy_ip_in_main_net"
]
}
]
},
{
"mode": "managed",
"type": "openstack_networking_floatingip_associate_v2",
"name": "ckan_dev_legacy_server",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"fixed_ip": "192.168.102.199",
"floating_ip": "90.147.152.55",
"id": "78785b82-e88f-4df6-841c-d8d637d99025",
"port_id": "084a4d8d-9e70-482b-9ee9-cea4ee11c395",
"region": "garr-na"
},
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router",
"openstack_networking_floatingip_v2.ckan_dev_legacy_floating_ip",
"openstack_networking_port_v2.ckan_legacy_ip_in_main_net"
]
}
]
},
{
"mode": "managed",
"type": "openstack_networking_floatingip_v2",
"name": "ckan_dev_legacy_floating_ip",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"address": "90.147.152.55",
"all_tags": [],
"description": "CKAN dev legacy",
"dns_domain": "",
"dns_name": "",
"fixed_ip": "192.168.102.199",
"id": "78785b82-e88f-4df6-841c-d8d637d99025",
"pool": "floating-ip",
"port_id": "084a4d8d-9e70-482b-9ee9-cea4ee11c395",
"region": "garr-na",
"subnet_id": null,
"subnet_ids": null,
"tags": [],
"tenant_id": "a2de533851354b1f8d99ac6b6216d92e",
"timeouts": null,
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router"
]
}
]
},
{
"mode": "managed",
"type": "openstack_networking_port_v2",
"name": "ckan_legacy_ip_in_main_net",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"admin_state_up": true,
"all_fixed_ips": [
"192.168.102.199"
],
"all_security_group_ids": [
"b1dca1a8-4eb4-43b0-9fe1-e6a399e23fbb"
],
"all_tags": [],
"allowed_address_pairs": [],
"binding": [
{
"host_id": "",
"profile": "",
"vif_details": {},
"vif_type": "",
"vnic_type": "normal"
}
],
"description": "",
"device_id": "241b2cc6-fc94-4b0f-a9d6-31978853ecd3",
"device_owner": "compute:nova",
"dns_assignment": [
{
"fqdn": "ckan-dev-legacy-server.garr.cloud.na.",
"hostname": "ckan-dev-legacy-server",
"ip_address": "192.168.102.199"
}
],
"dns_name": "ckan-dev-legacy-server",
"extra_dhcp_option": [],
"fixed_ip": [],
"id": "084a4d8d-9e70-482b-9ee9-cea4ee11c395",
"mac_address": "fa:16:3e:3b:60:a5",
"name": "ckan_legacy_main",
"network_id": "a326a836-6883-43ef-9383-64f0876b0a25",
"no_fixed_ip": null,
"no_security_groups": null,
"port_security_enabled": true,
"qos_policy_id": "",
"region": "garr-na",
"security_group_ids": [
"b1dca1a8-4eb4-43b0-9fe1-e6a399e23fbb"
],
"tags": [],
"tenant_id": "a2de533851354b1f8d99ac6b6216d92e",
"timeouts": null,
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"data.terraform_remote_state.privnet_dns_router"
]
}
]
}
],
"check_results": null
}