Skip to content

Commit

Permalink
Merge pull request #281 from imperva/set_custom_base_directory
Browse files Browse the repository at this point in the history
Set custom base directory
  • Loading branch information
assaf13 authored Oct 16, 2023
2 parents 2feb44c + 1209061 commit 9657395
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 11 deletions.
4 changes: 4 additions & 0 deletions examples/installation/dsf_single_account_deployment/sonar.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module "hub_main" {
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
base_directory = var.sonar_machine_base_directory
mx_details = var.enable_dam ? [for mx in module.mx : {
name = mx.display_name
address = coalesce(mx.public_dns, mx.private_dns)
Expand Down Expand Up @@ -92,6 +93,7 @@ module "hub_dr" {
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
base_directory = var.sonar_machine_base_directory
generate_access_tokens = true
tags = local.tags
providers = {
Expand Down Expand Up @@ -156,6 +158,7 @@ module "agentless_gw_main" {
sonarw_private_key_secret_name = var.sonarw_gw_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_gw_public_key_file_path)), null)
instance_profile_name = var.agentless_gw_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
providers = {
aws = aws.provider-2
Expand Down Expand Up @@ -197,6 +200,7 @@ module "agentless_gw_dr" {
sonarw_private_key_secret_name = var.sonarw_gw_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_gw_public_key_file_path)), null)
instance_profile_name = var.agentless_gw_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
providers = {
aws = aws.provider-2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ variable "sonarw_gw_public_key_file_path" {
description = "The Agentless Gateway sonarw user public key file path - used for remote Agentless Gateway federation, HADR, etc."
}

variable "sonar_machine_base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}

##############################
#### DAM variables ####
##############################
Expand Down
4 changes: 4 additions & 0 deletions examples/installation/sonar_multi_account_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ module "hub_main" {
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
providers = {
aws = aws.hub-main
Expand Down Expand Up @@ -173,6 +174,7 @@ module "hub_dr" {
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
providers = {
aws = aws.hub-dr
Expand Down Expand Up @@ -210,6 +212,7 @@ module "agentless_gw_main" {
sonarw_private_key_secret_name = var.sonarw_gw_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_gw_public_key_file_path)), null)
instance_profile_name = var.gw_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
providers = {
aws = aws.gw-main
Expand Down Expand Up @@ -250,6 +253,7 @@ module "agentless_gw_dr" {
sonarw_private_key_secret_name = var.sonarw_gw_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_gw_public_key_file_path)), null)
instance_profile_name = var.gw_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
providers = {
aws = aws.gw-dr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,9 @@ variable "sonarw_gw_public_key_file_path" {
default = null
description = "The Agentless Gateway sonarw user public key file path - used for remote Agentless Gateway federation, HADR, etc."
}

variable "sonar_machine_base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}
3 changes: 3 additions & 0 deletions examples/installation/sonar_single_account_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module "hub_main" {
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
}

Expand Down Expand Up @@ -130,6 +131,7 @@ module "hub_dr" {
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
}

Expand Down Expand Up @@ -163,6 +165,7 @@ module "agentless_gw" {
sonarw_private_key_secret_name = var.sonarw_gw_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_gw_public_key_file_path)), null)
instance_profile_name = var.gw_instance_profile_name
base_directory = var.sonar_machine_base_directory
tags = local.tags
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,9 @@ variable "use_hub_as_proxy" {
default = true
description = "Whether to use the DSF Hub as a proxy for ssh into the Agentless Gateways"
}

variable "sonar_machine_base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}
1 change: 1 addition & 0 deletions modules/aws/agentless-gw/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ module "gw_instance" {
sonarw_public_key_content = var.sonarw_public_key_content
volume_attachment_device_name = var.volume_attachment_device_name
tags = var.tags
base_directory = var.base_directory
}
8 changes: 7 additions & 1 deletion modules/aws/agentless-gw/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,10 @@ variable "volume_attachment_device_name" {
type = string
default = null
description = "The device name to expose to the instance for the ebs volume. Keep null if you have no preference"
}
}

variable "base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}
3 changes: 2 additions & 1 deletion modules/aws/hub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ module "hub_instance" {
sonarw_public_key_content = var.sonarw_public_key_content
volume_attachment_device_name = var.volume_attachment_device_name
tags = var.tags
}
base_directory = var.base_directory
}
8 changes: 7 additions & 1 deletion modules/aws/hub/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,10 @@ variable "volume_attachment_device_name" {
type = string
default = null
description = "The device name to expose to the instance for the ebs volume. Keep null if you have no preference"
}
}

variable "base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}
13 changes: 6 additions & 7 deletions modules/aws/sonar-base-instance/setup.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function attach_disk() {
echo "/dev/$DEVICE is not lvm memeber (\"$FS\"). Formatting it..."
create_lvm /dev/$DEVICE
fi

mount -a
}

Expand Down Expand Up @@ -258,11 +258,10 @@ __EOF__
fi
}

STATE_DIR=/imperva
DATA_DIR=$STATE_DIR/data
LOGS_DIR=$STATE_DIR/logs
LOCAL_DIR=$STATE_DIR/local
APPS_DIR=$STATE_DIR/apps
DATA_DIR="${base_directory}/data"
LOGS_DIR="${base_directory}/logs"
LOCAL_DIR="${base_directory}/local"
APPS_DIR="${base_directory}/apps"

install_deps
create_users_and_groups
Expand All @@ -278,4 +277,4 @@ fi

set_environment_vars
install_ssh_keys
install_access_tokens
install_access_tokens
2 changes: 2 additions & 0 deletions modules/aws/sonar-base-instance/userdata.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ locals {

instance_address = var.use_public_ip ? local.public_ip : local.private_ip
display_name = var.name
sonar_base_directory = var.base_directory != null ? var.base_directory : ""

script_path = var.terraform_script_path_folder == null ? null : (join("/", [var.terraform_script_path_folder, "terraform_%RAND%.sh"]))
install_script = templatefile("${path.module}/setup.tftpl", {
Expand All @@ -20,6 +21,7 @@ locals {
jsonar_uuid = random_uuid.jsonar_uuid.result
additional_install_parameters = var.additional_install_parameters
access_tokens_array = local.access_tokens_array
base_directory = local.sonar_base_directory
})
}

Expand Down
8 changes: 7 additions & 1 deletion modules/aws/sonar-base-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,10 @@ variable "volume_attachment_device_name" {
type = string
default = null
description = "The device name to expose to the instance for the ebs volume. Keep null if you have no preference"
}
}

variable "base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}

0 comments on commit 9657395

Please sign in to comment.