Skip to content

Commit

Permalink
Allow user to set a custom Sonar base directory. The user can also se…
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf13 committed Oct 12, 2023
1 parent 790f1ac commit e60150b
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 11 deletions.
4 changes: 4 additions & 0 deletions examples/poc/sonar_hadr_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions examples/poc/sonar_hadr_deployment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
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"
}
21 changes: 14 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,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
Expand All @@ -278,4 +285,4 @@ fi

set_environment_vars
install_ssh_keys
install_access_tokens
install_access_tokens
1 change: 1 addition & 0 deletions modules/aws/sonar-base-instance/userdata.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

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 e60150b

Please sign in to comment.