stackstorm / hubot-stackstorm Goto Github PK
View Code? Open in Web Editor NEWHubot plugin for integration with StackStorm event-driven infrastructure automation platform.
License: Apache License 2.0
Hubot plugin for integration with StackStorm event-driven infrastructure automation platform.
License: Apache License 2.0
Version: st2 3.1.0, on Python 3.6.8
Duplicate:
With default action alias !pack get <pack>
. If run !pack get pack=example
, the st2chatops
exits with exception.
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] ERROR Failed to create an alias execution: { name: 'APIError',
status: 400,
message:
'Command "pack get pack=core" doesn\'t match format string "pack get {{ pack }}"' }
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] DEBUG SlackClient#send() room: GJJCKM0HF, message: [object Object]
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] ERROR undefined
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] ERROR {"name":"APIError","status":400,"message":"Command \"pack get pack=core\" doesn't match format string \"pack get {{ pack }}\""}
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] INFO Hubot will shut down ...
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] INFO Disconnected from Slack RTM
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] INFO Exiting...
Right now hubot plugin basically duplicates all the API logic for alias matching. That's bad because hard to maintain and error prone.
StackStorm API offers all the primitives for performing alias matching and everything else server-side. All the bot plugins should be very thin and simple wrappers around the API and be trivially to maintain (right now it's exactly the opposite).
That's something I already mentioned as blocker a long time ago when we worked on improved ChatOps, but it never materialized, we just added more regexes which makes everything even harder to maintain.
Using the docs as an example, with this configuration:
formats:
- "google {{query}}"
sending as a direct message to hubot via slack (untested on other messaging providers) google foo
sets query=foo
. However, sending: ! google foo
does not set query=foo
I tested this on 1.3.2. If someone else could verify, that would help.
When starting st2chatops, it fails with following errors:
ERROR Unable to load /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm: TypeError: Object prototype may only be an Object or null
at Function.create (native)
at module.exports (/opt/stackstorm/chatops/node_modules/st2client/index.js:122:17)
at module.exports (/opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js:114:13)
at Robot.loadFile (/opt/stackstorm/chatops/node_modules/hubot/src/robot.coffee:358:11, :226:13)
at /opt/stackstorm/chatops/node_modules/hubot-stackstorm/index.js:38:13
at Array.forEach (native)
at module.exports (/opt/stackstorm/chatops/node_modules/hubot-stackstorm/index.js:33:13)
at Robot.loadExternalScripts (/opt/stackstorm/chatops/node_modules/hubot/src/robot.coffee:401:11, :272:39)
at /opt/stackstorm/chatops/node_modules/hubot/bin/hubot:119:11, :126:26
at fs.js:268:14
at Object.oncomplete (fs.js:107:15)
Problem:
!ansible uname -> WORKS
!ansible "uname -a" -> doesn't work.
!ansible 'uname -a' -> doesn't work.
Specs:
bacon [4:12 PM]
st2 ('0.13.2.5',)
st2 client 0.13.2.5
prd.testing.lanets.ca 3.13.0-32-generic
Python 2.7.6
bacon [4:12 PM]
I could update python to 2.7.9.
bacon [4:13 PM]
[email protected]
Original forum thread: https://forum.stackstorm.com/t/st2chatops-with-mattermost-not-replying/711
Created at the request of @armab
Good morning,
Currently, hubot-stackstorm does not respond with the output/result of a stackstorm command on Mattermost.
Here is what happens when I send !pack get docker
Chatops message received
followed by the JSON of the correct output)I have tested this with Mattermost 5.4.0, 5.9.0 and 5.12.3 on two different networks (one connected to the Internet and one not). I have tried using the Slack adapter with the same settings instead and it works as expected. I have tried using errbot with a Mattermost adapter and a Stackstorm adapter and it also works.
I recommend reading the forum thread at the top of this issue if you have any questions, as it has been most likely answered in there.
aliases/roll.yaml:
---
name: "roll"
action_ref: "ansible.playbook"
description: "Perform a rolling deployment with Ansible playbook"
formats:
- "roll1 {{playbook=deploy.yaml}} {{cwd=/opt/server-tooling/rollin}} {{inventory-file=test}} {{limit=10.2.30.121}}"
Sending:
bob roll1 playbook=deploy.yaml cwd=/opt/server-tooling/rollin inventory-file=test
Results in:
Action ansible.playbook completed.
status : failed
execution: 56391f6b02ebd505aa3bc807
result :
--------
return_code : 1
stderr : ERROR: Specified --limit does not match any hosts
Executed command "/opt/stackstorm/virtualenvs/ansible/bin/ansible-playbook --limit=inventory-file=test --inventory-file=test deploy.yaml"
Notice how it clobbered the the limit parameter and didn't inject the default.
Running it on production with authentication enabled. At start it works ok, but after some period of time when trying to run chatops command I get:
Version:
hubot-stackstorm
0.2.1
Log:
[Wed Jul 29 2015 16:50:44 GMT+0000 (UTC)] INFO Connecting...
[Wed Jul 29 2015 16:50:44 GMT+0000 (UTC)] INFO Logged in as chatopsbot of ..., but not yet connected
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Slack client now connected
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Performing authentication...
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO /opt/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js is using deprecated documentation syntax
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Loading commands....
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Wed Jul 29 2015 16:52:45 GMT+0000 (UTC)] INFO Loading commands....
[Wed Jul 29 2015 16:54:45 GMT+0000 (UTC)] INFO Loading commands....
...
(note exactly 24h interval)
...
[Thu Jul 30 2015 16:48:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:50:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:50:47 GMT+0000 (UTC)] ERROR Failed to retrieve commands: {
"faultstring": "Unauthorized"
}
[Thu Jul 30 2015 16:52:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:52:47 GMT+0000 (UTC)] ERROR Failed to retrieve commands: {
"faultstring": "Unauthorized"
}
Seems something related to expired tokens,
because after restarting hubot it returns back to normal.
Hello.
Commands sent to the hubot, which passes them later to stackstorm, get their case lowered. I am seeing that this is done to get a matching command, but this causes different issues later. E.g., passing a hostname to ansible. Ansible looks for the exact name in its inventory. I think this can be worked around by copying the command to a temp var, changing it to lower case and get a matching command from it, then treating the original command accordingly. I will try to implement it locally on my server.
Thanks.
When a message is routed through chatops.post_message, it is automatically prepended with "/code". For our particular use case, we would prefer to have the ability to toggle code on/of
https://github.com/StackStorm/hubot-stackstorm/blob/master/lib/format_data.js#L71
Reasons we want it!
This screenshot demonstrates what I mean.
Such behavior is documented somewhere (don't remember exactly where), but I found it not so user-friendly.
I think that bot should react in PM for the same commands as user writes in channel AND optionally, if you think it makes good sense, for commands without alias (eg. !
).
Tiny things to provide more obvious and predictable communication interface, making sure user don't need to keep in mind special cases like that.
Microsoft has posted a Bot Framework Hubot adapter[1]. Have anyone manage to actually get hubot connected with MS teams?
I am looking forward StackStorm integration with MS team using Bot Framework Hubot adapter.
[1]. Hubot adapter for botframework: https://github.com/Microsoft/BotFramework-Hubot
If chatops.post_message
is given a sufficiently long message, it is truncated, and its length does not seem to be adjustable. I tested via the Slack documentation-based tester, and the full message is retained. It appears to be truncated at some point by hubot-stackstorm.
Setting ST2_MAX_MESSAGE_LENGTH
had no effect. I believe that is the case because of this comment.
See my note here: e6a06f1#diff-95dd92bf93762e48697a3823e2d7e7e2R51
A customer asked for this feature.
The !help
command currently just dumps every command that is loaded by st2chatops. This is due to how hubot commands are loaded (into robot.commands
) and how the hubot-help plugin works.
It would be helpful if the bot only dumped out commands that the authenticated ChatOps user can run. This would reduce confusion, because the situation right now amounts to:
!help
A few additional notes:
!help
is run from, or it would require a complete listing of the allowed commands on a per-channel basis. This listing can grow very quickly, so this feature would greatly complicate that feature.!help
#public-channel
---------------
* do_thing_1
* do_thing_2
#private-channel-aaylmao
------------------------
* do_thing_1
* do_thing_3
* do_thing_4
#private-channel-omgstahp
-------------------------
* do_thing_2
* do_thing_5
hostname
parameter) will similarly be complicated by this feature.I'm not able to change the URL in st2 bot info.
After modifying the ST2_WEBUI_URL to a static ip in st2chatops.env and modifying webui_base_url in st2.conf and doing a st2ctl restart. The link still point to the hostname instead of the static value.
OS: Linux version 3.13.0-100-generic (buildd@lgw01-52) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
This is a single node install using the curl installer.
export ST2_HOSTNAME="${ST2_HOSTNAME:-localhost}"
export NODE_TLS_REJECT_UNAUTHORIZED=0
export EXPRESS_PORT=8081
export HUBOT_LOG_LEVEL=debug
export HUBOT_NAME=hubot
export HUBOT_ALIAS='!'
export ST2_API="${ST2_API:-https://${ST2_HOSTNAME}/api}"
export ST2_AUTH_URL="${ST2_AUTH_URL:-https://${ST2_HOSTNAME}/auth}"
export ST2_API_KEY=secret_key
export ST2_WEBUI_URL=https://10.40.0.117
export HUBOT_ADAPTER=slack
export HUBOT_SLACK_TOKEN=xoxb-super-secret
We have approximately 135 aliases:
# st2 action-alias list -j -a all | jq '.[].formats[]' | egrep "^\"" | wc -l
135
Not all of them are being made available to hubot.
When dumping Raw actions from ST2 API
during loadCommands
in /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js
, it was determined that about 100 aliases were making it.
When I try to run npm install hubot-stackstorm
I am getting this issue :
root@56914a14ea3b:~/myhubot# npm install hubot-stackstorm
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for st2client
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-08-27T09_31_24_173Z-debug.log
`
While doing some testing of the ChatOPS interface, I've noticed notifications from StackStorm via hubot to Slack show the following text:
NO FALLBACK DEFINED
This is due to the fallback part of payload in robot.emit 'slack-attachment', payload
has not been defined. This really should be a combination of the pretext and the text with no formatting. So that notifications (and systems that do not support attachments) can display the message.
Jon.
https://github.com/StackStorm/hubot-stackstorm/blob/master/scripts/stackstorm.js needs to be broken out. The temptation to dump more things into 1 file should be avoided at all cost. If nothing else modularization help with writing more tests.
I can see an issue of " hubot-stackstorm" package installation :
root@bef5e65692ca:/myhubot# npm install hubot-stackstorm
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm audit fix
to fix them, or npm audit
for detailsWhen result
message from the bot contains attachment, @mention
doesn't work in Slack:
^^ correct & highlighted @mention, you're notified in Slack
^^ @mention is just a plain text here, no Slack notification from bot
As @emedvedev said, something was changed in Slack API.
Original discussion with code example:
This get emitted upon startup and repeats until Hubot eventually shuts down
[Mon Sep 21 2015 17:34:11 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Mon Sep 21 2015 17:34:11 GMT+0000 (UTC)] ERROR SyntaxError: Unexpected token <
at Object.parse (native)
at /opt/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js:117:28
at IncomingMessage.<anonymous> (/opt/hubot/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
reported by
@mick27
from IRC
When playing with chatops commands in the room (Slack room in our case) - it works ok.
When sending private message to bot, it returns 500:
(reproduced in Slack)
PM most probably is not the best way for ChatOps, but we should avoid user confusion here.
At least should be some more user-friendly message asking to use chat room (otherwise fix chatops via PM).
As a privileged user (ops/sysadmin) I want to be able to apply one off commands (for debugging/fixes) and/or run my configuration management solution through Chatops/Slack/Rocketchat. At the same time I want to grant read only or a layer of both authentication and authorization to other stakeholders/single channel users. Also restrict/limit the specific calls a user can make to the channel bots and/or list which commands unprivileged users could access (better example may be 2 channels for two authorizations steps or 2 bots in one channel). Ideally security/auditing could; ping, status, metrics, report, etc. to the channel or render reports/audits/charts/etc, or only make available lower risk commands (e.g. ansible playbook w/o declaring git branch or arbitrary cmd - where code being applied can only come from master branch) to restrict team members to only be able to push "approved" code.
hm, so after I restart with st2ctl restart, my bot stops receiving events from st2 :simple_smile:
until I restart the bot too
A community report. I've run into that issue a couple times, too. Not sure if we should solve in st2client or here.
After a period of time st2chatops auth token expires and an error is seen in the logs:
$ journalctl -u st2chatops | grep ERROR
Apr 29 03:34:24 stackstorm.domain.tld hubot[108611]: [Sun Apr 29 2018 03:34:24 GMT-0400 (EDT)] ERROR Stream error: Event { type: 'error' }
Apr 29 03:34:26 stackstorm.domain.tld hubot[108611]: [Sun Apr 29 2018 03:34:26 GMT-0400 (EDT)] ERROR Stream error: Event { type: 'error', status: 401 }
After this, the bot responds with ACKs but any chatops.post_messages
are not echo'd into ChatOps because it is no longer able to listen on the stream.
For more details and explanation please see the original issue here: StackStorm/st2#4119
Hi,
I want to confirm if there is plan to support sending response from stackstorm to the command originating thread. Acknowledgement message from Hubot is sent in the same thread but response from chatops.post_message action is sent to channel instead of thread.
Hello.
Can we move hardcoded formatting markdown characters from format_data.js to some kind of configuration file? Not all chat servers support it. I had to temporary remove it for Let's Chat server.
[ansible@dc1udtlhkvm01 lib]$ fgrep -A1 '```' ./*
./format_data.js:// return util.format('```\n%s```', table.toString());
./format_data.js- return util.format('\n%s', table.toString());
--
./format_data.js:// return util.format('```\n%s\n```', JSON.stringify(data, null, 4));
./format_data.js- return util.format('\n%s\n', JSON.stringify(data, null, 4));
--
./format_data.js:// return util.format('```\n%s\n```', data);
./format_data.js- return util.format('\n%s\n', data);
Thanks :)
I defined a chatops alias like that:
name: "mypack_doc"
action_ref: "mypack.doc"
description: "Launch a documentation build & upload results on website."
formats:
- "(doc|docs|dox|docu) {{branch=master}}"
and in the slack channel, when I ask for help, i get that:
stanleyAPP [6:08 PM]
!(doc|docs|dox|docu) {{branch=master}} - Launch a documentation build & upload results on website.
I think the jinja delimiters {{
and }}
should be strippped from the help output, since they are misleading my users who just copy/paste them...
The (|)
enabling choice, is less problematic to grasp, apparently...
WDYT ?
Executing a "st2 run chatops.post_message message="test" channel="REDACTED" user="REDACTED" whisper=True" command does not result in a whisper message being sent to the user. Logs show a successful run. Executing without the "channel=" value results in error
"'channel' is a required property for url: http://127.0.0.1:9101/v1/executions"
Hello.
Is it possible to show stackstorm's action-aliases descriptions after their format in hubot's help? Would be nice to give some hints for users. Thanks in advance.
Currently, hubot-stackstorm leverages the built-in http client (node-scoped-http-client
) to make API calls. This is separate from the authenticate method which uses the request
library. Currently the authentication works over https and returns an auth token. However, the subsequent API calls fail over https with the error: unable to verify the first certificate
. Perhaps it's better to use the same approach for API calls as is used for authentication?
Currently, the workaround for this is to put the following env into hubot.conf
export NODE_TLS_REJECT_UNAUTHORIZED=0
but this approach is vulnerable to MITM attacks.
Just noticed an odd problem, the following display formatting works:
formats:
- display: "alertlogic scan list [<customer_id>]"
representation:
- "alertlogic scan list {{customer_id=0}}"
Which displays via hubot as:
! alertlogic scan list [<customer_id>] - List all the AlertLogic scans for a customer_id to account of key.
However if you combine [ ]
with {{var}}
as follows:
formats:
- display: "alertlogic scan list [{{customer_id}}]"
representation:
- "alertlogic scan list {{customer_id=0}}"
You get no aliases in Hubot and the hubot logs contain the following:
[Fri Mar 04 2016 15:11:42 GMT+0000 (UTC)] ERROR Failed to retrieve commands from "https://my-st2-server:443/api": Invalid regular expression: /alertlogic scan list [\s*([\s\S]+?)\s*](\s+(\S+)\s*=("([\s\S]*?)"|'([\s\S]*?)'|({[\s\S]*?})|(\S+))\s*)*$/: Unmatched ')'
It very much looks like parsing of display is happening when you include {{ var }}
I've always done this as I was following the examples at https://stackstorm.com/2015/12/08/stackstorm-1-2-0-the-new-chatops/.
Jon.
Originally logged here: StackStorm/st2#4561, @nzlosh suggested I might re-log it here.
chatops.post_message
seems to be ignoring Slack pretext
.
Pick one below and delete the rest:
st2 2.10.1, on Python 2.7.6
Standard docker install.
st2 run chatops.post_message channel=testing message='To get a list of commands type: ```!help```' extra='{"slack": {"color":"#f48527","pretext":"Hey <!channel>, Ready for ChatOps?","title": "Ansible and ChatOps. Get started :rocket:","title_link":"https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/","author_name":"by StackStorm - IFTTT for Ops","author_link":"https://stackstorm.com/","author_icon":"https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png","image_url":"https://i.imgur.com/HWN8T78.png","fields":[{"title":"Documentation","value":"https://docs.stackstorm.com/chatops/","short":true}]}}' > /dev/null
A pretext line in the Slack channel.
Pretext line missing.
In some previous ChatOps version the URL with results was always included in message:
Execution Details available at: http://...
In the new and more flexible ChatOps version with formatting and everything it's missing now.
Some tasks could be really long-running and having full execution URL would be nice, so user can include it with own formatted result
message (Jinja2 stuff in Action Alias). Ideally to make it available as ready-to use variable.
For transparency and clarity on who works with stackstorm via chatops, it would be beneficial to lock down hubot to specific channels, ensuring no one ( except certain users, or workspace admins) are able to add hubot to public/private channels, and disabling the DM functionality.
That rather should be placed in
st2
repo, but I'll leave it here to track ChatOps issues/features better
There are long-running actions like deploy, provision, VM creation and so on, - all pretty popular ChatOps citizens. Showing how much time did it take to execute an action would be great.
Add action execution time as jinja variable, so it could be used in result
templating:
Also, from the user's side it would be nice to have optional way to pretty-format it:
3s
, but1m 20s
. You got the point: make it useful, not just: Action executed in4328 seconds
.
Probably creating new Jinja filters for that would work or whatever.
"attachments" is now legacy. I'm filing this issue so that this is on the radar to figure out what that means for our hubot.
https://api.slack.com/reference/messaging/blocks
https://api.slack.com/reference/messaging/attachments#legacy_fields
Playing around, I can use do something like:
extra:
slack:
text: some msg
attachments:
- blocks:
- type: section
text:
type: plain_text
text: section header
- type: divider
however, this failed
extra:
slack:
text: some msg
attachments:
- blocks:
- type: section
text:
type: plain_text
text: section header
- type: divider
- type: actions
elements:
type: button
text: windows link to file on NAS
url: "file://///nas_server/share/path/filename.csv"
Other stuff might be broken as well.
Hello.
Not sure if this is hubot-stackstorm issue or not, but I am getting weirdly formatted output in the slack chatroom:
However running st2 run action [same action] from console it comes up just fine:
Same nice output in WebUI of stackstorm2:
And raw data from the st2 job itself looks fine too (at least I do not see backslashes there marking lines divisioning like in shell scripts when you do not want to have long lines you break them with backslashes):
Could you guys look at it and point out at who's at fault here: stackstorm, hubot-slack or hubot-stackstorm? Thanks in advance.
I am not able to send the message with button attachments. If I send simple message{non-attachment message} its working fine. If i send message with extra param from the stackstorm the message is not getting displayed in the channel.
If I have changed the line 137 in post_data.js under lib folder from attachments: content to attachments: content.attachments ? content.attachments : content then the button gets displayed.
Please help on this issue. Is this a right fix
message from stackstorm
action:
ref: chatops.post_message
parameters:
channel: "bq97zw96ypnrjp15h9ey4bhu5o"
#channel: "#town-square"
message: "Trying button action"
extra:
color: "#ff0000"
mattermost:
attachments:
- pretext: "This is the attachment pretext."
text: "This is the attachment text."
actions:
- name: "Ephemeral Message"
integration:
url: "https://x.x.x.x/hubot/buttonaction"
context:
action: "do_something_ephemeral"
- name: "Update"
integration:
url: "https://x.x.x.x/hubot/buttonaction"
context:
action: "do_something_update"
Received this error this AM while provisioning a new node with st2express
latest (Atlas Image v0.13).
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] INFO /opt/hubot/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js is using deprecated documentation syntax
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] DEBUG Successfully authenticated.
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] ERROR Failed to retrieve commands: null
Hubot was setup using st2installer
, configured to point to Slack. Aliases are indeed setup and active on the server.
root@st2express:/opt/hubot/hubot# st2 action-alias list
+---------------------------+-------+-----------------------+-------------------------------------+---------+
| ref | pack | name | description | enabled |
+---------------------------+-------+-----------------------+-------------------------------------+---------+
| hubot.hubot_branch | hubot | hubot_branch | Show the currently deployed hubot | True |
| | | | branch | |
| hubot.hubot_deploy | hubot | hubot_deploy | Deploy a specific git branch of | True |
| | | | deployed Hubot | |
| hubot.hubot_restart | hubot | hubot_restart | Restart Hubot | True |
| packs.deploy_pack | packs | deploy_pack | Download StackStorm packs via | True |
| | | | ChatOps | |
| packs.pack_info | packs | pack_info | Get StackStorm pack information via | True |
| | | | ChatOps | |
| st2.st2_actions_list | st2 | st2_actions_list | List available StackStorm actions. | True |
| st2.st2_executions_get | st2 | st2_executions_get | Retrieve details for a single | True |
| | | | execution. | |
| st2.st2_executions_list | st2 | st2_executions_list | List available StackStorm | True |
| | | | executions. | |
| st2.st2_executions_re_run | st2 | st2_executions_re_run | Re-run an action execution. | True |
| st2.st2_rules_list | st2 | st2_rules_list | List available StackStorm rules. | True |
| st2.st2_sensors_list | st2 | st2_sensors_list | List available StackStorm sensors. | True |
+---------------------------+-------+-----------------------+-------------------------------------+---------+
Hubot v0.2.1, StackStorm version 0.12.0-3
Currently, URL for st2stream is fixed to $ST2_API/stream
This is not ideal if running 1ppc mode in st2-docker because without that, st2chatops need to rely on st2web container running nginx which proxies /api/stream
to st2stream backend.
#182 was a regression, but we should add a test for that so we don't regress again in the future. Opening this issue to track the status of that.
This is issue which i solved. This is just info sharing. Please close this issue.
Currently stackstorm.js script loads all enabled aliases of all packs installed in st2. For scaling of hubot necessary to restrict specific packs to specific hubot instance. I might send PR if i have time but basically i did below changes to stackstorm.js . Hope its helpful for someone. Concept is inspired from new environment variable introduced here #133 ST2_ALIAS_PACK_RESTRICTION
In st2chatops.env file:
export ST2_ALIAS_PACK_RESTRICTION=packs,pack1Name,pack2Name
In scripts/stackstorm.js file:
// To restrict adding aliases from only specific packs.
env.ST2_ALIAS_PACK_RESTRICTION = env.ST2_ALIAS_PACK_RESTRICTION || null;
var loadCommands = function() {
robot.logger.info('Loading commands....');
api.actionAlias.list()
.then(function (aliases) {
// Remove all the existing commands
command_factory.removeCommands();
if (env.ST2_ALIAS_PACK_RESTRICTION) {
robot.logger.info('Aliases only from following packs will be loaded: ' + env.ST2_ALIAS_PACK_RESTRICTION);
var packs = env.ST2_ALIAS_PACK_RESTRICTION;
var packsList = packs.split(",");
_.each(aliases, function (alias) {
if (packsList.indexOf(alias.pack) !== -1){
var name = alias.name;
var formats = alias.formats;
var description = alias.description;
if (alias.enabled === false) {
return;
}
if (!formats || formats.length === 0) {
robot.logger.error('No formats specified for command: ' + name);
return;
}
_.each(formats, function (format) {
var command = formatCommand(robot.logger, name, format.display || format, description);
command_factory.addCommand(command, name, format.display || format, alias,
format.display ? utils.DISPLAY : false);
_.each(format.representation, function (representation) {
command = formatCommand(robot.logger, name, representation, description);
command_factory.addCommand(command, name, representation, alias, utils.REPRESENTATION);
});
});
}});
}
else {
robot.logger.info('Env variable ST2_ALIAS_PACK_RESTRICTION is not set. No aliases from any pack will be loaded ');
}
robot.logger.info(command_factory.st2_hubot_commands.length + ' commands are loaded');
})
.catch(function (err) {
var error_msg = 'Failed to retrieve commands from "%s": %s';
robot.logger.error(util.format(error_msg, env.ST2_API, err.message));
});
};
If the source_channel is not a String, like Telegram, the POST in /api/v1/aliasexecution fail with message:
Nov 6 17:14:40 stackstorm hubot: [Mon Nov 06 2017 17:14:40 GMT-0200 (-02)] DEBUG Sending command payload: {"name":"remote_shell_cmd","format":"(run|execute) {{cmd}} on {{hosts}}","command":"execute date on localhost","user":"test","source_channel":123456,"notification_route":"hubot"}
Nov 6 17:14:40 stackstorm gunicorn: 2017-11-06 17:14:40,374 INFO [-] c278448b-9896-43ed-b0e4-b298d60f9897 - 400 58 181.033ms (content_length=58,request_id='c278448b-9896-43ed-b0e4-b298d60f9897',runtime=181.033,remote_addr='127.0.0.1',status=400,method='POST',path='/v1/aliasexecution')
Nov 6 17:14:40 stackstorm hubot: [Mon Nov 06 2017 17:14:40 GMT-0200 (-02)] ERROR Failed to create an alias execution: { name: 'APIError',
Nov 6 17:14:40 stackstorm hubot: status: 400,
Nov 6 17:14:40 stackstorm hubot: message: '123456 is not of type \'string\'' }
My workarround is edit the file scripts/stackstorm.js and set:
--- chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js 2017-11-06 17:13:59.878000000 -0200
+++ chatops/node_modules/hubot-stackstorm/scripts/stackstorm.edit.js 2017-11-06 17:18:03.657000000 -0200
@@ -266,7 +266,7 @@
postDataHandler.postData({
whisper: false,
user: addressee.name,
- channel: addressee.room,
+ channel: String(addressee.room),
message: message,
extra: {
color: '#F35A00'
@@ -283,7 +283,7 @@
'format': format_string,
'command': command,
'user': addressee.name,
- 'source_channel': addressee.room,
+ 'source_channel': String(addressee.room),
'notification_route': env.ST2_ROUTE || 'hubot'
};
@@ -296,7 +296,7 @@
'parameters': {
'uuid': twofactor_id,
'user': addressee.name,
- 'channel': addressee.room,
+ 'channel': String(addressee.room),
'hint': action_alias.description
}
});
Hey guys, - newbie here.. is there a way to disable direct messaging hubot on slack to run commands? Would like to keep all comms in a specific channel.
The bot should retrieve a new authentication token when the current one expires - currently it doesn't.
The best solution (imo) for this is to add alias related functionality to st2client.js and handle re-authentication transparently in the client. This way we don't need to reinvent the wheel in 2 places and the client needs and should support this functionality anyways.
Related st2client.js issue - StackStorm/st2client.js#25
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.