Sake Task Runner

website·Indexed 31 days ago

https://sakecli.com/

Sake is a task runner for local and remote hosts that uses a sake.yaml configuration file to define servers and tasks. It supports multiple execution strategies, variable registration, and various output formats for task execution over SSH.

Tokens
12.8K
Snippets
85
Records
115
Agent score
59%

What's inside Sake

  1. Overview of sake command runner

    sake is a command runner for local and remote hosts. It allows users to define servers and tasks in a sake.yaml configuration file and execute those tasks across specified servers. Key features include auto-completion for tasks/servers/tags, SSH access to servers or Docker containers, task output formatting in tables, and the ability to import other sake.yaml configurations.
  2. Overview of sake task runner

    sake is a task runner designed for both local and remote hosts. It relies on a sake.yaml configuration file where servers and tasks are defined, allowing users to execute these tasks across specified environments.
  3. Overview of sake remote task runner

    sake is an ergonomic CLI utility designed to run tasks on remote servers. It is intended as a simpler alternative to complex configuration management tools like Ansible, Puppet, or Chef. It provides a central way to manage server lists (name, host, and description) and allows users to execute ad-hoc commands or defined tasks across one, some, or all configured servers.
  4. Understand core concepts of sake.yaml configuration

    The sake.yaml configuration is built around several key entities that define how the tool interacts with infrastructure and executes commands:

    • servers: Local or remote machines identified by a host.
    • tasks: Shell commands written to be executed against selected servers.
    • specs: Configurations that modify how tasks are executed and how their output is handled.
    • targets: Configuration shorthands used to filter servers when running tasks.
    • themes: Settings used to customize the visual output of sake commands.
    • env: Environment variables defined at global, per-server, or per-task levels.

    Note that specs, targets, and themes include default settings that can be overridden by the user.

  5. Sake execution workflow overview

    The sake tool operates using the following internal sequence:

    1. Parse and validate CLI arguments.
    2. Parse config files to create config, inventory, tasks, specs, and target states.
    3. Create clients for remote and local task execution for selected hosts/tasks.
    4. Execute tasks on remote/local hosts.
    5. Disconnect from remote hosts.
    6. Print results, reports, and errors.
  6. Describe and inspect configuration entities

    The describe command provides detailed information about servers, tasks, targets, or specs. Using the -e or --edit flag while describing an entity will open it for editing.
    # Describe all servers
    sake describe servers
    
    # Describe a specific task
    sake describe task <task>
    
    # Describe and immediately edit a spec
    sake describe specs --edit
  7. Sake performance benchmarks overview

    Sake benchmarks demonstrate that it is between 6 and 8 times faster than pyinfra and between 4 and 18 times faster than Ansible, depending on the number of hosts. Benchmarks are calculated as an average of 20 runs across three metrics:

    • Elapsed Time: Real wall clock time in seconds.
    • CPU: Percentage of CPU usage calculated as (user + sys time) / tot time.
    • Memory: Maximum memory usage in Megabytes (MB) during the process lifetime.

    The benchmark implementation is available at github.com/alajmo/sake-performance.

  8. Generate task execution reports

    Use the --report flag to get an overview of task execution. The recap report is provided by default.
    # Show all available reports
    sake run task --report=all
  9. Install sake CLI on Linux and Mac

    The sake CLI is available for Linux and Mac. It can be installed via a shell script, various package managers, or the Go toolchain. Pre-compiled binaries are also available on the GitHub releases page.
    # Via cURL
    curl -sfL https://raw.githubusercontent.com/alajmo/sake/main/install.sh | sh
    
    # Via Homebrew
    brew tap alajmo/sake
    brew install sake
    
    # Via MacPorts
    sudo port install sake
    
    # Via Arch Linux
    pacman -S sake
    
    # Via pkg
    pkg install sake
    
    # Via Go
    go install github.com/alajmo/sake@latest
  10. Generate sake dependency graphs

    Create SVG dependency graphs using graphviz and goda to visualize the project structure.
    # Generate a specific graph
    goda graph "github.com/alajmo/sake/..." | dot -Tsvg -o res/graph.svg
    
    # Generate a full dependency graph
    goda graph "github.com/alajmo/sake:all" | dot -Tsvg -o res/graph-full.svg
  11. Choose between sake and Ansible

    Decide which tool to use based on your project requirements:

    Choose sake when:

    • You primarily rely on shell scripts.
    • You require real-time output from remote tasks.
    • Maximum performance is a priority.
    • You prefer a simple, non-opinionated tool with fewer concepts to learn.

    Choose Ansible when:

    • You need declarative, idempotent configurations for complex infrastructure.
    • You want to leverage a large community and established industry standard.
    • You need built-in templating (Jinja) and a wide array of pre-built modules.

    Hybrid Approach: You can use Ansible playbooks/roles for initial server configuration and sake for high-performance ad-hoc task execution.

  12. Initialize a new Sake configuration

    Run the sake init command to create a default sake.yaml configuration file. By default, this initializes the project in the current directory (or a temporary directory like /tmp/sake) and adds a default localhost server pointing to 0.0.0.0.
    $ sake init