ChatOps with Hubot and Slack

docker

#21

How do you inquire what st2chatops has for it’s environment? Things seem to work if I pass the following directly at the command line:

/opt/stackstorm/chatops# ST2_API_KEY=<masked api key> HUBOT_SLACK_TOKEN=xoxb-<masked token> ST2_ROUTE=chatops PORT=8181 bin/hubot --name "hubot"  -a slack --alias !

[Tue Sep 11 2018 17:20:31 GMT+0000 (UTC)] DEBUG Loading adapter slack
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] INFO Logged in as hubot of Opus Ops
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] INFO Slack client now connected
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Loading scripts from /opt/stackstorm/chatops/scripts
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Loading scripts from /opt/stackstorm/chatops/src/scripts
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] INFO Using ST2_API_KEY as authentication. Expiry will lead to bot exit.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Using slack post data handler.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Parsing help for /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] INFO Loading commands....
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Parsing help for /opt/stackstorm/chatops/node_modules/hubot-help/src/help.coffee
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: run {{cmd}} on {{hosts}} - Execute a command on a remote host via SSH.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack get <pack> - Get information about installed StackStorm pack.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack get {{ pack }} - Get information about installed StackStorm pack.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack install <pack>[,<pack>] - Install/upgrade StackStorm packs.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack install <gitUrl>[,<gitUrl>] - Install/upgrade StackStorm packs.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack install {{ packs }} - Install/upgrade StackStorm packs.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack search <query> - Search for packs in StackStorm Exchange and other directories.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack search {{ query }} - Search for packs in StackStorm Exchange and other directories.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack show <pack> - Show information about the pack from StackStorm Exchange.
[Tue Sep 11 2018 17:20:32 GMT+0000 (UTC)] DEBUG Added command: pack show {{ pack }} - Show information about the pack from StackStorm Exchange.
[Tue Sep 11 2018 17:36:32 GMT+0000 (UTC)] INFO 5 commands are loaded
[Tue Sep 11 2018 17:37:24 GMT+0000 (UTC)] DEBUG Received message: '!help' in channel: chatops, from: MysteryAchievement
[Tue Sep 11 2018 17:37:24 GMT+0000 (UTC)] DEBUG Message '!help' matched regex //^\s*[@]?(?:hubot[:,]?|![:,]?)\s*(?:([\s\S]+?)$)/i/; listener.options = { id: null }
[Tue Sep 11 2018 17:37:24 GMT+0000 (UTC)] DEBUG Executing listener callback for Message '!help'
[Tue Sep 11 2018 17:37:24 GMT+0000 (UTC)] DEBUG Message '!help' matched regex //^\s*[@]?(?:hubot[:,]?|![:,]?)\s*(?:help(?:\s+(.*))?$)/i/; listener.options = { id: null }
[Tue Sep 11 2018 17:37:24 GMT+0000 (UTC)] DEBUG Executing listener callback for Message '!help'
[Tue Sep 11 2018 17:37:24 GMT+0000 (UTC)] DEBUG Sending to CCND4M2UE: !help - Displays all of the help commands that this bot knows about.
!help <query> - Displays all help commands that match <query>.
!pack get <pack> - Get information about installed StackStorm pack.
!pack install <gitUrl>[,<gitUrl>] - Install/upgrade StackStorm packs.
!pack install <pack>[,<pack>] - Install/upgrade StackStorm packs.
!pack search <query> - Search for packs in StackStorm Exchange and other directories.
!pack show <pack> - Show information about the pack from StackStorm Exchange.
!run {{cmd}} on {{hosts}} - Execute a command on a remote host via SSH.

But when I try to see if the service is running, I see this:

/opt/stackstorm/chatops# service st2chatops status
st2chatops stop/waiting

#22

Unless I am missing something, I think something is wrong with the container. I know that’s a bold statement from a know-nothing but humor me for a second. Following README.md:

Create a new folder and then do:

git clone https://github.com/stackstorm/st2-docker
cd st2-docker
make env

modify docker.compose.yml and add:

    environment:
      - NODE_TLS_REJECT_UNAUTHORIZED=0
      - EXPRESS_PORT=8181
      - ST2_HOSTNAME=localhost
      - ST2_API=https://localhost/api
      - ST2_API_KEY=<masked>
      - ST2_AUTH_URL=https://localhost/auth
      - ST2_STREAM_URL=https://localhost/stream
      - ST2_WEBUI_URL=https://localhost
      - ST2_ROUTE=chatops
      - HUBOT_LOG_LEVEL=debug
      - HUBOT_NAME=hubot
      - HUBOT_ALIAS='!'
      - HUBOT_ADAPTER=slack
      - HUBOT_SLACK_TOKEN=xoxb-<masked>

add a file named enable-chatops.sh containing:

#!/bin/bash

sudo rm /etc/init/st2chatops.override

and place it in /opt/st2-docker/runtime/entrypoint.d/

Now spin up the container and bash in:

docker-compose up -d
docker-compose exec starmstorm bash

and then run

st2ctl status | grep "st2chatops"

(and i also tried: st2ctl reload --register-all but still get:

st2chatops is not running.

From what I can tell, this is the bare-minimum to get this to work. I can reproduce it at will. One other thing - running this:

ST2_API_KEY=<masked api key> HUBOT_SLACK_TOKEN=xoxb-<masked token> ST2_ROUTE=chatops PORT=8181 bin/hubot --name "hubot"  -a slack --alias !

works and I can communicate with hubot in slack.