Skip to content

Deploying StackStorm

Introduction

StackStorm (ST2) is a powerful event-driven automation platform that enables you to tie together all your tools through sensors, triggers, rules, and actions. It provides IFTTT-like automation for infrastructure management, security incident response, continuous deployment, and ChatOps workflows.

Built on a robust architecture with Python-based components, StackStorm integrates with hundreds of tools through its extensive pack ecosystem. From AWS to Slack, from Kubernetes to Jira, StackStorm connects your entire toolchain into automated workflows.

Key highlights of StackStorm:

  • Event-Driven: React to events from any source in real-time
  • Extensive Integrations: 100+ packs for popular tools and services
  • Workflows: Chain actions together with complex logic
  • Rules Engine: Define when and how automation triggers
  • ChatOps: Control automation through Slack, Microsoft Teams, or IRC
  • RBAC: Role-based access control for enterprise use
  • Audit Trail: Complete logging of all automation actions
  • API-First: RESTful API for all operations
  • Web UI: Visual interface for management and monitoring
  • CLI Tools: Full command-line interface
  • Python-Based: Easy to extend with Python
  • Open Source: Apache 2.0 licensed

This guide walks through deploying StackStorm on Klutch.sh using Docker for event-driven automation.

Why Deploy StackStorm on Klutch.sh

Deploying StackStorm on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh handles the complex multi-component deployment.

Persistent Storage: Rules, workflows, and execution history persist across deployments.

HTTPS by Default: Secure API access with automatic SSL certificates.

GitHub Integration: Version control your automation packs and deploy updates automatically.

Scalable Resources: Allocate resources based on automation workload.

Environment Variable Management: Securely store API keys and credentials.

Custom Domains: Use a professional domain for your automation platform.

High Availability: Keep your automation running 24/7.

Prerequisites

Before deploying StackStorm on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your configuration
  • MongoDB database (can be deployed on Klutch.sh or external)
  • RabbitMQ instance for messaging
  • Redis instance for coordination
  • Basic familiarity with Docker and automation concepts
  • (Optional) A custom domain for your StackStorm instance

Deploying StackStorm on Klutch.sh

    Create a GitHub Repository

    Create a new GitHub repository for your StackStorm deployment.

    Create Your Dockerfile

    Create a Dockerfile in your repository:

    FROM stackstorm/stackstorm:latest
    # Set environment variables
    ENV ST2_AUTH_URL=https://your-app-name.klutch.sh/auth
    ENV ST2_API_URL=https://your-app-name.klutch.sh/api
    ENV ST2_STREAM_URL=https://your-app-name.klutch.sh/stream
    # Install additional packs
    RUN /opt/stackstorm/st2/bin/st2ctl reload --register-all
    EXPOSE 443
    HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD curl -f http://localhost:9101/healthcheck || exit 1

    Create docker-compose Configuration

    For a complete StackStorm deployment, create docker-compose.yml:

    version: '3.8'
    services:
    stackstorm:
    image: stackstorm/stackstorm:latest
    environment:
    - ST2_AUTH_URL=${ST2_AUTH_URL}
    - ST2_API_URL=${ST2_API_URL}
    - ST2_STREAM_URL=${ST2_STREAM_URL}
    - MONGO_HOST=${MONGO_HOST}
    - MONGO_PORT=${MONGO_PORT}
    - MONGO_DB=${MONGO_DB}
    - MONGO_USER=${MONGO_USER}
    - MONGO_PASS=${MONGO_PASS}
    - RABBITMQ_HOST=${RABBITMQ_HOST}
    - RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}
    - RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASS}
    - REDIS_HOST=${REDIS_HOST}
    volumes:
    - st2-data:/opt/stackstorm/packs
    - st2-keys:/opt/stackstorm/keys
    ports:
    - "443:443"
    volumes:
    st2-data:
    st2-keys:

    Push Your Repository to GitHub

    Commit and push your configuration.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project.

    Create a New App

    Within your project, create a new app and connect your GitHub repository.

    Configure HTTP Traffic

    In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 443

    Set Environment Variables

    Configure the following environment variables:

    VariableValue
    ST2_AUTH_URLhttps://your-app-name.klutch.sh/auth
    ST2_API_URLhttps://your-app-name.klutch.sh/api
    ST2_STREAM_URLhttps://your-app-name.klutch.sh/stream
    MONGO_HOSTMongoDB host
    MONGO_PORT27017
    MONGO_DBst2
    MONGO_USERMongoDB username
    MONGO_PASSMongoDB password
    RABBITMQ_HOSTRabbitMQ host
    RABBITMQ_USERRabbitMQ username
    RABBITMQ_PASSRabbitMQ password
    REDIS_HOSTRedis host

    Attach Persistent Volumes

    Add the following volumes:

    Mount PathRecommended SizePurpose
    /opt/stackstorm/packs20 GBInstalled packs
    /opt/stackstorm/keys1 GBSSH keys and secrets
    /opt/stackstorm/virtualenvs10 GBPack virtual environments

    Deploy Your Application

    Click Deploy to build and start StackStorm.

    Access StackStorm

    Once deployment completes, access StackStorm at https://your-app-name.klutch.sh.

