Consolidate common OS installation into a script:
Move common openstack service installation operations into a new script `os-svc-install`, which simplifies the elements for openstack services. Change-Id: Ied8ac3278e7fe8af76e24748ec4e598a84afa03c
This commit is contained in:
parent
8220c00095
commit
56e50ee5cf
1
elements/glance-api/element-deps
Normal file
1
elements/glance-api/element-deps
Normal file
@ -0,0 +1 @@
|
||||
os-svc-install
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o xtrace
|
||||
|
||||
# upstart script
|
||||
cp -f $(dirname $0)/etc_init_glance-api.conf /etc/init/glance-api.conf
|
||||
|
@ -1,9 +0,0 @@
|
||||
description "OpenStack Glance API service"
|
||||
|
||||
start on (local-filesystems and net-device-up IFACE!=lo)
|
||||
stop on runlevel [016]
|
||||
|
||||
respawn
|
||||
|
||||
exec su -s /bin/sh -c "exec /opt/stack/glance/bin/glance-api --config-file /etc/glance/glance-api.conf --log-config /etc/glance/logging.conf"
|
||||
|
@ -1,32 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
# install glance-api
|
||||
|
||||
set -e
|
||||
set -o xtrace
|
||||
|
||||
install-packages \
|
||||
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
|
||||
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
|
||||
python-greenlet python-routes python-simplejson python-webob rabbitmq-server
|
||||
|
||||
OS_ROOT=/opt/stack
|
||||
mkdir -p $OS_ROOT
|
||||
|
||||
# clone source
|
||||
GLANCE_ROOT=$OS_ROOT/glance
|
||||
git clone https://github.com/openstack/glance.git $GLANCE_ROOT
|
||||
cd $GLANCE_ROOT
|
||||
git checkout master
|
||||
|
||||
# pip dependencies
|
||||
python setup.py egg_info
|
||||
pip install -r glance.egg-info/requires.txt
|
||||
cd -
|
||||
|
||||
# config
|
||||
mkdir -p /etc/glance
|
||||
cp $GLANCE_ROOT/etc/glance-api.conf /etc/glance
|
||||
cp $GLANCE_ROOT/etc/policy.json /etc/glance
|
||||
cp $GLANCE_ROOT/etc/glance-api-paste.ini /etc/glance
|
||||
cp $GLANCE_ROOT/etc/logging.cnf.sample /etc/glance/logging.conf
|
||||
os-svc-install -n glance-api -u glance -r https://github.com/openstack/glance.git -c "/opt/stack/glance/bin/glance-api"
|
||||
|
1
elements/keystone/element-deps
Normal file
1
elements/keystone/element-deps
Normal file
@ -0,0 +1 @@
|
||||
os-svc-install
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o xtrace
|
||||
|
||||
# upstart script
|
||||
cp -f $(dirname $0)/etc_init_keystone.conf /etc/init/keystone.conf
|
||||
|
@ -1,9 +0,0 @@
|
||||
description "OpenStack Keystone service"
|
||||
|
||||
start on (local-filesystems and net-device-up IFACE!=lo)
|
||||
stop on runlevel [016]
|
||||
|
||||
respawn
|
||||
|
||||
exec su -s /bin/sh -c "exec /opt/stack/keystone/bin/keystone-all"
|
||||
|
@ -1,32 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# install keystone
|
||||
|
||||
set -e
|
||||
set -o xtrace
|
||||
|
||||
install-packages \
|
||||
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
|
||||
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
|
||||
python-greenlet python-routes python-simplejson python-webob
|
||||
|
||||
OS_ROOT=/opt/stack
|
||||
mkdir -p $OS_ROOT
|
||||
|
||||
# clone source
|
||||
KEYSTONE_ROOT=$OS_ROOT/keystone
|
||||
git clone https://github.com/openstack/keystone.git $KEYSTONE_ROOT
|
||||
cd $KEYSTONE_ROOT
|
||||
git checkout master
|
||||
|
||||
# pip dependencies
|
||||
python setup.py egg_info
|
||||
pip install -r keystone.egg-info/requires.txt
|
||||
cd -
|
||||
|
||||
# config
|
||||
mkdir -p /etc/keystone
|
||||
cp $KEYSTONE_ROOT/etc/keystone.conf.sample /etc/keystone/keystone.conf
|
||||
cp $KEYSTONE_ROOT/etc/policy.json /etc/keystone
|
||||
cp $KEYSTONE_ROOT/etc/logging.conf.sample /etc/keystone/logging.conf
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
os-svc-install -n keystone -u keystone -r https://github.com/openstack/keystone.git -c "/opt/stack/keystone/bin/keystone-all"
|
||||
|
||||
|
1
elements/nova-api/element-deps
Normal file
1
elements/nova-api/element-deps
Normal file
@ -0,0 +1 @@
|
||||
os-svc-install
|
@ -1,39 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
useradd -G admin -m nova -s /bin/false
|
||||
|
||||
install-packages \
|
||||
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
|
||||
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
|
||||
python-greenlet python-routes python-simplejson python-webob rabbitmq-server
|
||||
|
||||
OS_ROOT=/opt/stack
|
||||
mkdir -p $OS_ROOT
|
||||
|
||||
# clone source
|
||||
NOVA_ROOT=$OS_ROOT/nova
|
||||
git clone https://github.com/openstack/nova.git $NOVA_ROOT
|
||||
cd $NOVA_ROOT
|
||||
git checkout master
|
||||
|
||||
# pip dependencies
|
||||
python setup.py egg_info
|
||||
pip install -r nova.egg-info/requires.txt
|
||||
cd -
|
||||
|
||||
SYS_DIRS="/etc/nova /var/log/nova $NOVA_ROOT/keys"
|
||||
for d in $SYS_DIRS; do
|
||||
mkdir -p $d
|
||||
chown nova:nova $d
|
||||
done
|
||||
|
||||
# config
|
||||
cp $NOVA_ROOT/etc/nova/nova.conf.sample /etc/nova/nova.conf
|
||||
cp $NOVA_ROOT/etc/nova/logging_sample.conf /etc/nova/logging.conf
|
||||
cp $NOVA_ROOT/etc/nova/api-paste.ini /etc/nova
|
||||
cp $NOVA_ROOT/etc/nova/policy.json /etc/nova
|
||||
|
||||
# upstart script
|
||||
cp -f $(dirname $0)/../upstart/nova-api.conf /etc/init
|
||||
os-svc-install -n nova-api -u nova -r https://github.com/openstack/nova.git -c "/opt/stack/nova/bin/nova-api"
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
description "OpenStack Nova API Service"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
setuid nova
|
||||
setgid nova
|
||||
|
||||
respawn
|
||||
|
||||
exec /opt/stack/nova/bin/nova-api
|
||||
|
||||
# wait until service is running.
|
||||
post-start script
|
||||
svc_port=$(grep ^osapi_compute_listen_port /etc/nova/nova.conf ||:)
|
||||
svc_port=${svc_port##*=}
|
||||
if [ -z "$svc_port" ] ; then
|
||||
svc_port="8774"
|
||||
fi
|
||||
|
||||
for try in $(seq 9 -1 1); do
|
||||
if nc -w 1 localhost $svc_port < /dev/null ; then
|
||||
echo Connected to port $svc_port!
|
||||
exit 0
|
||||
fi
|
||||
echo Could not connect to $svc_port, retrying $try more times...
|
||||
sleep 1
|
||||
done
|
||||
end script
|
||||
|
9
elements/os-svc-install/README.md
Normal file
9
elements/os-svc-install/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
Installs 'os-svc-install', a script to perform one-line installs of init-controlled openstack services from github.
|
||||
|
||||
|
||||
Example Usage
|
||||
--------------
|
||||
`os-svc-install -u nova -n nova-all -c 'nova-all --someoption' -r https://github.com/openstack/nova.git`
|
||||
|
||||
The above command will pip-install the repo specified by '-r', and create a service start script called nova-all (from `-n`), which starts the command specified by `-c` as user `-u`
|
||||
|
7
elements/os-svc-install/install.d/04-os-svc-install
Executable file
7
elements/os-svc-install/install.d/04-os-svc-install
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
install-packages python-pip
|
||||
|
||||
install -m 0755 -o root -g root $(dirname $0)/../os-svc-install /usr/local/bin/os-svc-install
|
||||
|
68
elements/os-svc-install/os-svc-install
Executable file
68
elements/os-svc-install/os-svc-install
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
|
||||
|
||||
function install-os-upstart() {
|
||||
local svc_name=$1
|
||||
local svc_user=$2
|
||||
local cmd=$3
|
||||
local f=/etc/init/$svc_name.conf
|
||||
|
||||
cat > $f <<EOF
|
||||
description "OpenStack $svc_name service"
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
setuid $svc_user
|
||||
|
||||
respawn
|
||||
|
||||
exec $cmd
|
||||
EOF
|
||||
}
|
||||
|
||||
function install-os-service() {
|
||||
local svc_name=$1
|
||||
local svc_user=$2
|
||||
local svc_repo=$3
|
||||
|
||||
local os_root=/opt/stack
|
||||
mkdir -p $os_root
|
||||
|
||||
id $svc_user || useradd $svc_user --system -d $os_root -s /bin/false
|
||||
|
||||
pip install --src $os_root -e git+$svc_repo#egg=$svc_name
|
||||
}
|
||||
|
||||
|
||||
function usage() {
|
||||
echo "options:"
|
||||
echo " -h show usage and exit"
|
||||
echo " -r service's git repo url"
|
||||
echo " -n service name"
|
||||
echo " -u name of the service run-as user"
|
||||
echo " -c command line to start service"
|
||||
exit 0
|
||||
}
|
||||
|
||||
while getopts r:u:c:n:h opt; do
|
||||
case "$opt" in
|
||||
u) user=$OPTARG;;
|
||||
h) usage;;
|
||||
r) repo=$OPTARG;;
|
||||
n) name=$OPTARG;;
|
||||
c) cmd=$OPTARG;;
|
||||
\?) usage;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$user" || -z "$repo" || -z "$cmd" || -z "$name" ]]; then
|
||||
echo "missing required parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install-packages python-dev python-pip git-core python-setuptools gcc libc6-dev libxml2-dev libxslt-dev
|
||||
install-os-service "$name" "$user" "$repo"
|
||||
install-os-upstart "$name" "$user" "$cmd"
|
||||
|
@ -242,4 +242,3 @@ function copy_elements_lib () {
|
||||
sudo mkdir -p $TMP_MOUNT_PATH/lib/diskimage-builder
|
||||
sudo cp -t $TMP_MOUNT_PATH/lib/diskimage-builder $_LIB/elements-functions
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user