kandra: Pull instance storage device from nvme information.

This commit is contained in:
Alex Vandiver 2024-03-29 03:39:44 +00:00 committed by Tim Abbott
parent 87dee7a9b2
commit 93c6fd4746
2 changed files with 16 additions and 8 deletions

View File

@ -1,12 +1,21 @@
#!/bin/sh
#!/bin/bash
set -x
set -e
# This file only exists on the server, ignore its non-existence locally
# shellcheck disable=SC1091
. "/sys/dev/block/259:0/uevent"
set -o pipefail
LOCALDISK=$(
nvme list -o json \
| jq -r '.Devices[] | select(.ModelNumber | contains("Instance Storage")) | .DevicePath' \
| head -n1
)
if [ -z "$LOCALDISK" ]; then
echo "No instance storage found!"
nvme list
exit 1
fi
LOCALDISK="/dev/$DEVNAME"
if ! grep -q "$LOCALDISK" /etc/fstab; then
echo "$LOCALDISK /srv xfs nofail,noatime 1 1" >>/etc/fstab
fi

View File

@ -4,8 +4,7 @@ class kandra::profile::postgresql inherits kandra::profile::base {
include kandra::teleport::db
include kandra::prometheus::postgresql
$common_packages = ['xfsprogs']
package { $common_packages: ensure => installed }
package { ['xfsprogs', 'nvme-cli']: ensure => installed }
kandra::firewall_allow{ 'postgresql': }
@ -27,7 +26,7 @@ class kandra::profile::postgresql inherits kandra::profile::base {
}
exec { 'setup_disks':
command => '/root/setup_disks.sh',
require => Package["postgresql-${zulip::postgresql_common::version}", 'xfsprogs'],
require => Package["postgresql-${zulip::postgresql_common::version}", 'xfsprogs', 'nvme-cli'],
unless => 'test /var/lib/postgresql/ -ef /srv/postgresql/',
}