forked from batrick/ceph-linode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·102 lines (86 loc) · 2.5 KB
/
launch.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
98
99
100
101
102
#!/bin/bash
set -ex
# may be necessary for ansible with >25 forks
ulimit -n 65536 || true
source "$(dirname "$0")/ansible-env.bash"
CEPH_ANSIBLE=~/ceph-ansible/
NUKE=0
LOG=launch.log
YML="$(dirname "$0")/linode.yml"
RETRY="${YML%.*}.retry"
function main {
if [ "$NUKE" -gt 0 ]; then
time python2 "$(dirname "$0")/linode-nuke.py"
fi
if [ "$NUKE" -gt 0 -o ! -f ansible_inventory ]; then
time python2 "$(dirname "$0")/linode-launch.py"
fi
# wait for Linodes to finish booting
time python2 "$(dirname "$0")/linode-wait.py"
do_playbook --limit=all "$(dirname "$0")/pre-config.yml"
if [ "$NUKE" -gt 0 ]; then
# /dev/sdc is sometimes not wiped after linode-nuke.py
# (Linode wipes deleted disks on a schedule rather than immediately.)
ans --module-name=shell --args='wipefs -a /dev/sdc' osds
fi
if [ ! -d $CEPH_ANSIBLE/roles ] ; then
echo "skipping ceph-ansible run"
# Sometimes we hit transient errors, so retry until it works!
elif ! do_playbook --limit=all "$YML"; then
# Always include the mons because we need their statistics to generate ceph.conf
printf 'mons\nmgrs\n' >> "$RETRY"
do_playbook --limit=@"${RETRY}" "$YML"
rm -f -- "${RETRY}"
fi
}
ARGUMENTS='--options c:,h,n,l: --long ceph-ansible:,help,nuke,log:'
NEW_ARGUMENTS=$(getopt $ARGUMENTS -- "$@")
eval set -- "$NEW_ARGUMENTS"
function usage {
printf "%s: [--ceph-ansible path] [--nuke] [--log path]\n" "$0"
}
while [ "$#" -ge 0 ]; do
case "$1" in
-c|--ceph-ansible)
shift
CEPH_ANSIBLE="$1"
shift
;;
-h|--help)
usage
exit
;;
-n|--nuke)
NUKE=1
shift
;;
-l|--log)
shift
LOG="$1"
shift
;;
--)
shift
break
;;
esac
done
export CEPH_ANSIBLE
# Don't output the API KEY
set +x
if [ -z "$LINODE_API_KEY" ]; then
printf "Specify the Linode API key using the LINODE_API_KEY environment variable.\n"
exit 1
fi
set -x
if ! [ -d "$CEPH_ANSIBLE"/roles ]; then
printf "Cannot find ceph-ansible environment, please specify the path to ceph-ansible. (current: %s)\n" "$CEPH_ANSIBLE"
fi
cat > ansible.cfg <<EOF
# Managed by launch.sh, do not modify!
[defaults]
action_plugins = ${CEPH_ANSIBLE}/plugins/actions
library = ${CEPH_ANSIBLE}/library
roles_path = ${CEPH_ANSIBLE}/roles
EOF
main |& tee -a "$LOG"