forked from fultonj/tripleo-ceph-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect_osp_ceph.sh
executable file
·61 lines (53 loc) · 2.46 KB
/
connect_osp_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
#!/usr/bin/env bash
# Filename: connect_osp_ceph.sh
# Description: Connects HCI OSP to Ceph
# Supported Langauge(s): bash-4.2.x & ansible-1.9.x
# Time-stamp: <2017-02-11 19:31:29 jfulton>
# -------------------------------------------------------
# This script only needs to be run once during initial deployment
# Restarts glance, cinder, nova so they repoll the new ceph cluster
# -------------------------------------------------------
# HARD CODED VARIABLES
inventory_file=/etc/ansible/hosts
# -------------------------------------------------------
# SAFETY CHECKS
test "$(whoami)" != 'stack' && (echo "This must be run by the stack user on the undercloud"; exit 1)
mon=$(grep mons $inventory_file -A 1 | tail -1 | awk {'print $1'})
if [[ -z $mon ]]; then
echo "No host under [mons] in $inventory_file. Exiting. "
exit 1
fi
if ! hash ansible 2>/dev/null; then
echo "Cannot find ansible command. Exiting. "
exit 1
fi
# -------------------------------------------------------
# RESTART OPENSTACK SERVICES
PCS=0
if [ $PCS -eq 1 ]; then
echo "Restarting Glance (with Pacemaker)"
ansible $mon -b -m shell -a "pcs resource disable openstack-glance-api-clone"
ansible $mon -b -m shell -a "pcs status | grep -A 2 glance-api"
ansible $mon -b -m shell -a "pcs resource enable openstack-glance-api-clone"
ansible $mon -b -m shell -a "pcs status | grep -A 2 glance-api"
echo "Restarting Cinder (with Pacemaker)"
ansible $mon -b -m shell -a "pcs resource disable openstack-cinder-volume "
ansible $mon -b -m shell -a "pcs status | grep -A 2 openstack-cinder-volume "
ansible $mon -b -m shell -a "pcs resource enable openstack-cinder-volume "
ansible $mon -b -m shell -a "pcs status | grep -A 2 openstack-cinder-volume "
else
declare -a svcs=(openstack-cinder-volume.service openstack-glance-api.service)
declare -a states=(status restart)
for svc in "${svcs[@]}"; do
for state in "${states[@]}"; do
ansible $mon -b -m shell -a "systemctl $state $svc"
done
done
fi
echo "Restarting Nova-Compute on all compute nodes (with Systemd)"
ansible osds -b -m shell -a "systemctl status openstack-nova-compute.service "
ansible osds -b -m shell -a "systemctl restart openstack-nova-compute.service "
ansible osds -b -m shell -a "systemctl status openstack-nova-compute.service "
# -------------------------------------------------------
echo "The overcloud should be ready to use. Please test. "
exit 0