Execute shell commands and scripts directly from your runbooks to interact with your infrastructure.

Supported Shells

  • Bash
  • Sh
  • Zsh

Command Format

# Single command
command --flag value

# Multi-line command
command1 && \
  command2 | \
  grep 'pattern'

Examples

Basic Command

# Get system uptime
uptime

Piped Commands

# Find and count Java processes
ps aux | grep java | wc -l

Environment Variables

# Use environment variables
echo "Current user is $USER"

Best Practices

  • Keep commands simple and focused
  • Use full paths to binaries when possible
  • Handle errors with || operator
  • Use set -e at the start of scripts to fail fast

Security Considerations

  • Avoid using root privileges unless necessary
  • Never include sensitive data directly in commands
  • Use environment variables for secrets
  • Validate all user inputs