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
- Select HTTP as the traffic type
- Set the internal port to 443
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 variablesENV ST2_AUTH_URL=https://your-app-name.klutch.sh/authENV ST2_API_URL=https://your-app-name.klutch.sh/apiENV ST2_STREAM_URL=https://your-app-name.klutch.sh/stream
# Install additional packsRUN /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 1Create 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:
Set Environment Variables
Configure the following environment variables:
| Variable | Value |
|---|---|
ST2_AUTH_URL | https://your-app-name.klutch.sh/auth |
ST2_API_URL | https://your-app-name.klutch.sh/api |
ST2_STREAM_URL | https://your-app-name.klutch.sh/stream |
MONGO_HOST | MongoDB host |
MONGO_PORT | 27017 |
MONGO_DB | st2 |
MONGO_USER | MongoDB username |
MONGO_PASS | MongoDB password |
RABBITMQ_HOST | RabbitMQ host |
RABBITMQ_USER | RabbitMQ username |
RABBITMQ_PASS | RabbitMQ password |
REDIS_HOST | Redis host |
Attach Persistent Volumes
Add the following volumes:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/opt/stackstorm/packs | 20 GB | Installed packs |
/opt/stackstorm/keys | 1 GB | SSH keys and secrets |
/opt/stackstorm/virtualenvs | 10 GB | Pack 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:
st2-register-content --config-file /etc/st2/st2.conf --register-allst2 user create admin --password 'your-password'Installing Packs
Install automation packs:
# Install from StackStorm Exchangest2 pack install awsst2 pack install slackst2 pack install kubernetes
# List installed packsst2 pack listConfiguring Packs
Each pack requires configuration:
# Configure Slack packst2 pack config slack
# View pack configurationst2 pack get slackStackStorm Concepts
Triggers
Events that start automation:
| Trigger Type | Example |
|---|---|
| Webhook | HTTP POST from external service |
| Timer | Scheduled intervals |
| Sensor | Poll external systems |
| Manual | CLI or API invocation |
Actions
Tasks that automation performs:
| Action Type | Example |
|---|---|
| Shell | Run shell commands |
| Remote | Execute on remote hosts via SSH |
| HTTP | Make API requests |
| Python | Run 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.0description: 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
- Install the Slack pack
- Create a Slack bot
- Configure bot token in StackStorm
- 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: 80action: 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: 3600Troubleshooting
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
- StackStorm Official Site
- StackStorm Documentation
- StackStorm GitHub Repository
- StackStorm Exchange
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
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.