diff --git a/kdd/wp-ai4securesociety/main.tf b/kdd/wp-ai4securesociety/main.tf new file mode 100644 index 0000000..963b23d --- /dev/null +++ b/kdd/wp-ai4securesociety/main.tf @@ -0,0 +1,94 @@ +# Define required providers +terraform { + required_version = ">= 0.14.0" + required_providers { + openstack = { + source = "terraform-provider-openstack/openstack" + version = "~> 1.53.0" + } + } +} + +data "terraform_remote_state" "privnet_dns_router" { + backend = "local" + + config = { + path = "../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_ai4securesociety" { + name = "wp-ai4securesociety" + 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_2204.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.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 + ] + } +} + +# Allocate and associate a floating IP address +# +resource "openstack_networking_floatingip_v2" "wp_ai4securesociety_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 SobigData summer school 2024 ai4securesociety initiative" +} + +resource "openstack_compute_floatingip_associate_v2" "wp_ai4securesociety_fp" { + floating_ip = openstack_networking_floatingip_v2.wp_ai4securesociety_ip.address + instance_id = openstack_compute_instance_v2.wp_ai4securesociety.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(".", ["ai4securesociety", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name]) + description = "Wordpress for the SobigData summer school 2024 ai4securesociety initiative" + ttl = 8600 + type = "A" + records = [openstack_networking_floatingip_v2.wp_ai4securesociety_ip.address] + }, + phpadmin = { + zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id + name = join(".", ["phpadmin-ai4securesociety", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name]) + description = "PHPMyAdmin for the Wordpress DB of the SobigData summer school 2024 ai4securesociety initiative" + ttl = 8600 + type = "CNAME" + records = [join(".", ["ai4securesociety", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name])] + } + } +} diff --git a/kdd/wp-ai4securesociety/provider.tf b/kdd/wp-ai4securesociety/provider.tf new file mode 100644 index 0000000..0d5af91 --- /dev/null +++ b/kdd/wp-ai4securesociety/provider.tf @@ -0,0 +1,3 @@ +provider "openstack" { + cloud = "kdd-lab" +} diff --git a/kdd/wp-ai4securesociety/terraform.tfstate b/kdd/wp-ai4securesociety/terraform.tfstate new file mode 100644 index 0000000..bf0e7ea --- /dev/null +++ b/kdd/wp-ai4securesociety/terraform.tfstate @@ -0,0 +1,636 @@ +{ + "version": 4, + "terraform_version": "1.6.6", + "serial": 6, + "lineage": "92f7f8a7-4f51-0a75-de75-21baf92de2c7", + "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": "../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 KDD project", + "disable_status_check": false, + "email": "postmaster@isti.cnr.it", + "id": "9d29d051-9567-4af4-9ffe-87eb643fc90b", + "masters": [], + "name": "kdd.cloud.isti.cnr.it.", + "project_id": "d6757d56e6e54ffe83a9701cc92af4c2", + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "PRIMARY", + "value_specs": null + }, + "dns_zone_id": "9d29d051-9567-4af4-9ffe-87eb643fc90b", + "el7_data_file": "../../s2i2s_openstack_vm_data_scripts/el.sh", + "external_gateway_ip": [ + { + "ip_address": "146.48.30.196", + "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": "KDD private network (use this as the main network)", + "dns_domain": "kdd.cloud.isti.cnr.it.", + "external": false, + "id": "fb006673-39b6-472b-ba20-f1087e7e38ef", + "mtu": 8942, + "name": "kdd-cloud-main", + "port_security_enabled": true, + "qos_policy_id": "", + "region": "isti_area_pi_1", + "segments": [ + { + "network_type": "geneve", + "physical_network": "", + "segmentation_id": 6061 + } + ], + "shared": false, + "tags": [], + "tenant_id": "d6757d56e6e54ffe83a9701cc92af4c2", + "timeouts": null, + "transparent_vlan": false, + "value_specs": null + }, + "main_private_network_id": "fb006673-39b6-472b-ba20-f1087e7e38ef", + "main_region": "isti_area_pi_1", + "main_subnet_network": { + "all_tags": [], + "allocation_pool": [ + { + "end": "10.12.7.254", + "start": "10.12.1.1" + } + ], + "allocation_pools": [ + { + "end": "10.12.7.254", + "start": "10.12.1.1" + } + ], + "cidr": "10.12.0.0/21", + "description": "KDD main private subnet", + "dns_nameservers": [ + "146.48.29.97", + "146.48.29.98", + "146.48.29.99" + ], + "enable_dhcp": true, + "gateway_ip": "10.12.0.1", + "host_routes": [], + "id": "ddf59a67-2bbc-4678-a1ae-19ef01a295e2", + "ip_version": 4, + "ipv6_address_mode": "", + "ipv6_ra_mode": "", + "name": "kdd-cloud-main-subnet", + "network_id": "fb006673-39b6-472b-ba20-f1087e7e38ef", + "no_gateway": false, + "prefix_length": null, + "region": "isti_area_pi_1", + "service_types": [], + "subnetpool_id": "", + "tags": [], + "tenant_id": "d6757d56e6e54ffe83a9701cc92af4c2", + "timeouts": null, + "value_specs": null + }, + "main_subnet_network_id": "ddf59a67-2bbc-4678-a1ae-19ef01a295e2", + "mtu_size": 8942, + "os_project_data": { + "id": "d6757d56e6e54ffe83a9701cc92af4c2", + "name": "kdd-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", + "ubuntu_2204": { + "name": "Ubuntu-Jammy-22.04", + "user_data_file": "../../s2i2s_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" + ], + "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" + } + ] + ], + "allocation_pools": [ + "list", + [ + "object", + { + "end": "string", + "start": "string" + } + ] + ], + "cidr": "string", + "description": "string", + "dns_nameservers": [ + "list", + "string" + ], + "enable_dhcp": "bool", + "gateway_ip": "string", + "host_routes": [ + "list", + [ + "object", + { + "destination_cidr": "string", + "next_hop": "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", + "ubuntu_2204": [ + "map", + "string" + ] + } + ] + }, + "workspace": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "openstack_compute_floatingip_associate_v2", + "name": "wp_ai4securesociety_fp", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "fixed_ip": "", + "floating_ip": "146.48.30.89", + "id": "146.48.30.89/b0e31162-e764-40b2-b34e-f5133caff757/", + "instance_id": "b0e31162-e764-40b2-b34e-f5133caff757", + "region": "isti_area_pi_1", + "timeouts": null, + "wait_until_associated": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router", + "openstack_compute_instance_v2.wp_ai4securesociety", + "openstack_networking_floatingip_v2.wp_ai4securesociety_ip" + ] + } + ] + }, + { + "mode": "managed", + "type": "openstack_compute_instance_v2", + "name": "wp_ai4securesociety", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "access_ip_v4": "10.12.1.4", + "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": 30, + "volume_type": "" + } + ], + "config_drive": null, + "created": "2024-02-29 18:04:05 +0000 UTC", + "flavor_id": "4", + "flavor_name": "m1.medium", + "floating_ip": null, + "force_delete": false, + "id": "b0e31162-e764-40b2-b34e-f5133caff757", + "image_id": "Attempt to boot from volume - no image supplied", + "image_name": null, + "key_pair": "adellam", + "metadata": null, + "name": "wp-ai4securesociety", + "network": [ + { + "access_network": false, + "fixed_ip_v4": "10.12.1.4", + "fixed_ip_v6": "", + "floating_ip": "", + "mac": "fa:16:3e:bc:22:72", + "name": "kdd-cloud-main", + "port": "", + "uuid": "fb006673-39b6-472b-ba20-f1087e7e38ef" + } + ], + "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-02-29 18:04:47 +0000 UTC", + "user_data": "094aad1c2a9d617fb2d4622557b2841486c0ecd7", + "vendor_options": [], + "volume": [] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInVwZGF0ZSI6MTgwMDAwMDAwMDAwMH19", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router" + ] + } + ] + }, + { + "mode": "managed", + "type": "openstack_networking_floatingip_v2", + "name": "wp_ai4securesociety_ip", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "address": "146.48.30.89", + "all_tags": [], + "description": "Wordpress for the SobigData summer school 2024 ai4securesociety initiative", + "dns_domain": "", + "dns_name": "", + "fixed_ip": "", + "id": "4d2a8c7b-7570-496b-b0b2-9b9b683b43df", + "pool": "external-network", + "port_id": "", + "region": "isti_area_pi_1", + "subnet_id": null, + "subnet_ids": null, + "tags": null, + "tenant_id": "d6757d56e6e54ffe83a9701cc92af4c2", + "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 SobigData summer school 2024 ai4securesociety initiative", + "disable_status_check": false, + "id": "9d29d051-9567-4af4-9ffe-87eb643fc90b/a3d840e0-6f16-4c90-b21f-118f962ee965", + "name": "phpadmin-ai4securesociety.kdd.cloud.isti.cnr.it.", + "project_id": "d6757d56e6e54ffe83a9701cc92af4c2", + "records": [ + "ai4securesociety.kdd.cloud.isti.cnr.it." + ], + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "CNAME", + "value_specs": null, + "zone_id": "9d29d051-9567-4af4-9ffe-87eb643fc90b" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router", + "openstack_networking_floatingip_v2.wp_ai4securesociety_ip" + ] + }, + { + "index_key": "wp", + "schema_version": 0, + "attributes": { + "description": "Wordpress for the SobigData summer school 2024 ai4securesociety initiative", + "disable_status_check": false, + "id": "9d29d051-9567-4af4-9ffe-87eb643fc90b/0a4c038b-0630-4691-9f3e-4c4d10a42174", + "name": "ai4securesociety.kdd.cloud.isti.cnr.it.", + "project_id": "d6757d56e6e54ffe83a9701cc92af4c2", + "records": [ + "146.48.30.89" + ], + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "A", + "value_specs": null, + "zone_id": "9d29d051-9567-4af4-9ffe-87eb643fc90b" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router", + "openstack_networking_floatingip_v2.wp_ai4securesociety_ip" + ] + } + ] + } + ], + "check_results": null +}