StackStorm QuickTip: ChatOps your pack dev workflow

by James Fryman

Happy Monday! In today’s StackStorm quick tip, we are going to show you a way to rapidly test and deploy packs. This technique pairs a StackStorm action, packs.install, and an Action-Alias that we will create to allow users to rapidly test and deploy new ChatOps commands for themselves.

Let’s just dive in!

# /opt/stackstorm/packs/st2-flow/aliases/flow_deploy.yaml
---
name: "flow_deploy"
pack: "st2-flow"
action_ref: "packs.install"
formats:
  - display: "flow deploy {{ branch }}"
    representation:
      - "{{register=all}} {{packs=st2-flow}} {{repo_url=moc.buhtignull@tig:websages/st2-flow}} flow deploy {{branch=master}}"
ack:
  format: "Deploying flow ... standby ..."
result:
  format: |
    {% if execution.status == 'failed' %}
    Oh no! Failure. Check the execution results in the web console{~}
    {% else %}
    Successfully deployed flow{~}
    {% endif %}

Imagine if you asked your colleagues to type in that long line every single time they wanted to deploy a pack. It would never be used. However, a simple ChatOps alias, and now it is simple as a single chat command. Using something like this significantly decreases the barrier to entry of experimentation/learning/growing of StackStorm. Folks will be more apt to try something if they see and use tools that give them nearly immediate feedback and know they can safely revert to a known state if need be.

Easy win.

This also has an added benefit of enabling StackStorm adaptable to change. This is absolutely necessary for a successful implementation. When you get feedback, you can quickly turn concerns into wins and previous folks who might have been detractors will become quick allies. It is not hard to see the possibilities once the lightbulb turns on. You also start teaching everyone immediately. Indirectly, team members will see actions being executed, and know that “this is the way to deploy StackStorm code”. It’s quick and painless.

Random Thoughts

Q: This action is tied directly to the packs.install. What about a workflow? Seems like that would be a better way to structure this.

A: Yeah, probably. Whip that thing up, and rapidly deploy the fix. Viola. Everyone wins. You absolutely will find better ways to maintain this or a similar command as you learn how your users interact with it. This is functional, and also has no problems being upgraded.

Q: I would never use this in my environment. There is no security. Anyone can run this command!

A: That’s fantastic! I also would not suggest running something this open in a production environment. There is a sliding scale between usability and security. This is very cleary leaning toward the usability end of the spectrum. But, by being able to rapidly iterate, you could build out something like Confirm ChatOps Action (credit: Igor Cherkaev), and implement the security you need. Combine that with fast iterations, you can grow something suitable for even the most stringent of environments.

Q: Could I use this pattern to deploy, say my SuperCoolDisruptingApp?

A: YES! When you provide smart people tools to do their job, you’ll be amazed how fast they are adopted. Use ChatOps to reduce friction in daily life where possible.

Let’s get going!

The keys: do not let great be the enemy of good, and constantly iterate. Your automation journey begins with the first step. Take this with you, it’s dangerous out there alone.

dangerous out there!

Want to see more StackStorm Quick Tips or have a tip of your own share? Let us know! Send us a tweet: (@Stack_Storm) with the hashtag #st2quicktip. Visit us at to learn more about the product and team.