main #2

Merged
andrea.dellamico merged 3 commits from francesco.mangiacrapa/infrastructure-as-code:main into main 2023-11-24 18:28:01 +01:00
5 changed files with 37 additions and 11 deletions

5
.gitignore vendored
View File

@ -37,3 +37,8 @@ terraform.rc
# output plans
*-plan.zip
# Ignore ssh_key_file_ref
**/ssh-key-ref-outputs.tf

View File

@ -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"
}

View File

@ -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

View File

@ -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")
}