Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Example: commands-example

Inputs

No sample input files found for this example. (expected under /home/kalabelt/dev/sus/examples/inputs/commands-example-samples or /home/kalabelt/dev/sus/examples/inputs/commands-example)

Profile

# Example Profile: Command Execution
# This profile demonstrates the command execution features in sus
#
# Commands are organized into groups, with each group containing one or more
# inline commands. Group-level settings (os, arch, ignore-errors, etc.) are
# inherited by all commands in the group, but can be overridden per-command.

# Simple command group - runs on any platform
[[commands]]
  name = "Echo Test"
  ignore-errors = true
    [[commands.commands]]
      command = "echo 'Hello from sus profile'"

# OS-specific command groups
[[commands]]
  name = "Windows System Info"
  os = ["windows"]
  ignore-errors = true
  target = "local"
    [[commands.commands]]
      command = "systeminfo"

[[commands]]
  name = "Linux System Info"
  os = ["linux"]
  target = "local"
    [[commands.commands]]
      command = "uname -a"

[[commands]]
  name = "macOS System Info"
  os = ["macos"]
  target = "local"
    [[commands.commands]]
      command = "sw_vers"

# Command group with architecture filter
[[commands]]
  name = "x86_64 Specific"
  arch = ["x86-64"]
  ignore-errors = true
    [[commands.commands]]
      command = "echo 'Running on x86_64'"

# Command group with environment variables (inherited by all commands)
[[commands]]
  name = "Environment Test"
  os = ["linux", "macos"]
  env = [["CUSTOM_VAR", "custom_value"]]
  ignore-errors = true
    [[commands.commands]]
      command = "echo $CUSTOM_VAR"
    [[commands.commands]]
      command = "printenv CUSTOM_VAR"

# Command group with working directory
[[commands]]
  name = "List Temp Directory"
  os = ["linux", "macos"]
  working-dir = "/tmp"
  ignore-errors = true
    [[commands.commands]]
      command = "ls -la"

# Multiple commands in a group sharing settings
[[commands]]
  name = "Hardware Info"
  os = ["linux"]
  ignore-errors = true
    [[commands.commands]]
      command = "lscpu"
    [[commands.commands]]
      command = "free -h"
    [[commands.commands]]
      command = "df -h"

# Network information group
[[commands]]
  name = "Network Info"
  os = ["linux"]
  ignore-errors = true
    [[commands.commands]]
      command = "ip addr show"
    [[commands.commands]]
      command = "ip route show"

# Command group with a matrix - runs all commands for each OS/arch combination
[[commands]]
  name = "Cross-Platform Matrix"
  ignore-errors = true
    [commands.matrix]
      os = ["linux"]
      arch = ["x86-64"]
    [[commands.commands]]
      command = "uname -m"
    [[commands.commands]]
      command = "echo 'Platform-specific check'"

# Per-command overrides within a group
[[commands]]
  name = "Mixed Error Handling"
  ignore-errors = true
    [[commands.commands]]
      command = "echo 'This can fail'"
    [[commands.commands]]
      command = "critical-command"
      ignore-errors = false
    [[commands.commands]]
      command = "echo 'This also can fail'"

# Agent-targeted command group
[[commands]]
  name = "Agent Commands"
  os = ["linux"]
  target = "agent"
  ignore-errors = true
    [[commands.commands]]
      command = "hostname"
    [[commands.commands]]
      command = "uptime"

Report outputs

No outputs found for this example (expected: /home/kalabelt/dev/sus/examples/outputs/commands-example). Run the example to generate outputs.