##环境 系统: ubuntu14.04/ubuntu15.04
stackstorm版本: v0.12
##依赖 ###apt
aptlist='rabbitmq-server make python-virtualenv python-dev realpath python-pip mongodb mongodb-server gcc git mysql-server python-yaml python-dateutil python-jsonpath-rw'
apt-get install -y ${aptlist}
###pip 从github的requirements.txt拷贝过来,文档中的不全
mkdir /usr/local/src/st2
cd /usr/local/src/st2
cat << EOF > requirements.txt
apscheduler>=3.0.0rc1
eventlet>=0.13.0
flask
flask-jsonschema
gitpython==0.3.2.1
jinja2
jsonschema>=2.3.0
kombu
mongoengine>=0.8.7,<0.9
oslo.config>=1.12.1,<1.13
paramiko
pecan==0.7.0
pymongo<3.0
python-dateutil
python-json-logger
pyyaml
requests
setuptools==11.1
six==1.9.0
tooz
git+https://github.com/StackStorm/python-mistralclient.git@st2-0.9.0
git+https://github.com/StackStorm/fabric.git@stanley-patched
passlib>=1.6.2,<1.7
lockfile>=0.10.2,<0.11
python-gnupg>=0.3.7,<0.4
jsonpath-rw>=1.3.0
# Requirements for linux pack
# used by file watcher sensor
pyinotify>=0.9.5,<=0.10
-e git+https://github.com/Kami/logshipper.git@stackstorm_patched#egg=logshipper
# used by nmap actions
python-nmap>=0.3.4,<0.4
semver>=2.1.2
EOF
pip install -r requirements.txt
##配置rabbitmq
rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server restart
#下载管理脚本
curl -sS -o /usr/bin/rabbitmqadmin http://localhost:15672/cli/rabbitmqadmin
chmod 755 /usr/bin/rabbitmqadmin
###Mistral 注意要关闭mistral的认证
参考 https://github.com/openstack/mistral
安装完成后,要注册mistral到系统服务(ubuntu14.04使用upstart,15.04使用systemd)
upstart:
cat <<mistral_upstart >/etc/init/mistral.conf
description "Mistral Workflow Service"
start on runlevel [2345]
stop on runlevel [016]
respawn
exec /opt/openstack/mistral/.venv/bin/python /opt/openstack/mistral/mistral/cmd/launch.py --config-file /etc/mistral/mistral.conf --log-config-append /etc/mistral/wf_trace_logging.conf
mistral_upstart
##下载并安装st2包
cd /usr/local/src/st2
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2actions_0.12.0-3_amd64.deb
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2api_0.12.0-3_amd64.deb
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2auth_0.12.0-3_amd64.deb
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2client_0.12.0-3_amd64.deb
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2common_0.12.0-3_amd64.deb
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2debug_0.12.0-3_amd64.deb
wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2reactor_0.12.0-3_amd64.deb
dpkg -i *.deb
##安装WebUI ###已编译
cd /usr/local/src/st2
wget https://downloads.stackstorm.net/releases/st2/0.12.0/webui/webui-0.12.0.tar.gz
tar -xf webui-0.12.0.tar.gz
mkdir /opt/stackstorm/static/
mv webui /opt/stackstorm/static/
###正式版
cd /usr/local/src
git clone https://github.com/StackStorm/st2web.git
node -v
v0.10.32
npm -v
1.4.9
cd /usr/local/src/st2web
npm install
bower install
gulp #测试web服务是否正常
编辑gulpfile.js
,修改port: 8000
编译web
gulp build
gulp production
mkdir -p /opt/stackstorm/static/webui
cp -rf build/* /opt/stackstorm/static/webui/
##配置WEBUI ###修改配置文件,配置正确的api接口:
#vim /opt/stackstorm/static/webui/config.js
'use strict';
angular.module('main')
.constant('st2Config', {
hosts: [{
name: 'Dev Env',
url: 'http://127.0.0.1:9101',
auth: false,
},]
});
###允许web访问st2api
#vim /etc/st2/st2.conf
allow_origin = http://st2web.example.com:3000
##配置st2 ###SUDO 默认情况下, 所有的action以stanley
用户执行,可以在st2.conf
修改默认配置.
1.新增用户:
useradd stanley
2.stanley
需要sudo权限。
echo "stanley ALL=(ALL) NOPASSWD: SETENV: ALL" >> /etc/sudoers.d/st2
###SSH(可选) 参考: http://docs.stackstorm.com/0.12/install/config.html#configure-ssh ###禁用auth
#vim /etc/st2/st2.conf
...
[auth]
enable = False
...
###新增CLI配置(可选)
# Configuration file for the StackStorm CLI
[general]
base_url = http://localhost
api_version = v1
# Path to the CA cert bundle used to validate the SSL certificates
cacert =
[cli]
debug = True
# True to cache the retrieved auth token during authentication in ~/.st2/token
# and use the cached token in the sunsequent API requests
cache_token = True
[credentials]
# Credentials used to authenticate against the auth API and retrieve the auth
# token
username = test1
password = testpassword
[api]
url = http://localhost:9101/v1
[auth]
url = http://localhost:9100/
##注册sensors、action、rules、aliases、policy types、policies ###注册核心模块
st2ctl reload --register-all
###注册样例 拷贝github.com/StackStorm/st2/contrib
中的examples
、hello-st2
到/opt/stackstorm/packs/
目录下,然后注册:
st2 run packs.load register=all
更多第三方packs在https://github.com/StackStorm/st2contrib
##重启服务
st2ctl restart
##排错
-
如果
st2ctl restart
起不来则在前台启动服务查看错误,例如:st2api --config-file /etc/st2/st2.conf
-
如果有服务起不来,可能是依赖有问题,尝试再次
pip install -r requests.txt