From 93c6fd47463a8381006b3e0a7f05ece263991a79 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 29 Mar 2024 03:39:44 +0000 Subject: [PATCH] kandra: Pull instance storage device from nvme information. --- puppet/kandra/files/postgresql/setup_disks.sh | 19 ++++++++++++++----- puppet/kandra/manifests/profile/postgresql.pp | 5 ++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/puppet/kandra/files/postgresql/setup_disks.sh b/puppet/kandra/files/postgresql/setup_disks.sh index 2eb6583856..6e4d42fd31 100755 --- a/puppet/kandra/files/postgresql/setup_disks.sh +++ b/puppet/kandra/files/postgresql/setup_disks.sh @@ -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 diff --git a/puppet/kandra/manifests/profile/postgresql.pp b/puppet/kandra/manifests/profile/postgresql.pp index 2a7b1cfdf0..d3f73b99a0 100644 --- a/puppet/kandra/manifests/profile/postgresql.pp +++ b/puppet/kandra/manifests/profile/postgresql.pp @@ -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/', }