diff --git a/hpc/wp-musit-project-eu/main.tf b/hpc/wp-musit-project-eu/main.tf new file mode 100644 index 0000000..521eda6 --- /dev/null +++ b/hpc/wp-musit-project-eu/main.tf @@ -0,0 +1,100 @@ +# 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 = "../main_net_dns_router/terraform.tfstate" + } +} + +module "ssh_settings" { + source = "../../modules/ssh-key-ref" +} +# +# Uses common_variables as module +# +module "common_variables" { + source = "../../modules/labs_common_variables" +} + +resource "openstack_compute_instance_v2" "wp_musit_proj" { + name = "wp-musit-project" + availability_zone_hints = module.common_variables.availability_zone_no_gpu_name + flavor_name = module.common_variables.flavor_list.m1_medium + key_pair = module.ssh_settings.ssh_key_name + security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name] + block_device { + uuid = module.common_variables.ubuntu_2404.uuid + source_type = "image" + volume_size = 30 + 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("${data.terraform_remote_state.privnet_dns_router.outputs.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 + ] + } +} + +# Allocate and associate a floating IP address +# +resource "openstack_networking_floatingip_v2" "wp_musit_proj_ip" { + pool = module.common_variables.floating_ip_pools.main_public_ip_pool + # The DNS association does not work because of a bug in the OpenStack API + description = "Wordpress for the musit project" +} + +data "openstack_networking_port_v2" "wp_musit_proj_port" { + device_id = openstack_compute_instance_v2.wp_musit_proj.id + network_id = openstack_compute_instance_v2.wp_musit_proj.network.0.uuid +} + +resource "openstack_networking_floatingip_associate_v2" "wp_musit_proj_fip_associate" { + floating_ip = openstack_networking_floatingip_v2.wp_musit_proj_ip.address + port_id = data.openstack_networking_port_v2.wp_musit_proj_port.id +} + +# +# Add a DNS record to the floating IP address +# +module "dns_records_create" { + source = "../../modules/dns_resources" + + dns_resources_map = { + wp = { + zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id + name = join(".", ["wp-musit-proj", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name]) + description = "Wordpress for the musit project" + ttl = 8600 + type = "A" + records = [openstack_networking_floatingip_v2.wp_musit_proj_ip.address] + }, + phpadmin = { + zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id + name = join(".", ["phpadmin-musit", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name]) + description = "PHPMyAdmin for the Wordpress DB of the musit project" + ttl = 8600 + type = "CNAME" + records = [join(".", ["wp-musit-proj", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name])] + } + } +} diff --git a/hpc/wp-musit-project-eu/provider.tf b/hpc/wp-musit-project-eu/provider.tf new file mode 100644 index 0000000..b1bfd26 --- /dev/null +++ b/hpc/wp-musit-project-eu/provider.tf @@ -0,0 +1,3 @@ +provider "openstack" { + cloud = "hpc-lab" +} diff --git a/hpc/wp-musit-project-eu/terraform.tfstate b/hpc/wp-musit-project-eu/terraform.tfstate new file mode 100644 index 0000000..070d159 --- /dev/null +++ b/hpc/wp-musit-project-eu/terraform.tfstate @@ -0,0 +1,681 @@ +{ + "version": 4, + "terraform_version": "1.9.8", + "serial": 7, + "lineage": "2bfb094b-97e5-a6cc-6a44-d2a98acebb93", + "outputs": {}, + "resources": [ + { + "mode": "data", + "type": "openstack_networking_port_v2", + "name": "wp_musit_proj_port", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "admin_state_up": true, + "all_fixed_ips": [ + "10.13.4.130" + ], + "all_security_group_ids": [ + "2f4c13cd-d431-4d52-b8a9-8eea0d7c5c86" + ], + "all_tags": [], + "allowed_address_pairs": [], + "binding": [ + { + "host_id": "", + "profile": "", + "vif_details": {}, + "vif_type": "", + "vnic_type": "normal" + } + ], + "description": "", + "device_id": "08126794-37e8-4ee2-a4ab-7f282f23695d", + "device_owner": "compute:cnr-isti-nova-a", + "dns_assignment": [ + { + "fqdn": "host-10-13-4-130.openstacklocal.", + "hostname": "host-10-13-4-130", + "ip_address": "10.13.4.130" + } + ], + "dns_name": "", + "extra_dhcp_option": [], + "fixed_ip": null, + "id": "869538ab-4778-4f74-b8b1-e70578788804", + "mac_address": "fa:16:3e:66:3c:3f", + "name": "", + "network_id": "5ef3fcdd-590c-4034-a46d-9ddd60693c57", + "port_id": "869538ab-4778-4f74-b8b1-e70578788804", + "project_id": "adaf7e28a31e465795359fcde26398b7", + "region": "isti_area_pi_1", + "security_group_ids": null, + "status": null, + "tags": null, + "tenant_id": "adaf7e28a31e465795359fcde26398b7" + }, + "sensitive_attributes": [] + } + ] + }, + { + "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": "../main_net_dns_router/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" + }, + "centos_7": { + "name": "CentOS-7", + "user_data_file": "../../s2i2s_openstack_vm_data_scripts/el.sh", + "uuid": "f0187a99-64f6-462a-ab5f-ef52fe62f2ca" + }, + "default_security_group_name": "default_for_all", + "dns_zone": { + "attributes": {}, + "description": "DNS primary zone for the HPC project", + "disable_status_check": false, + "email": "postmaster@isti.cnr.it", + "id": "9d929715-2dd7-4859-a52a-bd148d2a6694", + "masters": [], + "name": "hpc.cloud.isti.cnr.it.", + "project_id": "adaf7e28a31e465795359fcde26398b7", + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "PRIMARY", + "value_specs": null + }, + "dns_zone_id": "9d929715-2dd7-4859-a52a-bd148d2a6694", + "el7_data_file": "../../s2i2s_openstack_vm_data_scripts/el.sh", + "external_gateway_ip": [ + { + "ip_address": "146.48.30.35", + "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", + "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" + }, + "main_private_network": { + "admin_state_up": true, + "all_tags": [], + "availability_zone_hints": [], + "description": "HPC private network (use this as the main network)", + "dns_domain": "hpc.cloud.isti.cnr.it.", + "external": false, + "id": "5ef3fcdd-590c-4034-a46d-9ddd60693c57", + "mtu": 8942, + "name": "hpc-cloud-main", + "port_security_enabled": true, + "qos_policy_id": "", + "region": "isti_area_pi_1", + "segments": [ + { + "network_type": "geneve", + "physical_network": "", + "segmentation_id": 30164 + } + ], + "shared": false, + "tags": [], + "tenant_id": "adaf7e28a31e465795359fcde26398b7", + "timeouts": null, + "transparent_vlan": false, + "value_specs": null + }, + "main_private_network_id": "5ef3fcdd-590c-4034-a46d-9ddd60693c57", + "main_region": "isti_area_pi_1", + "main_subnet_network": { + "all_tags": [], + "allocation_pool": [ + { + "end": "10.13.7.254", + "start": "10.13.1.1" + } + ], + "cidr": "10.13.0.0/21", + "description": "HPC main private subnet", + "dns_nameservers": [ + "146.48.29.97", + "146.48.29.98", + "146.48.29.99" + ], + "dns_publish_fixed_ip": false, + "enable_dhcp": true, + "gateway_ip": "10.13.0.1", + "id": "84e50cdf-3f92-4e2c-b366-4e30cfcb913e", + "ip_version": 4, + "ipv6_address_mode": "", + "ipv6_ra_mode": "", + "name": "hpc-cloud-main-subnet", + "network_id": "5ef3fcdd-590c-4034-a46d-9ddd60693c57", + "no_gateway": false, + "prefix_length": null, + "region": "isti_area_pi_1", + "service_types": [], + "subnetpool_id": "", + "tags": [], + "tenant_id": "adaf7e28a31e465795359fcde26398b7", + "timeouts": null, + "value_specs": null + }, + "main_subnet_network_id": "84e50cdf-3f92-4e2c-b366-4e30cfcb913e", + "mtu_size": 8942, + "os_project_data": { + "id": "adaf7e28a31e465795359fcde26398b7", + "name": "hpc-lab-cloud" + }, + "policy_list": { + "affinity": "affinity", + "anti_affinity": "anti-affinity", + "soft_affinity": "soft-affinity", + "soft_anti_affinity": "soft-anti-affinity" + }, + "resolvers_ip": [ + "146.48.29.97", + "146.48.29.98", + "146.48.29.99" + ], + "ssh_sources": { + "infrascience_net_cidr": "146.48.122.0/23", + "isti_net_cidr": "146.48.80.0/21", + "isti_vpn_gw1": "146.48.80.101/32", + "isti_vpn_gw2": "146.48.80.102/32", + "isti_vpn_gw3": "146.48.80.103/32", + "s2i2s_net_cidr": "146.48.28.0/22", + "s2i2s_vpn_1_cidr": "146.48.28.10/32", + "s2i2s_vpn_2_cidr": "146.48.28.11/32" + }, + "ubuntu2204_data_file": "../../s2i2s_openstack_vm_data_scripts/ubuntu2204.sh", + "ubuntu2404_data_file": "../../s2i2s_openstack_vm_data_scripts/ubuntu2404.sh", + "ubuntu_2204": { + "name": "Ubuntu-Jammy-22.04", + "user_data_file": "../../s2i2s_openstack_vm_data_scripts/ubuntu2204.sh", + "uuid": "54768889-8556-4be4-a2eb-82a4d9b34627" + }, + "ubuntu_2404": { + "name": "Ubuntu-Noble-24.04.img", + "user_data_file": "../../s2i2s_openstack_vm_data_scripts/ubuntu2404.sh", + "uuid": "fc3f705d-3cf5-4866-8ef6-ff6e2cdd4075" + } + }, + "type": [ + "object", + { + "almalinux_9": [ + "map", + "string" + ], + "availability_zone_no_gpu_name": "string", + "availability_zone_with_gpu_name": "string", + "availability_zones_names": [ + "map", + "string" + ], + "centos_7": [ + "map", + "string" + ], + "default_security_group_name": "string", + "dns_zone": [ + "object", + { + "attributes": [ + "map", + "string" + ], + "description": "string", + "disable_status_check": "bool", + "email": "string", + "id": "string", + "masters": [ + "set", + "string" + ], + "name": "string", + "project_id": "string", + "region": "string", + "timeouts": [ + "object", + { + "create": "string", + "delete": "string", + "update": "string" + } + ], + "ttl": "number", + "type": "string", + "value_specs": [ + "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", + "flavor_list": [ + "map", + "string" + ], + "floating_ip_pools": [ + "map", + "string" + ], + "main_private_network": [ + "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" + ] + } + ], + "main_private_network_id": "string", + "main_region": "string", + "main_subnet_network": [ + "object", + { + "all_tags": [ + "set", + "string" + ], + "allocation_pool": [ + "set", + [ + "object", + { + "end": "string", + "start": "string" + } + ] + ], + "cidr": "string", + "description": "string", + "dns_nameservers": [ + "list", + "string" + ], + "dns_publish_fixed_ip": "bool", + "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" + ] + } + ], + "main_subnet_network_id": "string", + "mtu_size": "number", + "os_project_data": [ + "map", + "string" + ], + "policy_list": [ + "map", + "string" + ], + "resolvers_ip": [ + "list", + "string" + ], + "ssh_sources": [ + "map", + "string" + ], + "ubuntu2204_data_file": "string", + "ubuntu2404_data_file": "string", + "ubuntu_2204": [ + "map", + "string" + ], + "ubuntu_2404": [ + "map", + "string" + ] + } + ] + }, + "workspace": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "openstack_compute_instance_v2", + "name": "wp_musit_proj", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "access_ip_v4": "10.13.4.130", + "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": "fc3f705d-3cf5-4866-8ef6-ff6e2cdd4075", + "volume_size": 30, + "volume_type": "" + } + ], + "config_drive": null, + "created": "2024-12-02 15:29:24 +0000 UTC", + "flavor_id": "4", + "flavor_name": "m1.medium", + "force_delete": false, + "id": "08126794-37e8-4ee2-a4ab-7f282f23695d", + "image_id": "Attempt to boot from volume - no image supplied", + "image_name": null, + "key_pair": "adellam", + "metadata": null, + "name": "wp-musit-project", + "network": [ + { + "access_network": false, + "fixed_ip_v4": "10.13.4.130", + "fixed_ip_v6": "", + "mac": "fa:16:3e:66:3c:3f", + "name": "hpc-cloud-main", + "port": "", + "uuid": "5ef3fcdd-590c-4034-a46d-9ddd60693c57" + } + ], + "network_mode": null, + "personality": [], + "power_state": "active", + "region": "isti_area_pi_1", + "scheduler_hints": [], + "security_groups": [ + "default_for_all" + ], + "stop_before_destroy": false, + "tags": null, + "timeouts": null, + "updated": "2024-12-02 15:31:44 +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" + ] + } + ] + }, + { + "mode": "managed", + "type": "openstack_networking_floatingip_associate_v2", + "name": "wp_musit_proj_fip_associate", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "fixed_ip": "10.13.4.130", + "floating_ip": "146.48.31.126", + "id": "82303dbf-ffa6-4064-badb-58a40b42d688", + "port_id": "869538ab-4778-4f74-b8b1-e70578788804", + "region": "isti_area_pi_1" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "data.openstack_networking_port_v2.wp_musit_proj_port", + "data.terraform_remote_state.privnet_dns_router", + "openstack_compute_instance_v2.wp_musit_proj", + "openstack_networking_floatingip_v2.wp_musit_proj_ip" + ] + } + ] + }, + { + "mode": "managed", + "type": "openstack_networking_floatingip_v2", + "name": "wp_musit_proj_ip", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": "146.48.31.126", + "all_tags": [], + "description": "Wordpress for the musit project", + "dns_domain": "", + "dns_name": "", + "fixed_ip": "", + "id": "82303dbf-ffa6-4064-badb-58a40b42d688", + "pool": "external-network", + "port_id": "", + "region": "isti_area_pi_1", + "subnet_id": null, + "subnet_ids": null, + "tags": null, + "tenant_id": "adaf7e28a31e465795359fcde26398b7", + "timeouts": null, + "value_specs": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=" + } + ] + }, + { + "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": "phpadmin", + "schema_version": 0, + "attributes": { + "description": "PHPMyAdmin for the Wordpress DB of the musit project", + "disable_status_check": false, + "id": "9d929715-2dd7-4859-a52a-bd148d2a6694/0fcd762b-a2ef-4548-bbdf-bf57dd3e86e5", + "name": "phpadmin-musit.hpc.cloud.isti.cnr.it.", + "project_id": "adaf7e28a31e465795359fcde26398b7", + "records": [ + "wp-musit-proj.hpc.cloud.isti.cnr.it." + ], + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "CNAME", + "value_specs": null, + "zone_id": "9d929715-2dd7-4859-a52a-bd148d2a6694" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router", + "openstack_networking_floatingip_v2.wp_musit_proj_ip" + ] + }, + { + "index_key": "wp", + "schema_version": 0, + "attributes": { + "description": "Wordpress for the musit project", + "disable_status_check": false, + "id": "9d929715-2dd7-4859-a52a-bd148d2a6694/ce45f82c-29e5-451a-9460-4b92168650f1", + "name": "wp-musit-proj.hpc.cloud.isti.cnr.it.", + "project_id": "adaf7e28a31e465795359fcde26398b7", + "records": [ + "146.48.31.126" + ], + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "A", + "value_specs": null, + "zone_id": "9d929715-2dd7-4859-a52a-bd148d2a6694" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router", + "openstack_networking_floatingip_v2.wp_musit_proj_ip" + ] + } + ] + } + ], + "check_results": null +}