From 01fa08102f5418ac5811a4b601b38a4bd5e895f3 Mon Sep 17 00:00:00 2001 From: Greg O <84852800+GrzesiekO@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:04:18 +0200 Subject: [PATCH] chore: update p4_configure.sh and module configs for Helix Core Updated the p4_configure.sh script to include a new function that appends the newly mounted EBS volumes or FSx mount points to the /etc/fstab file. This ensures the mounts persist across reboots. Also made some minor updates to the Terraform module configurations for the Helix Core resources to align with the script changes. --- assets/packer/perforce/helix-core/p4_configure.sh | 12 +++++++++++- modules/perforce/helix-core/data.tf | 4 ++-- modules/perforce/helix-core/main.tf | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/assets/packer/perforce/helix-core/p4_configure.sh b/assets/packer/perforce/helix-core/p4_configure.sh index 9ee70ca8..313bdfc9 100644 --- a/assets/packer/perforce/helix-core/p4_configure.sh +++ b/assets/packer/perforce/helix-core/p4_configure.sh @@ -158,14 +158,24 @@ perform_operations() { mount_fs_or_ebs() { local mount_point=$1 local dest_dir=$2 + local mount_options="" + local fs_type="" + if is_fsx_mount "$mount_point"; then # Mount as FSx mount -t nfs -o nconnect=16,rsize=1048576,wsize=1048576,timeo=600 "$mount_point" "$dest_dir" + mount_options="nfs nconnect=16,rsize=1048576,wsize=1048576,timeo=600" + fs_type="nfs" else # Mount as EBS the called function also creates XFS on EBS - prepare_ebs_volume "$mount_point" "$dest_dir" + + mount_options="defaults" + fs_type="xfs" + fi + # Adding appending to the fstab so mounts persist across reboots. + echo "$mount_point $dest_dir $fs_type $mount_options 0 0" >> /etc/fstab } # Create temporary directories and mount diff --git a/modules/perforce/helix-core/data.tf b/modules/perforce/helix-core/data.tf index e844a7d5..1816611c 100644 --- a/modules/perforce/helix-core/data.tf +++ b/modules/perforce/helix-core/data.tf @@ -5,12 +5,12 @@ data "aws_subnet" "instance_subnet" { # Fetching custom Perforce Helix Core AMI data "aws_ami" "helix_core_ami" { most_recent = true - name_regex = "p4_rocky_linux-*" + name_regex = "p4_al2023-*" owners = ["self"] filter { name = "name" - values = ["p4_rocky_linux-*"] + values = ["p4_al2023-*"] } filter { diff --git a/modules/perforce/helix-core/main.tf b/modules/perforce/helix-core/main.tf index cd1a3837..dd8f707b 100644 --- a/modules/perforce/helix-core/main.tf +++ b/modules/perforce/helix-core/main.tf @@ -35,7 +35,7 @@ resource "aws_instance" "helix_core_instance" { user_data = <<-EOT #!/bin/bash - /home/rocky/p4_configure.sh /dev/sdf /dev/sdg /dev/sdh \ + /home/ec2-user/gpic_scripts/p4_configure.sh /dev/sdf /dev/sdg /dev/sdh \ ${var.server_type} \ ${var.helix_core_super_user_username_secret_arn == null ? awscc_secretsmanager_secret.helix_core_super_user_username[0].secret_id : var.helix_core_super_user_username_secret_arn} \ ${var.helix_core_super_user_password_secret_arn == null ? awscc_secretsmanager_secret.helix_core_super_user_password[0].secret_id : var.helix_core_super_user_password_secret_arn} \