-
Notifications
You must be signed in to change notification settings - Fork 38
/
ceph.sh
executable file
·98 lines (90 loc) · 3.53 KB
/
ceph.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
# KuberDock - is a platform that allows users to run applications using Docker
# container images and create SaaS / PaaS based on these applications.
# Copyright (C) 2017 Cloud Linux INC
#
# This file is part of KuberDock.
#
# KuberDock is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# KuberDock is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with KuberDock; if not, see <http://www.gnu.org/licenses/>.
#
# Script installs CEPH-client to a node. It is obsolete now, because CEPH
# client will be installed to node automatically, during node adding to KD
# cluster.
MANAGECMD=/var/opt/kuberdock/manage.py
while [[ $# > 1 ]]; do
key="$1"
case $key in
-s|--skip-hostname-check)
SKIPHOSTNAMECHECK=YES
;;
*)
;;
esac
shift # past argument or value
done
if [[ -n $1 ]]; then
TARGET_HOST="$1"
fi
if [[ -z $TARGET_HOST ]]; then
echo "Empty hostname"
exit 1
fi
VERSION=hammer
# Check existence of the node with specified hostname in kuberdock database
# to prevent invalid (incomplete) hostnames arguments.
# Skip this checking if ceph client will be installed on host which is not
# attached as a node.
if [[ -z "$SKIPHOSTNAMECHECK" ]]; then
python $MANAGECMD node-info --nodename "$TARGET_HOST" > /dev/null 2>&1
if [[ $? != 0 ]]; then
echo "Node $TARGET_HOST not found in DB. Use -s|--skip-hostname-check flag for installing ceph client to hosts which are not attached as nodes yet."
exit 1
fi
fi
#ssh root@$TARGET_HOST -i /var/lib/nginx/.ssh/id_rsa -o "StrictHostKeyChecking no" rpm -ivh http://ceph.com/rpm-$VERSION/el7/noarch/ceph-release-1-0.el7.noarch.rpm --force
ssh root@$TARGET_HOST -i /var/lib/nginx/.ssh/id_rsa -o "StrictHostKeyChecking no" "
cat > /etc/yum.repos.d/ceph-base << EOF
http://ceph.com/rpm-$VERSION/rhel7/\\\$basearch
http://eu.ceph.com/rpm-$VERSION/rhel7/\\\$basearch
http://au.ceph.com/rpm-$VERSION/rhel7/\\\$basearch
EOF
cat > /etc/yum.repos.d/ceph.repo << EOF
[Ceph]
name=Ceph packages
#baseurl=http://ceph.com/rpm-$VERSION/rhel7/\\\$basearch
mirrorlist=file:///etc/yum.repos.d/ceph-base
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc
EOF
"
#ssh root@$TARGET_HOST -i /var/lib/nginx/.ssh/id_rsa -o "StrictHostKeyChecking no" yum --enablerepo=Ceph install -y ceph-common
CNT=1
/bin/false
while [ $? -ne 0 ]; do
echo "Trying to install CEPH-client $CNT"
((CNT++))
if [[ $CNT > 4 ]]; then
ssh root@$TARGET_HOST -i /var/lib/nginx/.ssh/id_rsa -o "StrictHostKeyChecking no" "yum --enablerepo=Ceph --nogpgcheck install -y ceph-common"
fi
ssh root@$TARGET_HOST -i /var/lib/nginx/.ssh/id_rsa -o "StrictHostKeyChecking no" "yum --enablerepo=Ceph install -y ceph-common"
done
scp -r -i /var/lib/nginx/.ssh/id_rsa -o "StrictHostKeyChecking no" /var/lib/kuberdock/conf/ceph.* root@$TARGET_HOST:/etc/ceph
if [[ -z "$SKIPHOSTNAMECHECK" ]]; then
python $MANAGECMD node-flag --nodename $TARGET_HOST --flagname ceph_installed --value true
else
python $MANAGECMD node-flag --nodename $TARGET_HOST --flagname ceph_installed --value true 2> /dev/null
fi