##环境 系统: 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/st2cd /usr/local/src/st2cat << EOF > requirements.txtapscheduler>=3.0.0rc1eventlet>=0.13.0flaskflask-jsonschemagitpython==0.3.2.1jinja2jsonschema>=2.3.0kombumongoengine>=0.8.7,<0.9oslo.config>=1.12.1,<1.13paramikopecan==0.7.0pymongo<3.0python-dateutilpython-json-loggerpyyamlrequestssetuptools==11.1six==1.9.0toozgit+https://github.com/StackStorm/python-mistralclient.git@st2-0.9.0git+https://github.com/StackStorm/fabric.git@stanley-patchedpasslib>=1.6.2,<1.7lockfile>=0.10.2,<0.11python-gnupg>=0.3.7,<0.4jsonpath-rw>=1.3.0# Requirements for linux pack# used by file watcher sensorpyinotify>=0.9.5,<=0.10-e git+https://github.com/Kami/logshipper.git@stackstorm_patched#egg=logshipper# used by nmap actionspython-nmap>=0.3.4,<0.4semver>=2.1.2EOFpip install -r requirements.txt
##配置rabbitmq
rabbitmq-plugins enable rabbitmq_managementservice rabbitmq-server restart#下载管理脚本curl -sS -o /usr/bin/rabbitmqadmin http://localhost:15672/cli/rabbitmqadminchmod 755 /usr/bin/rabbitmqadmin
###Mistral 注意要关闭mistral的认证
参考
安装完成后,要注册mistral到系统服务(ubuntu14.04使用upstart,15.04使用systemd)
upstart:
cat </etc/init/mistral.confdescription "Mistral Workflow Service"start on runlevel [2345]stop on runlevel [016]respawnexec /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.confmistral_upstart
##下载并安装st2包
cd /usr/local/src/st2wget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2actions_0.12.0-3_amd64.debwget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2api_0.12.0-3_amd64.debwget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2auth_0.12.0-3_amd64.debwget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2client_0.12.0-3_amd64.debwget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2common_0.12.0-3_amd64.debwget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2debug_0.12.0-3_amd64.debwget https://downloads.stackstorm.net/releases/st2/0.12.0/debs/current/st2reactor_0.12.0-3_amd64.debdpkg -i *.deb
##安装WebUI ###已编译
cd /usr/local/src/st2wget https://downloads.stackstorm.net/releases/st2/0.12.0/webui/webui-0.12.0.tar.gztar -xf webui-0.12.0.tar.gzmkdir /opt/stackstorm/static/mv webui /opt/stackstorm/static/
###正式版
cd /usr/local/srcgit clone https://github.com/StackStorm/st2web.gitnode -vv0.10.32npm -v1.4.9cd /usr/local/src/st2webnpm installbower installgulp #测试web服务是否正常
编辑gulpfile.js
,修改port: 8000
编译web
gulp buildgulp productionmkdir -p /opt/stackstorm/static/webuicp -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.confallow_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(可选) 参考: ###禁用auth
#vim /etc/st2/st2.conf...[auth]enable = False...
###新增CLI配置(可选)
# Configuration file for the StackStorm CLI[general]base_url = http://localhostapi_version = v1# Path to the CA cert bundle used to validate the SSL certificatescacert =[cli]debug = True# True to cache the retrieved auth token during authentication in ~/.st2/token# and use the cached token in the sunsequent API requestscache_token = True[credentials]# Credentials used to authenticate against the auth API and retrieve the auth# tokenusername = test1password = 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