stackstorm的安装

yum -y install https://dl.fedoraproject.org/pub/epel/epel-releas
e-latest-6.noarch.rpm
rpm --import https://www.mongodb.org/static/pgp/server-3.2.asc
sh -c "cat <<EOT > /etc/yum.repos.d/mongodb-org-3.2.repo
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
EOT"
yum -y install mongodb-org
yum -y install rabbitmq-server
备注:无法安装rabbitmq-server,需要执行下面的步骤:
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
yum -y install erlang
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el6.noarch.rpm
yum -y install rabbitmq-server-3.6.6-1.el6.noarch.rpm
如果报这个错误:Requires: socat
更新源wget –no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo
yum install socat -y
然后再安装
yum -y install rabbitmq-server-3.6.6-1.el6.noarch.rpm

service mongod start
service rabbitmq-server start
chkconfig mongod on
chkconfig rabbitmq-server on
if grep -q "CentOS" /etc/redhat-release; then sudo yum -y localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-2.noarch.rpm; fi
yum -y install postgresql94-server postgresql94-contrib postgresql94-devel
service postgresql-9.4 initdb
sed -i "s/\(host.*all.*all.*127.0.0.1\/32.*\)ident/\1md5/" /var/lib/pgsql/9.4/data/pg_hba.conf
sed -i "s/\(host.*all.*all.*::1\/128.*\)ident/\1md5/" /var/lib/pgsql/9.4/data/pg_hba.conf
service postgresql-9.4 start
chkconfig postgresql-9.4 on
curl -s https://packagecloud.io/install/repositories/StackStorm/stable/script.rpm.sh | sudo bash
yum install -y st2 st2mistral
cat << EHD | sudo -u postgres psql
CREATE ROLE mistral WITH CREATEDB LOGIN ENCRYPTED PASSWORD 'StackStorm';
CREATE DATABASE mistral OWNER mistral;
EHD
/opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf upgrade head
/opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf populate
useradd stanley
mkdir -p /home/stanley/.ssh
chmod 0700 /home/stanley/.ssh
ssh-keygen -f /home/stanley/.ssh/stanley_rsa -P ""
sh -c 'cat /home/stanley/.ssh/stanley_rsa.pub >> /home/stanley/.ssh/authorized_keys'
chown -R stanley:stanley /home/stanley/.ssh
sh -c 'echo "stanley    ALL=(ALL)       NOPASSWD: SETENV: ALL" >> /etc/sudoers.d/st2'
chmod 0440 /etc/sudoers.d/st2
sed -i -r "s/^Defaults\s+\+?requiretty/# Defaults +requiretty/g" /etc/sudoers
st2ctl start
st2ctl reload
st2 --version
st2 -h
st2 action list --pack=core
st2 run core.local -- date -R
st2 execution list
st2 run core.remote hosts='localhost' -- uname -a
st2 run packs.install packs=st2
yum -y install httpd-tools
htpasswd -bs /etc/st2/htpasswd st2admin Ch@ngeMe

Enable and configure auth in /etc/st2/st2.conf:

[auth]
# ...
enabled = True
backend = flat_file
backend_kwargs = {"file_path": "/etc/st2/htpasswd"}
# ...

Restart the st2api service:

sudo st2ctl restart-component st2api

Authenticate, export the token for st2 CLI, and check that it works:

# Get an auth token and use in CLI or API
st2 auth st2admin

# A shortcut to authenticate and export the token
export ST2_AUTH_TOKEN=$(st2 auth st2admin -p Ch@ngeMe -t)

# Check that it works
st2 action list
# Add key and repo for the latest stable nginx
sudo rpm --import http://nginx.org/keys/nginx_signing.key
sudo sh -c "cat <<EOT > /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/6/x86_64/
gpgcheck=1
enabled=1
EOT"

# Install st2web and nginx
sudo yum -y install st2web nginx

# Generate self-signed certificate or place your existing certificate under /etc/ssl/st2
sudo mkdir -p /etc/ssl/st2

sudo openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/st2/st2.key -out /etc/ssl/st2/st2.crt \
-days 365 -nodes -subj "/C=US/ST=California/L=Palo Alto/O=StackStorm/OU=Information \
Technology/CN=$(hostname)"

# Copy and enable the supplied nginx config file
sudo cp /usr/share/doc/st2/conf/nginx/st2.conf /etc/nginx/conf.d/

# Disable default_server configuration in existing /etc/nginx/nginx.conf
sudo sed -i 's/default_server//g' /etc/nginx/conf.d/default.conf

sudo service nginx restart
sudo chkconfig nginx on
# Ensure chatops pack is in place
ls /opt/stackstorm/packs/chatops
# Create notification rule if not yet enabled
st2 rule get chatops.notify || st2 rule create /opt/stackstorm/packs/chatops/rules/notify_hubot.yaml
curl -sL https://rpm.nodesource.com/setup_4.x | sudo -E bash -
yum install -y st2chatops
service st2chatops start
chkconfig st2chatops on
st2ctl reload --register-all