Git Product home page Git Product logo

errbot-slack-st2's Introduction

Errbot as an interface to StackStorm's ChatOps

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

TL;DR

  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

Requirements

Docker

Minimum required versions are:

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

Slack

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.

StackStorm a.k.a. ST2

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.

Deployment

ChatOps Support Pack

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.

Configuration

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.

Plugins

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.

Launch

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

docker-compose up -d

Watch live log with:

docker-compose logs --tail=all -f

errbot-slack-st2's People

Contributors

vutny avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

zoomdata

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.