diff --git a/.gitignore b/.gitignore index faaf717e..09277b03 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,8 @@ terraform.rc # output plans *-plan.zip + + +# Ignore ssh_key_file_ref +**/ssh-key-ref-outputs.tf + diff --git a/openstack-tf/d4s-dev/geoserver/geoserver.zip b/openstack-tf/d4s-dev/geoserver/geoserver.zip deleted file mode 100644 index 8b6690f1..00000000 Binary files a/openstack-tf/d4s-dev/geoserver/geoserver.zip and /dev/null differ diff --git a/openstack-tf/modules/common_variables/variables.tf b/openstack-tf/modules/common_variables/variables.tf index 2ed0fcd6..7ed8c057 100644 --- a/openstack-tf/modules/common_variables/variables.tf +++ b/openstack-tf/modules/common_variables/variables.tf @@ -61,14 +61,6 @@ variable "networks_with_d4s_services" { } } -variable "ssh_key_file" { - type = map(string) - default = { - file = "~/.ssh/privateKeySsh" - name = "francescomangiacrapa" - } -} - variable "ubuntu_1804" { type = map(string) @@ -185,3 +177,31 @@ variable "smartexecutor_addresses" { default = { } } + + +# Added by Francesco +# Create in the path 'modules/ssh-key-ref' the file 'ssh-key-ref-outputs.tf' +# with the following outputs: + +# output "ssh_key_file" { +# value = "~/.ssh/{YOUR_PRIVATE_KEYNAME}" +# sensitive = true +# } + +# output "ssh_key_name" { +# value = "{YOUR_KEYNAME}" +# sensitive = false +# } + +# Then you can use above outputs in your 'file.tf' (if it contains the soft link to variables.tf) as: +# module.ssh_settings.ssh_key_file +# module.ssh_settings.ssh_key_name + +# e.g. +# +# resource "openstack_compute_instance_v2" "geoserver" { +# key_pair = module.ssh_settings.ssh_key_name + +module "ssh_settings" { + source = "../../modules/ssh-key-ref" +} diff --git a/openstack-tf/modules/geoserver/geoserver.tf b/openstack-tf/modules/geoserver/geoserver.tf index a6a1433c..45dff344 100644 --- a/openstack-tf/modules/geoserver/geoserver.tf +++ b/openstack-tf/modules/geoserver/geoserver.tf @@ -1,3 +1,4 @@ + # Geoserver attached volume - used for 'geoserver_data' resource "openstack_blockstorage_volume_v3" "geoserver_data_vol" { name = var.geoserver_basic_data.vol_data_name @@ -9,7 +10,7 @@ resource "openstack_compute_instance_v2" "geoserver" { name = var.geoserver_basic.name availability_zone_hints = var.availability_zones_names.availability_zone_no_gpu flavor_name = var.geoserver_basic.flavor - key_pair = var.ssh_key_file.name + key_pair = module.ssh_settings.ssh_key_name security_groups = [var.security_group_list.default, var.security_group_list.http_and_https_from_the_load_balancers] block_device { uuid = var.ubuntu_1804.uuid diff --git a/openstack-tf/modules/ssh_keys/ssh-keys.tf b/openstack-tf/modules/ssh_keys/ssh-keys.tf index 662d992b..dca6c183 100644 --- a/openstack-tf/modules/ssh_keys/ssh-keys.tf +++ b/openstack-tf/modules/ssh_keys/ssh-keys.tf @@ -1,4 +1,4 @@ resource "openstack_compute_keypair_v2" "initial_ssh_key" { - name = var.ssh_key_file.name - public_key = "${file("${var.ssh_key_file.file}.pub")}" + name = var.ssh_key_file.name + public_key = file("${var.ssh_key_file.file}.pub") }