ChatOps without a single line of code

Denys Havrysh
ChatOps chronicles
Published in
4 min readMay 23, 2018
Image from https://electric-cloud.com

A concept of ChatOps is not new nowadays. That is an approach to collaborate on daily tasks by communicating with some programmable application, i.e. Chat Bot, via your team’s chat room using human language. In the current state of technology, it has nothing to do with Machine Learning or NLPyet. You could instruct your personalized bot to do various useful things for you, for example: deploy some code, check web service status, schedule a job or a meeting, run destructive commands on all production boxes and much much more. Your imagination is the limit. It enables visibility and transparency for routine day-to-day activities and provides self-service for other team members. The term “ChatOps” was originally invented at GitHub, but quickly spread across Internet communities around DevOps, SRE and modern IT operations.

OK, got it. How could I try it out with my team today?

This post will cover high-level basics of ChatOps system architecture and its implementation. Here we will present a solution, which will help to quickly start out small, get instant value and iterate to improve things are most matter in your organization.

So, you may ask: “How could I bring that ChatOps thing to my team without writing any code?” Well, if you already have all your process and workflows already automated, then it should be rather easy to get in to this. The truth is that you would need to code a lot of automation recipes, which a bot could execute for you. Don’t be afraid, we have good news here: you don’t need to develop the bot on your own, interface to a chat service, integration with Cloud provider, SSH transport or Web client to call RESTful endpoints. What about chat messages parsing, event logging, asynchronous calls, authentications ACLs, storing some intermediate data? You don’t have to reinvent a wheel and worry about all this crazy stuff from day zero to just get your real work done. To summarize things, you need basically two main parts of your future ChatOps solution:

  • The Backend: a service to interact with other systems, servers and APIs.
  • The Chat Bot: an application that will receive commands in a chat room, ask the Backend to do dirty job and carry success or failure result back to user, who issued the command.

Bring in versatile tools

Sounds complicated? Sort of, but there are tools to help us. Meet StackStorm!

StackStorm (or ST2) is an open-source automation platform under an umbrella of Extreme Networks. It is capable of doing lots of stuff by adding integration packs. ST2 will act as our Backend service.

As a pleasant bonus, StackStorm comes with native ChatOps support built-in! The st2chatops package supplies already bundled Hubot, a popular chat bot written in CoffeeScript language. The world of Node.js is cool, but we better get something more familiar.

What we also like in ST2, it is all Python. Packs even use virtualenvs under the hood. Within my team we love coding automation tasks in Python so much. And it would be great to hack bot’s code and understand its internals when time will come.

Let us introduce you Errbot. It is written Python 3.3+ and supports various chat services, including Slack, which we use for collaboration in our team.

Alright, so how we’re going to integrate Errbot with StackStorm? Just our luck, there is a plugin to bring StackStorm’s ChatOps to Errbot.

Building the Complete Solution

It appeared that everything works quite well altogether. To get all this stuff up and running, proceed with these steps:

  1. Deploy ST2, but skip installing and starting st2chatops service.
  2. Install Errbot (better to do it in virtualenv) and connect it to your chat provider.
  3. Follow instructions from err-stackstorm plugin’s README file.

4. …

5. PROFIT!

This is how data flows between different parts of the system.

ChatOps architecture view by StackStorm

The documentation is pretty straight forward. At the end you will be able to execute prepackaged StackStorm’s action aliases by issuing command to Errbot in a chat. Just type

!help

to discover all things that your new bot could offer.

More specific command to get available actions is:

!st2help

The err-stackstorm plugin’s documentation has an excellent troubleshooting section if something does not work as expected.

What’s next?

You will expand features and commands the bot be able to understand by simply installing more ST2 packs. There are many integrations with popular DevOps tools, such as Docker, Jenkins, Kubernetes, Salt, Terraform and many others.

In later articles we will dive deep into how to deploy development environment and start experimenting with features which StackStorm provides.

--

--