[ceph] find osd_id when using ceph-volume

This commit is contained in:
Nico Schottelius 2021-04-20 11:38:49 +02:00
parent 8e853e65de
commit 0031c67d65
1 changed files with 9 additions and 1 deletions

View File

@ -12,6 +12,8 @@ fi
export DEV=$1;shift
export CLASS=$1; shift
set -e
# Ensure ceph-volume has all pre-requisites
if [ ! -f /var/lib/ceph/bootstrap-osd/ceph.keyring ]; then
mkdir -p /var/lib/ceph/bootstrap-osd
@ -21,7 +23,13 @@ if [ ! -f /etc/ceph/ceph.client.bootstrap-osd.keyring ]; then
ceph auth get client.bootstrap-osd > /etc/ceph/ceph.client.bootstrap-osd.keyring
fi
ceph-volume lvm prepare --data $DEV --crush-device-class $CLASS
# We are redirecting to a tempfile so that the output is visible for debugging,
# but we can still easily filter for the osd id
tmp=$(mktemp)
ceph-volume lvm prepare --data $DEV --crush-device-class $CLASS 2>&1 | tee ${tmp}
osd_id=$(grep /var/lib/ceph/osd/ceph- ${tmp} | sed -e 's/.*ceph-//' -e 's,/.*,,' | head -n1)
rm -f ${tmp}
if [ $# -eq 1 ]; then
echo "Not executing: /opt/ungleich-tools/monit-ceph-create-start osd.${osd_id}"