diff --git a/examples/poc/sonar_hadr_deployment/main.tf b/examples/poc/sonar_hadr_deployment/main.tf index 8337afe0c..822261724 100644 --- a/examples/poc/sonar_hadr_deployment/main.tf +++ b/examples/poc/sonar_hadr_deployment/main.tf @@ -106,6 +106,7 @@ module "hub_main" { allowed_hub_cidrs = [data.aws_subnet.dr_hub.cidr_block] allowed_agentless_gw_cidrs = [data.aws_subnet.main_gw.cidr_block, data.aws_subnet.dr_gw.cidr_block] allowed_all_cidrs = local.workstation_cidr + base_directory = var.sonar_machine_base_directory tags = local.tags depends_on = [ module.vpc @@ -135,6 +136,7 @@ module "hub_dr" { allowed_hub_cidrs = [data.aws_subnet.main_hub.cidr_block] allowed_agentless_gw_cidrs = [data.aws_subnet.main_gw.cidr_block, data.aws_subnet.dr_gw.cidr_block] allowed_all_cidrs = local.workstation_cidr + base_directory = var.sonar_machine_base_directory tags = local.tags depends_on = [ module.vpc @@ -165,6 +167,7 @@ module "agentless_gw_main" { proxy_private_ssh_key_path = module.key_pair.private_key_file_path proxy_ssh_user = module.hub_main.ssh_user } + base_directory = var.sonar_machine_base_directory tags = local.tags depends_on = [ module.vpc @@ -198,6 +201,7 @@ module "agentless_gw_dr" { proxy_private_ssh_key_path = module.key_pair.private_key_file_path proxy_ssh_user = module.hub_main.ssh_user } + base_directory = var.sonar_machine_base_directory tags = local.tags depends_on = [ module.vpc diff --git a/examples/poc/sonar_hadr_deployment/variables.tf b/examples/poc/sonar_hadr_deployment/variables.tf index 498259c2b..e83c92fee 100644 --- a/examples/poc/sonar_hadr_deployment/variables.tf +++ b/examples/poc/sonar_hadr_deployment/variables.tf @@ -153,3 +153,9 @@ variable "db_types_to_onboard" { error_message = "Valid values should contain at least one of the following: 'RDS MySQL', 'RDS MsSQL'." } } + +variable "sonar_machine_base_directory" { + type = string + default = "/imperva" + description = "The base directory where all Sonar related directories will be installed" +} diff --git a/modules/aws/agentless-gw/main.tf b/modules/aws/agentless-gw/main.tf index 9a4445627..017491bd3 100644 --- a/modules/aws/agentless-gw/main.tf +++ b/modules/aws/agentless-gw/main.tf @@ -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 } diff --git a/modules/aws/agentless-gw/variables.tf b/modules/aws/agentless-gw/variables.tf index d1f2632b7..79ef2d78a 100644 --- a/modules/aws/agentless-gw/variables.tf +++ b/modules/aws/agentless-gw/variables.tf @@ -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" -} \ No newline at end of file +} + +variable "base_directory" { + type = string + default = "/imperva" + description = "The base directory where all Sonar related directories will be installed" +} diff --git a/modules/aws/hub/main.tf b/modules/aws/hub/main.tf index e61f85e19..0e223a6f0 100644 --- a/modules/aws/hub/main.tf +++ b/modules/aws/hub/main.tf @@ -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 -} \ No newline at end of file + base_directory = var.base_directory +} diff --git a/modules/aws/hub/variables.tf b/modules/aws/hub/variables.tf index dedcce719..c873d1f3d 100644 --- a/modules/aws/hub/variables.tf +++ b/modules/aws/hub/variables.tf @@ -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" -} \ No newline at end of file +} + +variable "base_directory" { + type = string + default = "/imperva" + description = "The base directory where all Sonar related directories will be installed" +} diff --git a/modules/aws/sonar-base-instance/setup.tftpl b/modules/aws/sonar-base-instance/setup.tftpl index aa5040618..b5ade92f4 100644 --- a/modules/aws/sonar-base-instance/setup.tftpl +++ b/modules/aws/sonar-base-instance/setup.tftpl @@ -134,7 +134,7 @@ function attach_disk() { echo "/dev/$DEVICE is not lvm memeber (\"$FS\"). Formatting it..." create_lvm /dev/$DEVICE fi - + mount -a } @@ -258,11 +258,18 @@ __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 +base_directory="${base_directory:-}" +if [ -z "$base_directory" ]; then + DATA_DIR=/data + LOGS_DIR=/logs + LOCAL_DIR=/local + APPS_DIR=/apps +else + DATA_DIR="$base_directory/data" + LOGS_DIR="$base_directory/logs" + LOCAL_DIR="$base_directory/local" + APPS_DIR="$base_directory/apps" +fi install_deps create_users_and_groups @@ -278,4 +285,4 @@ fi set_environment_vars install_ssh_keys -install_access_tokens \ No newline at end of file +install_access_tokens diff --git a/modules/aws/sonar-base-instance/userdata.tf b/modules/aws/sonar-base-instance/userdata.tf index 91ddba1a7..488c7fe64 100644 --- a/modules/aws/sonar-base-instance/userdata.tf +++ b/modules/aws/sonar-base-instance/userdata.tf @@ -20,6 +20,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 = var.base_directory }) } diff --git a/modules/aws/sonar-base-instance/variables.tf b/modules/aws/sonar-base-instance/variables.tf index 1e876bb3e..658ee9c6c 100644 --- a/modules/aws/sonar-base-instance/variables.tf +++ b/modules/aws/sonar-base-instance/variables.tf @@ -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" -} \ No newline at end of file +} + +variable "base_directory" { + type = string + default = "/imperva" + description = "The base directory where all Sonar related directories will be installed" +}