Skip to content

Latest commit

 

History

History
154 lines (112 loc) · 4.92 KB

README.rst

File metadata and controls

154 lines (112 loc) · 4.92 KB

Errbot as an interface to StackStorm's ChatOps

Deploy Errbot using docker-compose connected with StackStorm to fully leverage its ChatOps capabilities in Slack.

  1. Deploy and configure StackStorm:

    git clone https://github.com/StackStorm/st2-docker.git
    cd st2-docker
    make env
    docker-compose up -d
    docker-compose exec stackstorm bash
    # Save the key to put in ST2_API_KEY later
    st2 apikey create -k -m '{"used_by": "my Errbot"}'
    cd /opt/stackstorm/packs/chatops/rules/
    sed -i -e '/^enabled: / s/true/false/' notify_hubot.yaml
    wget https://raw.githubusercontent.com/fmnisme/err-stackstorm/master/contrib/stackstorm-chatops/rules/notify_errbot.yaml
    cd ../actions
    sed -i -e '/^\s\+default: / s/chatops/errbot/' post_message.yaml
    st2ctl reload
    exit
  2. Deploy Errbot container:

    git clone --recurse-submodules https://github.com/vutny/errbot-slack-st2.git
    cd errbot-slack-st2
    export BOT_TOKEN='xoxb-123456789098-QwErTyUiOpaSdFgHjKlZxCvB'
    export BOT_ADMINS='@denys'  # Put your username in a chat here
    export ST2_API_KEY='MGU5NjQ2YzM2NzgwNDQxNmQ2MjI1ZjJkNzZlMGNlYm...'
    [ "$(uname -s)" = "Darwin" ] && export ST2_HOST=192.168.65.1
    docker-compose up -d
  3. Check the Errbot is alive by sending it direct message in Slack:

    !st2help

Minimum required versions are:

  • Docker 1.13.1 (or later Docker CE)
  • docker-compose 1.17.1

Create a bot integration in your Slack Team.

  1. Go to team menu, select Customize Slack option.
  2. In Customize Your Workspace page menu, click on Configure Apps.
  3. Select Custom Integrations and then Bots.
  4. Create new integration. Depending on a Slack team settings, you may need to issue a Request to Install a bot from Slack Workspace Owner.
  5. Copy the API token, we will need it to configure our Errbot.
  6. Give your new bot a fun name and describe what it does.
  7. Press Save Integration.

The best option for local testing and development is getting Docker, but you may consider to have a full-fledged installation from the upstream packages on a dedicated or virtual machine.

You need to run StackStorm services and configure API Key for Errbot to be able to talk to it. Issue st2 apikey create command in the shell inside the stackstorm container or wherever ST2 has been installed to generate it.

Some additional configuration for chatops pack in StackStorm required for Errbot to be able to receive event streams back with command execution results. Create new notify-errbot rule and change the route in post_message action as listed above in the TL;DR section.

Before spinning up Errbot, few environment variables should be exported in current shell.

  • BOT_ADMINS: account names of user who would be allowed to issue administrative commands to Errbot.
  • BOT_TOKEN: API token for existing or newly created custom bot integration in Slack, see above.
  • CORE_PLUGINS (optional): specify which bundled plugins Errbot should load on start up, separated by comma. ST2_API_KEY: the key created in StackStorm to access its API.
  • ST2_HOST (optional): if you're running StackStorm in Docker on MacOS set it to 192.168.65.1. On GNU/Linux you may need to specify 172.17.42.1 here. This is a special IP address of Docker bridge network interface.

It is possible to save these variables in .env file in the root of the repository.

During the first start of the errbot service container, WebserverConfiguration and err-stackstorm plugins will be automagically activated exposing StackStorm's Action Aliases to Errbot.

Start the container with pre-configured Slack and StackStorm integration:

docker-compose up -d

Watch live log with:

docker-compose logs --tail=all -f