Initial Configuration

Creating Admin User

After deployment, create an admin user:

Terminal window
st2-register-content --config-file /etc/st2/st2.conf --register-all
st2 user create admin --password 'your-password'

Installing Packs

Install automation packs:

Terminal window
# Install from StackStorm Exchange
st2 pack install aws
st2 pack install slack
st2 pack install kubernetes
# List installed packs
st2 pack list

Configuring Packs

Each pack requires configuration:

Terminal window
# Configure Slack pack
st2 pack config slack
# View pack configuration
st2 pack get slack

StackStorm Concepts

Triggers

Events that start automation:

Trigger TypeExample
WebhookHTTP POST from external service
TimerScheduled intervals
SensorPoll external systems
ManualCLI or API invocation

Actions

Tasks that automation performs:

Action TypeExample
ShellRun shell commands
RemoteExecute on remote hosts via SSH
HTTPMake API requests
PythonRun Python scripts

Rules

Connect triggers to actions:

name: "restart-on-failure"
pack: "mypack"
description: "Restart service on health check failure"
enabled: true
trigger:
type: "monitoring.health_check_failed"
criteria:
trigger.service_name:
type: "equals"
pattern: "api-server"
action:
ref: "linux.service"
parameters:
action: "restart"
service: "{{trigger.service_name}}"

Workflows

Chain multiple actions:

version: 1.0
description: Deploy and notify workflow
tasks:
deploy:
action: kubernetes.deployment_update
input:
deployment: "{{ctx().deployment}}"
image: "{{ctx().image}}"
next:
- when: "{{succeeded()}}"
do: notify_success
- when: "{{failed()}}"
do: notify_failure
notify_success:
action: slack.post_message
input:
channel: "#deployments"
message: "Deployment successful"
notify_failure:
action: slack.post_message
input:
channel: "#deployments"
message: "Deployment failed"

ChatOps Integration

Slack Setup

  1. Install the Slack pack
  2. Create a Slack bot
  3. Configure bot token in StackStorm
  4. Enable ChatOps aliases

Example Aliases

name: "deploy"
pack: "mypack"
description: "Deploy an application"
action_ref: "mypack.deploy"
formats:
- "deploy {{application}} to {{environment}}"

Common Automation Examples

Auto-Scaling

name: "scale-on-load"
trigger:
type: "monitoring.high_cpu"
criteria:
trigger.cpu_percent:
type: "gt"
pattern: 80
action:
ref: "kubernetes.scale_deployment"
parameters:
replicas: "{{trigger.current_replicas + 1}}"

Security Response

name: "block-suspicious-ip"
trigger:
type: "security.intrusion_detected"
action:
ref: "firewall.block_ip"
parameters:
ip: "{{trigger.source_ip}}"
duration: 3600

Troubleshooting

Actions Not Executing

  • Check action logs: st2 execution list
  • Verify pack configuration
  • Check credentials and permissions

Rules Not Triggering

  • Verify trigger is enabled
  • Check criteria syntax
  • Review rule conditions

Pack Installation Failed

  • Check network connectivity
  • Verify pack exists in exchange
  • Review dependency conflicts

Additional Resources

Conclusion

Deploying StackStorm on Klutch.sh gives you a powerful event-driven automation platform that connects your entire toolchain. From infrastructure management to security response to ChatOps, StackStorm automates complex workflows across your organization. With persistent storage, secure HTTPS access, and always-on availability, your automation runs reliably around the clock.