#!/bin/bash set -ex MGMT_IP=$(ifconfig br-mgmt | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}') HOST=$(hostname -s) ADMIN_IP=$(hiera management_vip) PUB_IP=$(hiera public_vip) PORT='15868' USER='masakari' PASS='masakari' DIR="$(dirname `readlink -f $0`)" apt-get update apt-get install -y --force-yes git python-pip python-dev pip install --upgrade pip pip install virtualenv source /root/openrc openstack user create --password $USER $PASS openstack role add --project services --user $USER admin openstack service create --name masakari --description "masakari high availability" ha id=$(openstack service show masakari -f value -c id 2>/dev/null) openstack endpoint create --region RegionOne $id --publicurl "http://${PUB_IP}:${PORT}/v1/%(tenant_id)s" --adminurl "http://${ADMIN_IP}:${PORT}/v1/%(tenant_id)s" --internalurl "http://${ADMIN_IP}:${PORT}/v1/%(tenant_id)s" mysql --execute="CREATE DATABASE masakari; GRANT ALL PRIVILEGES ON masakari.* To '${USER}'@'%' IDENTIFIED BY '${PASS}';" virtualenv v-masakari source v-masakari/bin/activate git clone https://github.com/openstack/masakari.git cd masakari pip install -r requirements.txt pip install PyMySql python setup.py install mkdir -p /etc/masakari cd etc/masakari cp policy.json api-paste.ini /etc/masakari/ rabbit_pass=$(hiera rabbit | sed 's/[{},=>"]/ /g' | awk '{print $2}') nova_pass=$(hiera nova | grep user_password | sed 's/[",=>]/ /g' | awk '{print $2}') mysql_host=$(hiera management_vip) cat > /etc/masakari/masakari.conf <<- EOM [DEFAULT] graceful_shutdown_timeout = 5 os_privileged_user_tenant = services os_privileged_user_password = ${nova_pass} os_privileged_user_name = nova logging_exception_prefix = %(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s logging_debug_format_suffix = from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d logging_default_format_string = %(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s logging_context_format_string = %(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %(user)s %(tenant)s%(color)s] %(instance)s%(color)s%(message)s use_syslog = False debug = True masakari_api_workers = 2 [keystone_authtoken] auth_uri = http://${ADMIN_IP}:5000 auth_url = http://${ADMIN_IP}:35357 auth_type = password project_name = services username = ${USER} password = ${PASS} project_domain_name = Default user_domain_name = Default [database] connection = mysql+pymysql://${USER}:${PASS}@${ADMIN_IP}/masakari?charset=utf8 [oslo_messaging_rabbit] rabbit_hosts = ${MGMT_IP}:5673 rabbit_userid = nova rabbit_password = ${rabbit_pass} EOM iptables -A INPUT -p tcp -m multiport --ports $PORT -m comment --comment "masakari-api" -j ACCEPT cat > /etc/init/masakari-api.conf <<- EOM description "Masakari API" start on runlevel [2345] stop on runlevel [!2345] chdir /root/ script . /root/v-masakari/bin/activate exec masakari-api --config-file=/etc/masakari/masakari.conf --debug end script EOM cat > /etc/init/masakari-engine.conf <<- EOM description "Masakari engine" start on runlevel [2345] stop on runlevel [!2345] chdir /root/ script . /root/v-masakari/bin/activate exec masakari-engine --config-file=/etc/masakari/masakari.conf --debug end script EOM cat > /etc/haproxy/conf.d/199-masakari.cfg <<- EOM listen masakari-api bind ${PUB_IP}:${PORT} bind ${ADMIN_IP}:${PORT} http-request set-header X-Forwarded-Proto https if { ssl_fc } option httpchk option httplog option httpclose server ${HOST} ${MGMT_IP}:${PORT} check inter 10s fastinter 2s downinter 3s rise 3 fall 3 EOM /usr/lib/ocf/resource.d/fuel/ns_haproxy reload cd $DIR pip install python-openstackclient git clone https://github.com/openstack/python-masakariclient cd python-masakariclient pip install -r requirements.txt python setup.py install initctl reload-configuration service masakari-api start masakari-manage db sync service masakari-engine start echo "Activate masakari virtual env: source /root/v-masakari/bin/activate"