Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

kandra: Create a tmp mountpoint for frontend hosts.

Alex Vandiver2a9b7f132bb4
diff --git a/puppet/kandra/manifests/app_frontend.pp b/puppet/kandra/manifests/app_frontend.pp
index 98bf95e309d..92ab2e32b14 100644
--- a/puppet/kandra/manifests/app_frontend.pp
+++ b/puppet/kandra/manifests/app_frontend.pp
@@ -6,6 +6,7 @@ class kandra::app_frontend {
include zulip::local_mailserver
include zulip::hooks::sentry
include kandra::app_frontend_monitoring
+ include kandra::app_frontend_tmpfs
kandra::firewall_allow{ 'smtp': }
kandra::firewall_allow{ 'http': }
diff --git a/puppet/kandra/manifests/app_frontend_tmpfs.pp b/puppet/kandra/manifests/app_frontend_tmpfs.pp
new file mode 100644
index 00000000000..5a6e8323b8a
--- /dev/null
+++ b/puppet/kandra/manifests/app_frontend_tmpfs.pp
@@ -0,0 +1,36 @@
+class kandra::app_frontend_tmpfs {
+ $disk = '/dev/nvme1n1'
+ $partition = "${disk}p1"
+
+ exec { 'create partition table':
+ command => "/usr/sbin/parted -s ${disk} mklabel gpt",
+ unless => "/usr/sbin/blkid -s PTUUID ${disk}",
+ }
+
+ exec { 'create partition':
+ command => "/usr/sbin/parted -a optimal -s ${disk} mkpart slack-tmp ext4 0% 100%",
+ unless => "/usr/sbin/blkid ${partition}",
+ require => Exec['create partition table'],
+ }
+
+ exec { 'format partition':
+ command => "/sbin/mkfs.ext4 -L slack-tmp ${partition}",
+ unless => "/sbin/blkid -t TYPE=ext4 ${partition}",
+ require => Exec['create partition'],
+ }
+
+ file { '/tmp/slack-conversions':
+ ensure => 'directory',
+ mode => '0755',
+ owner => 'root',
+ group => 'root',
+ }
+ mount { '/tmp/slack-conversions':
+ ensure => 'mounted',
+ device => $partition,
+ fstype => 'ext4',
+ atboot => true,
+ options => 'defaults,noatime,discard,commit=60,errors=remount-ro',
+ require => Exec['format partition'],
+ }
+}
diff --git a/tools/setup/install-aws-server b/tools/setup/install-aws-server
index cd7f3209d64..ea7f519ab92 100755
--- a/tools/setup/install-aws-server
+++ b/tools/setup/install-aws-server
@@ -128,6 +128,15 @@ if [ "$EXISTING_RECORDS" != "0" ]; then
exit 1
fi
+DEVICES+=(
+ "DeviceName=/dev/sda1,Ebs={VolumeSize=$DISK_SIZE,VolumeType=gp3,Throughput=125,Iops=3000,Encrypted=true}"
+)
+if [[ "$ROLES" == *"frontend"* ]]; then
+ DEVICES+=(
+ "DeviceName=/dev/sdf,Ebs={VolumeSize=100,VolumeType=gp3,Throughput=125,Iops=3000,Encrypted=true,DeleteOnTermination=True}"
+ )
+fi
+
# https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
EXTRA_ARGS+=(
--iam-instance-profile "Name=\"$IAM_PROFILE\""
@@ -136,7 +145,7 @@ EXTRA_ARGS+=(
--security-group-ids "${SECURITY_GROUPS[@]}"
--monitoring Enabled=true
--placement "AvailabilityZone=$AZ"
- --block-device-mappings "DeviceName=/dev/sda1,Ebs={VolumeSize=$DISK_SIZE,VolumeType=gp3,Throughput=125,Iops=3000,Encrypted=true}"
+ --block-device-mappings "${DEVICES[@]}"
--metadata-options "InstanceMetadataTags=enabled"
)
@@ -199,9 +208,26 @@ EOF
$AWS route53 change-resource-record-sets --hosted-zone-id "$AWS_ZONE_ID" --change-batch "file://$ROUTE53_CHANGES"
rm "$ROUTE53_CHANGES"
-VOLUME_ID=$(echo "$INSTANCE_DATA" | jq -r .Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId)
+# Add the name to the root volume
+VOLUME_ID=$(
+ echo "$INSTANCE_DATA" | jq -r \
+ '.Reservations[0].Instances[0].BlockDeviceMappings[]
+ | select(.DeviceName == "/dev/sda1")
+ | .Ebs.VolumeId'
+)
$AWS ec2 create-tags --resources "$VOLUME_ID" --tags "Key=Name,Value=$SERVER root"
+# Add volume name to tmp volume
+if [[ "$ROLES" == *"frontend"* ]]; then
+ VOLUME_ID=$(
+ echo "$INSTANCE_DATA" | jq -r \
+ '.Reservations[0].Instances[0].BlockDeviceMappings[]
+ | select(.DeviceName == "/dev/sdf")
+ | .Ebs.VolumeId'
+ )
+ $AWS ec2 create-tags --resources "$VOLUME_ID" --tags "Key=Name,Value=$SERVER tmp"
+fi
+
set +x
echo
echo