๐ Getting Started with Sloth Runner¶
Welcome to Sloth Runner - the AI-powered GitOps task orchestration platform! This guide will get you up and running in minutes.
๐ฆ Installation¶
Quick Install (Recommended)¶
Install the latest release with our automated script:
This script: - โ
Detects your OS and architecture automatically - โ
Downloads the latest release from GitHub - โ
Installs to /usr/local/bin - โ
Verifies installation
Note: Requires sudo privileges.
Manual Installation¶
Download from GitHub Releases:
# Linux AMD64
wget https://github.com/chalkan3-sloth/sloth-runner/releases/latest/download/sloth-runner-linux-amd64.tar.gz
tar xzf sloth-runner-linux-amd64.tar.gz
sudo mv sloth-runner /usr/local/bin/
# macOS ARM64 (Apple Silicon)
wget https://github.com/chalkan3-sloth/sloth-runner/releases/latest/download/sloth-runner-darwin-arm64.tar.gz
tar xzf sloth-runner-darwin-arm64.tar.gz
sudo mv sloth-runner /usr/local/bin/
Verify Installation¶
๐ฏ Quick Start¶
Your First Workflow¶
Create a simple workflow file hello.sloth:
-- hello.sloth
local hello_task = task("hello")
:description("My first task")
:command(function(this, params)
print("๐ฆฅ Hello from Sloth Runner!")
return true, "Task completed successfully"
end)
:build()
workflow
.define("hello_workflow")
:description("Hello world workflow")
:version("1.0.0")
:tasks({hello_task})
Run it:
Modern Output Styles¶
Try different output formats:
# Basic output
sloth-runner run -f hello.sloth -o basic
# Enhanced with colors and icons
sloth-runner run -f hello.sloth -o enhanced
# Rich with progress bars
sloth-runner run -f hello.sloth -o rich
# Modern UI
sloth-runner run -f hello.sloth -o modern
# JSON for CI/CD
sloth-runner run -f hello.sloth -o json
๐ Core Concepts¶
File Extension¶
๐ Important: Sloth Runner uses
.slothextension for workflow files (not.lua). The syntax is still Lua - only the extension changed for better identification.
Tasks¶
Tasks are the building blocks. Define with the builder pattern:
local build_task = task("build")
:description("Build the application")
:command(function(this, params)
return exec.run("go build -o app")
end)
:build()
local test_task = task("test")
:description("Run tests")
:depends_on({"build"})
:command(function(this, params)
return exec.run("go test ./...")
end)
:build()
workflow
.define("ci_pipeline")
:description("CI pipeline")
:version("1.0.0")
:tasks({build_task, test_task})
Task Groups¶
Organize related tasks:
๐๏ธ Stack Management¶
Stacks provide state persistence and environment isolation.
Create a Stack¶
Run with Stack¶
# Run workflow on stack
sloth-runner run prod-app --yes
# Check stack state
sloth-runner stack show prod-app
# List all stacks
sloth-runner stack list
Stack Benefits¶
- โ State persistence between runs
- โ Environment isolation
- โ History tracking
- โ Resource management
๐จ Modern DSL Features¶
Task Builder API¶
local deploy_task = task("deploy")
:description("Deploy to production")
:command(function(this, params)
-- Check environment condition
if os.getenv("ENV") ~= "prod" then
return false, "Not in production environment"
end
log.info("Deploying...")
local success, output = exec.run("kubectl apply -f k8s/")
if success then
log.info("โ
Deployed successfully!")
else
log.error("โ Deployment failed: " .. output)
end
return success, output
end)
:timeout("5m")
:retries(3)
:build()
workflow
.define("deployment")
:description("Production deployment")
:version("1.0.0")
:tasks({deploy_task})
Values Files¶
Parameterize workflows with values files:
values.yaml:
deploy.sloth:
local env = values.environment
local replicas = values.replicas
local deploy_task = task("deploy")
:description("Deploy application")
:command(function(this, params)
log.info("Deploying to " .. env)
log.info("Replicas: " .. replicas)
return true, "Deployment configuration applied"
end)
:build()
workflow
.define("deploy_workflow")
:description("Deploy with values")
:version("1.0.0")
:tasks({deploy_task})
Run with values:
๐ค Built-in Modules¶
Sloth Runner includes powerful built-in modules:
Example: Docker Deployment¶
local docker = require("docker")
local deploy_container = task("deploy_container")
:description("Deploy nginx container")
:command(function(this, params)
-- Pull image
docker.pull("nginx:latest")
-- Run container
docker.run({
image = "nginx:latest",
name = "web-server",
ports = {"80:80"},
detach = true
})
return true, "Container deployed successfully"
end)
:build()
workflow
.define("docker_deploy")
:description("Deploy Docker container")
:version("1.0.0")
:tasks({deploy_container})
Available Modules¶
- ๐ณ docker - Container management
- โ๏ธ aws, azure, gcp - Cloud providers
- ๐ง systemd - Service management
- ๐ฆ pkg - Package management
- ๐ metrics - Monitoring
- ๐ vault - Secrets management
- ๐ terraform - Infrastructure as Code
๐ญ Common Workflows¶
CI/CD Pipeline¶
local lint_task = task("lint")
:description("Run linter")
:command(function(this, params)
return exec.run("golangci-lint run")
end)
:build()
local test_task = task("test")
:description("Run tests")
:depends_on({"lint"})
:command(function(this, params)
return exec.run("go test -v ./...")
end)
:build()
local build_task = task("build")
:description("Build application")
:depends_on({"test"})
:command(function(this, params)
return exec.run("go build -o app")
end)
:build()
local deploy_task = task("deploy")
:description("Deploy application")
:depends_on({"build"})
:command(function(this, params)
exec.run("docker build -t myapp .")
exec.run("docker push myapp")
exec.run("kubectl rollout restart deployment/myapp")
return true, "Deployment completed"
end)
:build()
workflow
.define("cicd_pipeline")
:description("Complete CI/CD pipeline")
:version("1.0.0")
:tasks({lint_task, test_task, build_task, deploy_task})
Run the pipeline:
Infrastructure Automation¶
local plan_task = task("plan")
:description("Plan Terraform changes")
:command(function(this, params)
return terraform.plan({
dir = "./terraform",
var_file = "prod.tfvars"
})
end)
:build()
local apply_task = task("apply")
:description("Apply Terraform changes")
:depends_on({"plan"})
:command(function(this, params)
return terraform.apply({
dir = "./terraform",
auto_approve = true
})
end)
:build()
workflow
.define("terraform_deploy")
:description("Terraform deployment")
:version("1.0.0")
:tasks({plan_task, apply_task})
๐ Distributed Execution¶
Start Master Server¶
Start Agents¶
On different servers:
# Web server agent
sloth-runner agent start \
--master master.example.com:50053 \
--name web-01 \
--tags web,nginx
# Database agent
sloth-runner agent start \
--master master.example.com:50053 \
--name db-01 \
--tags database,postgres
Distribute Tasks¶
local deploy_web = task("deploy_web")
:description("Reload nginx")
:delegate_to("web-01")
:command(function(this, params)
return exec.run("nginx -s reload")
end)
:build()
local backup_db = task("backup_db")
:description("Backup database")
:delegate_to("db-01")
:command(function(this, params)
return exec.run("pg_dump mydb > backup.sql")
end)
:build()
workflow
.define("distributed_ops")
:description("Distributed operations")
:version("1.0.0")
:tasks({deploy_web, backup_db})
๐ Web Dashboard¶
Start the UI for visual management:
Access at: http://localhost:8080
Features: - ๐ Real-time task monitoring - ๐ค Agent health dashboard - ๐ Scheduler management - ๐ฆ Stack browser - ๐ Metrics and analytics
๐ Scheduler¶
Schedule recurring tasks:
-- In your workflow
schedule("nightly_backup")
:cron("0 2 * * *") -- 2 AM daily
:task("backup")
:build()
Manage from CLI:
# Enable scheduler
sloth-runner scheduler enable
# List scheduled tasks
sloth-runner scheduler list
# Disable scheduler
sloth-runner scheduler disable
๐ก Tips & Best Practices¶
1. Use Stacks for State Management¶
# โ
Good: Use stacks
sloth-runner stack new myapp
sloth-runner run myapp
# โ Avoid: Direct execution without state
sloth-runner run -f workflow.sloth
2. Choose the Right Output Format¶
# Interactive terminal
sloth-runner run -f deploy.sloth -o rich
# CI/CD pipelines
sloth-runner run -f ci.sloth -o json
# Simple scripts
sloth-runner run -f task.sloth -o basic
3. Use Values Files for Environments¶
# Development
sloth-runner run -f app.sloth -v dev-values.yaml
# Production
sloth-runner run -f app.sloth -v prod-values.yaml
4. Leverage Built-in Modules¶
-- โ Don't shell out unnecessarily
local install_bad = task("install")
:description("Install nginx (bad)")
:command(function(this, params)
return exec.run("apt-get install nginx")
end)
:build()
-- โ
Use built-in modules
local install_good = task("install")
:description("Install nginx (good)")
:command(function(this, params)
return pkg.install({packages = {"nginx"}})
end)
:build()
๐ Next Steps¶
Now that you're started, explore more:
- ๐ Core Concepts - Deep dive into architecture
- ๐จ Modern DSL - Advanced syntax
- ๐ง CLI Reference - All commands
- ๐ฆ Modules - Built-in capabilities
- ๐ญ Examples - Real-world workflows
- ๐ค AI Features - Intelligent optimization
- ๐ GitOps - Automated deployments
๐ Getting Help¶
- ๐ Documentation: Full docs
- ๐ฌ Community: GitHub Discussions
- ๐ Issues: Bug Reports
- ๐ Examples: Example Repository
Ready to automate? Create your first workflow and start orchestrating! ๐
English | Portuguรชs | ไธญๆ