forked from 45Drives/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-ceph-mon
48 lines (39 loc) · 1.26 KB
/
add-ceph-mon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
OS=$(cat /etc/os-release | grep -w NAME)
if [ "$OS" == 'NAME="Rocky Linux"' ] ; then
dnf install ceph-mon
elif [ "$OS" == 'NAME="Ubuntu"' ]; then
apt install ceph-mon
else
echo "OS is not Ubuntu or Rocky Linux"
exit
fi
# Prompt for ceph.conf and keyring
while true; do
read -p "Is the /etc/ceph/ceph.conf file and the admin keyring on this host (yes/no): " response
if [[ "$response" == "no" ]]; then
echo "Exiting..."
exit 0
elif [[ "$response" == "yes" ]]; then
echo "Continuing..."
break
else
echo "Invalid response. Please enter 'yes' or 'no'."
fi
done
# Create Keyring Directory and make Keyring
echo "Creating Keyring"
mkdir /var/lib/ceph/mon/ceph-$(hostname -s)
ceph auth get mon. -o /tmp/key-$(hostname -s)
ceph mon getmap -o /tmp/map-$(hostname -s)
ceph-mon -i $(hostname -s) --mkfs --monmap /tmp/map-$(hostname -s) --keyring /tmp/key-$(hostname -s)
chown -R ceph:ceph /var/lib/ceph/mon/ceph-$(hostname -s)
# Open Firewall ports
echo "Opening Firewall"
firewall-cmd --add-service={ceph,ceph-mon} --permanent
firewall-cmd --reload
# Start MON Service
echo "Starting MON service"
systemctl enable --now ceph-mon@$(hostname -s)
ceph -s
echo -e "\e[1;31mmon-$(hostname -s)\e[0m has been \e[1;32madded\e[0m"