Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
SAKE(1)				  Sake Manual			       SAKE(1)

NAME
       sake - sake is a	task runner for	local and remote hosts

SYNOPSIS
       sake [command] [flags]

DESCRIPTION
       sake is a task runner for local and remote hosts.

       You  define  servers  and tasks in a sake.yaml config file and then run
       the tasks on the	servers.

OPTIONS
       -c, --config=""
	      specify config

       -u, --user-config=""
	      specify user config

       --ssh-config=""
	      specify ssh config

       --no-color[=false]
	      disable color

       -h, --help[=false]
	      help for sake

COMMANDS
       check  Validate config.

       run <task> [flags]
	      Run tasks	specified in a sake.yaml file.

	      Available	Options:

		     --dry-run[=false]
			    print the task to see what will be executed

		     --describe[=false]
			    print task information

		     --list-hosts[=false]
			    print hosts	that will be targetted

		     -V, --verbose[=false]
			    enable all diagnostics

		     -S, --strategy=""
			    set	execution strategy [linear|host_pinned|free]

		     -f, --forks=10000
			    max	number of concurrent processes

		     -b, --batch=0
			    set	number of hosts	to run in parallel

		     -B, --batch-p=0
			    set	percentage of hosts to run in parallel [0-100]

		     -a, --all[=false]
			    target all hosts

		     -v, --invert[=false]
			    invert matching on hosts

		     -r, --regex=""
			    target hosts on host regex

		     -s, --servers=[]
			    target servers by names

		     -t, --tags=[]
			    target hosts by tags

		     -T, --target=""
			    target hosts by target name

		     --order=""
			    order hosts

		     -l, --limit=0
			    set	limit of servers to target

		     -L, --limit-p=0
			    set	percentage of servers to target	[0-100]

		     --ignore-unreachable[=false]
			    ignore unreachable hosts

		     -M, --max-fail-percentage=0
			    stop task execution	on all servers when  threshold
			    reached

		     --any-errors-fatal[=false]
			    stop task execution	on all servers on error

		     --ignore-errors[=false]
			    continue task execution on errors

		     -J, --spec=""
			    set	spec

		     -o, --output=""
			    set	 task  output  [text|table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv|none]

		     -p, --print=""
			    set	print [all|stdout|stderr]

		     --omit-empty-rows[=false]
			    omit empty row for table output

		     --omit-empty-columns[=false]
			    omit empty column for table	output

		     -q, --silent[=false]
			    omit showing loader	when running tasks

		     --confirm[=false]
			    confirm root task before running

		     --step[=false]
			    confirm each task before running

		     --tty[=false]
			    replace the	current	process

		     --attach[=false]
			    ssh	to server after	command

		     --local[=false]
			    run	task on	localhost

		     --theme="default"
			    set	theme

		     -e, --edit[=false]
			    edit task

		     -R, --report=[recap]
			    reports to show

		     -i, --identity-file=""
			    set	identity file

		     -U, --user=""
			    set	ssh user

		     --password=""
			    set	ssh password

		     --known-hosts-file=""
			    set	known hosts file

       exec <command> [flags]
	      Execute arbitrary	commands.

	      Single quote your	command	if you don't want  the	file  globbing
	      and  environments	 variables  expansion to take place before the
	      command gets executed in each directory.

	      Available	Options:

		     --dry-run[=false]
			    prints the command to see what will	be executed

		     --describe[=false]
			    print task information

		     --list-hosts[=false]
			    print hosts	that will be targetted

		     -V, --verbose[=false]
			    enable all diagnostics

		     -S, --strategy=""
			    set	execution strategy [linear|host_pinned|free]

		     -f, --forks=10000
			    max	number of concurrent processes

		     -b, --batch=0
			    set	number of hosts	to run in parallel

		     -B, --batch-p=0
			    set	percentage  of	servers	 to  run  in  parallel
			    [0-100]

		     -a, --all[=false]
			    target all servers

		     -v, --invert[=false]
			    invert matching on servers

		     -r, --regex=""
			    filter servers on host regex

		     -s, --servers=[]
			    target servers by names

		     -t, --tags=[]
			    target servers by tags

		     -T, --target=""
			    target servers by target name

		     --order=""
			    order hosts

		     -l, --limit=0
			    set	limit of servers to target

		     -L, --limit-p=0
			    set	percentage of servers to target

		     --ignore-unreachable[=false]
			    ignore unreachable hosts

		     -M, --max-fail-percentage=0
			    stop  task execution on all	servers	when threshold
			    reached

		     --any-errors-fatal[=false]
			    stop task execution	on all servers on error

		     --ignore-errors[=false]
			    continue task execution on errors

		     -J, --spec=""
			    set	spec

		     -o, --output=""
			    set	 task  output  [text|table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv|none]

		     -p, --print=""
			    set	print [all|stdout|stderr]

		     --omit-empty-rows[=false]
			    omit empty row for table output

		     --omit-empty-columns[=false]
			    omit empty column for table	output

		     -q, --silent[=false]
			    omit showing loader	when running tasks

		     --confirm[=false]
			    confirm root task before running

		     --step[=false]
			    confirm each task before running

		     --tty[=false]
			    replace the	current	process

		     --attach[=false]
			    ssh	to server after	command

		     --local[=false]
			    run	command	on localhost

		     --theme="default"
			    set	theme

		     -R, --report=[recap]
			    reports to show

		     -i, --identity-file=""
			    set	identity file for all servers

		     -U, --user=""
			    set	ssh user

		     --password=""
			    set	ssh password for all servers

		     --known-hosts-file=""
			    set	known hosts file

       init [flags]
	      Initialize sake in the current directory.

       edit [flags]
	      Open up sake config file in $EDITOR.

       edit server [server]
	      Open up sake config file in $EDITOR and go to servers section.

       edit task [task]
	      Open up sake config file in $EDITOR and go to tasks section.

       edit target [target]
	      Open up sake config file in $EDITOR and go to targets section.

       edit spec [spec]
	      Open up sake config file in $EDITOR and go to specs section.

       list servers [servers] [flags]
	      List servers.

	      Available	Options:

		     -v, --invert[=false]
			    invert matching on servers

		     -r, --regex=""
			    filter servers on host regex

		     -t, --tags=[]
			    filter servers by tags

		     -H, --all-headers[=false]
			    select all server headers

		     --headers=[server,host,tags,desc]
			    set	headers

		     -o, --output="table"
			    set	   table   output   [table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv]

		     --theme="default"
			    set	theme

       list tasks [tasks] [flags]
	      List tasks.

	      Available	Options:

		     -H, --all-headers[=false]
			    select all task headers

		     --headers=[task,desc]
			    set	headers

		     -o, --output="table"
			    set	  table	  output    [table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv]

		     --theme="default"
			    set	theme

       list tags [tags]	[flags]
	      List tags.

	      Available	Options:

		     --headers=[tag,server]
			    set	headers

		     -o, --output="table"
			    set	   table   output   [table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv]

		     --theme="default"
			    set	theme

       list targets [targets] [flags]
	      List targets.

	      Available	Options:

		     --headers=[target,desc,all,servers,tags,regex,in-
		     vert,limit,limit_p]
			    set	headers. Available headers: name, regex

		     -o, --output="table"
			    set	  table	  output    [table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv]

		     --theme="default"
			    set	theme

       list specs [specs] [flags]
	      List specs.

	      Available	Options:

		     --headers=[spec,desc,describe,list_hosts,or-
		     der,silent,hidden,strategy,batch,batch_p,forks,out-
		     put,print,any_errors_fatal,max_fail_percentage,ignore_er-
		     rors,ignore_unreachable,omit_empty,report,verbose,con-
		     firm,step]
			    set	headers

		     -o, --output="table"
			    set	   table   output   [table|table-2|table-3|ta-
			    ble-4|html|markdown|json|csv]

		     --theme="default"
			    set	theme

       describe	servers	[servers] [flags]
	      Describe servers.

	      Available	Options:

		     -t, --tags=[]
			    filter servers by their tag

		     -r, --regex=""
			    filter servers on host regex

		     -v, --invert[=false]
			    invert matching on servers

		     -e, --edit[=false]
			    edit server

       describe	tasks [tasks] [flags]
	      Describe tasks.

	      Available	Options:

		     -e, --edit[=false]
			    edit task

       describe	targets	[targets] [flags]
	      Describe targets.

	      Available	Options:

		     -e, --edit[=false]
			    edit target

       describe	specs [specs] [flags]
	      Describe specs.

	      Available	Options:

		     -e, --edit[=false]
			    edit spec

       ssh <server> [flags]
	      ssh to server.

	      Available	Options:

		     -i, --identity-file=""
			    set	identity file for all servers

		     --password=""
			    set	ssh password for all servers

       gen [flags]
	      Generate man page

	      Available	Options:

		     -d, --dir="./"
			    directory to save manpage to

CONFIG
       The sake.yaml config is based on	the following concepts:

	  servers are servers,	local or remote, that have a host

	  tasks are shell commands that you write and then run	 for  selected
	   servers

	  specs are configs that alter	task execution and output

	  targets  are	 configs  that	provide	shorthand filtering of servers
	   when	executing tasks

	  themes are used to modify the output	of sake	commands

       Specs, targets and themes come with a default setting that the user can
       override.

       Check the files and environment section to see how the config  file  is
       loaded.

       Below is	a config file detailing	all of the available options and their
       defaults.

	    # Import servers/tasks/env/specs/themes/targets from other configs
	   [optional]
	    import:
	      -	./some-dir/sake.yaml

	    #  Verify  SSH  host  connections. Set this	to true	if you wish to
	   circumvent verify host [optional]
	    disable_verify_host: false

	    # Set known_hosts_file path. Default is users ssh  home  directory
	   [optional]
	    # known_hosts_file:	$HOME/.ssh/known_hosts

	    # Set timeout for ssh connections in seconds
	    # default_timeout: 20

	    # Shell used for commands [optional]
	    # If you use any other program than	bash, zsh, sh, node, or	python
	    #  then  you have to provide the command flag if you want the com-
	   mand-line string evaluted
	    # For instance: bash -c
	    shell: bash

	    # List of Servers
	    servers:
	      #	Server name [required]
	      media:
		# Server description [optional]
		desc: media server

		# Host [required]
		host: media.lan
		# one-line for setting user and	port
		# host:	samir@media.lan:22

		# Specify multiple hosts:
		# hosts:
		# - samir@192.168.0.1:22
		# - samir@l92.168.1.1:22

		# or use a host	range generator
		# hosts: samir@192.168.[0:1].1:22

		# generate hosts by local command
		# inventory: echo samir@192.168.0.1:22 samir@192.168.1.1:22

		#      Bastion	    [optional]			      bastion:
	   samir@192.168.1.1:2222

		# Bastions [optional]
		# bastions: [samir@192.168.1.1:2222, samir@192.168.1.2:3333]

		#  User	 to  connect  as. It defaults to the current user [op-
	   tional]
		user: samir

		# Port for ssh [optional]
		port: 22

		# Shell	used for commands [optional]
		shell: bash

		# Run on localhost [optional]
		local: false

		# Set default working directory	for task execution [optional]
		work_dir: ""

		# Set identity file. By	default	it will	attempt	to establish a
	   connection using a SSH auth agent [optional]
		# sake respects	users ssh config, so you can set auth  creden-
	   tials in the	users ssh config
		identity_file: ./id_rsa

		#  Set	password.  Accepts  either a string or a shell command
	   [optional]
		password: $(echo $MY_SECRET_PASSWORD)

		# List of tags [optional]
		tags: [remote]

		# List of server specific environment variables	[optional]
		env:
		  # Simple string value
		  key: value

		  # Shell command substitution (evaluated on localhost)
		  date:	$(date -u +"%Y-%m-%dT%H:%M:%S%Z")

	    # List of environment variables that are available to all tasks
	    env:
	      #	Simple string value
	      AUTHOR: "alajmo"

	      #	Shell command substitution (evaluated on localhost)
	      DATE: $(date -u +"%Y-%m-%dT%H:%M:%S%Z")

	    # List of themes
	    themes:
	      #	Theme name
	      default:
		# Text options [optional]
		text:
		  # Set	host prefix for	each line [optional]
		  # Available variables: `.Name`, `.Index`, `.Host`,  `.Port`,
	   `.User`
		  prefix: '{{ .Host }}'

		  #  Colors  to	 alternate between for each server prefix [op-
	   tional]
		  # Available options: green, blue, red, yellow, magenta, cyan
		  prefix_colors: ["green", "blue", "red", "yellow", "magenta",
	   "cyan"]

		  # Customize the task header that is printed before each task
	   when	output is set to text (to opt out, set	it  to	empty  string)
	   [optional]
		  #  Available	variables:  `.Name`, `.Desc`, `.Index`,	`.Num-
	   Tasks`
		  # Available methods: `.Style`, which takes in	1 or more  pa-
	   rameters,  first  is	 the  string  to  be  styled, and the rest are
	   styling options
		  # Available styling options:
		  #   Colors (prefix with `fg_`	for foreground,	and `bg_`  for
	   background):	black, red, green, yellow, blue, magenta, cyan,	white,
	   hi_black,   hi_red,	 hi_green,   hi_yellow,	 hi_blue,  hi_magenta,
	   hi_cyan, hi_white
		  #    Attributes:  normal,  bold,  faint,  italic,  underline
	   crossed_out
		  header:  '{{	.Style "TASK" "bold" }}{{ if ne	.NumTasks 1 }}
	   ({{ .Index }}/{{ .NumTasks  }}){{end}}{{  if	 and  .Name  .Desc  }}
	   [{{.Style  .Name  "bold"}}:	{{  .Desc  }}] {{ else if .Name	}} [{{
	   .Name }}] {{	else if	.Desc }} [{{ .Desc }}] {{end}}'

		  # Fill remaining spaces with a character after  the  header,
	   if set to empty string, no filler characters	will be	displayed [op-
	   tional]
		  header_filler: "*"

		# Table	options	[optional]
		table:
		  # Table style	[optional]
		  # Available options: ascii, connected-light
		  style: ascii

		  # Set	host prefix [optional]
		  #  Available variables: `.Name`, `.Index`, `.Host`, `.Port`,
	   `.User`
		  prefix: '{{ .Host }}'

		  # Border options for table output [optional]
		  options:
		    draw_border: false
		    separate_columns: true
		    separate_header: true
		    separate_rows: false
		    separate_footer: false

		  # Color, attr, align,	and format options [optional]
		  # Available options for fg/bg: green,	blue, red, yellow, ma-
	   genta, cyan,	 hi_green,  hi_blue,  hi_red,  hi_yellow,  hi_magenta,
	   hi_cyan
		  # Available options for align: left, center, justify,	right
		  #  Available	options	for attr: normal, bold,	faint, italic,
	   underline, crossed_out
		  # Available options for format: default, lower, title, upper
		  title:
		    fg:
		    bg:
		    align:
		    attr:
		    format:

		  header:
		    fg:
		    bg:
		    align:
		    attr:
		    format:

		  row:
		    fg:
		    bg:
		    align:
		    attr:
		    format:

		  footer:
		    fg:
		    bg:
		    align:
		    attr:
		    format:

		  border:
		    header:
		      fg:
		      bg:
		      attr:

		    row:
		      fg:
		      bg:
		      attr:

		    row_alt:
		      fg:
		      bg:
		      attr:

		    footer:
		      fg:
		      bg:
		      attr:

	    # List of Specs [optional]
	    specs:
	      default:
		# Spec description
		desc: default spec

		# Print	task description
		describe: false

		# Print	list of	hosts that will	be targetted
		list_hosts: false

		#    Order    hosts    [inventory|reverse_inventory|sorted|re-
	   verse_sorted|random]
		order: inventory

		# Omit showing loader when running tasks
		silent:	false

		# Execution strategy [linear|host_pinned|free]
		strategy: linear

		# Number of hosts to run in parallel
		batch: 1

		# Number of hosts in percentage	to run in parallel [0-100]
		# batch_p: 100

		# Max number of	forks
		forks: 10000

		#     Set    task    output    [text|table|table-2|table-3|ta-
	   ble-4|html|markdown|json|csv|none]
		output:	text

		# Limit	output [stdout|stderr|all]
		print: all

		# Hide task from auto-completion
		hidden:	false

		# Continue task	execution on errors
		ignore_errors: true

		# Stop task execution on any error
		any_errors_fatal: false

		# Max number of	tasks to fail before aborting
		max_fail_percentage: 100

		# Ignore unreachable hosts
		ignore_unreachable: false

		# Omit empty rows for table output
		omit_empty_rows: false

		# Omit empty columns for table output
		omit_empty_columns: false

		# Show task reports [recap|rc|task|time|all]
		report:	[recap]

		# Verbose turns	on describe, list_hosts	and report set to all
		verbose: false

		# Confirm invoked task before running
		confirm: false

		# Confirm each task before running
		step: false

	    # List of targets [optional]
	    targets:
	      default:
		# Target description
		desc: ""

		# Target all hosts
		all: false

		# Specify hosts	via server name
		servers: []

		# Specify hosts	via server tags
		tags: []

		# Limit	number of hosts	to target
		limit: 0

		# Limit	number of hosts	to target in percentage
		limit_p: 100

		# Invert matching on hosts
		invert:	false

		# Specify host regex
		regex: ""

	    # List of tasks
	    tasks:
	      #	Command	ID [required]
	      simple-1:
		# The name that	will be	displayed when	executing  or  listing
	   tasks. Defaults to task ID [optional]
		name: Simple

		# Script to run
		cmd: |
		  echo "hello world"
		desc: simple command 1

	      #	Short-form for a command
	      simple-2:	echo "hello world"

	      #	Command	ID [required]
	      advanced-command:
		#  The	name  that will	be displayed when executing or listing
	   tasks. Defaults to task ID [optional]
		name: Advanced Command

		# Task description [optional]
		desc: Advanced task

		# Specify theme	[optional]
		theme: default

		# Spec reference [optional]
		# spec:	default

		# Or specify specs inline
		spec:
		  output: table
		  ignore_errors: true
		  ignore_unreachable: true
		  any_errors_fatal: false
		  omit_empty_rows: true
		  omit_empty_columns: true

		# Target reference [optional]
		# target: default

		# Or specify targets inline
		target:
		  all: true
		  servers: [media]
		  tags:	[remote]
		  limit: 1

		# List of environment variables	[optional]
		env:
		  # Simple string value
		  release: v1.0.0

		  # Shell command substitution
		  num_lines: $(ls -1 | wc -l)

		  # The	following variables are	available by default:
		  #   S_NAME
		  #   S_HOST
		  #   S_USER
		  #   S_PORT
		  #   S_BASTION
		  #   S_TAGS
		  #   S_IDENTITY
		  #   SAKE_DIR
		  #   SAKE_PATH

		# Run on localhost [optional]
		local: false

		# Set default working directory	for task [optional]
		work_dir: ""

		# Shell	used for commands [optional]
		shell: bash

		# Each task can	only define:
		# - a single cmd
		# - or a single	task reference
		# - or a list of task references and commands

		# Single command
		cmd: |
		  echo complex
		  echo command

		# Task reference. work_dir and env variables are passed	down
		task: simple-1

		# List of task references or commands
		tasks:
		  # Command
		  - name: inline-command
		    cmd: echo "Hello World"
		    ignore_errors: true
		    work_dir: /tmp
		    shell: bash
		    env:
		      foo: bar

		  # Task reference. work_dir  and  env	variables  are	passed
	   down.
		  # Nested task	referencing is supported and will result in a
		  # flat list of commands
		  - task: simple-1
		    ignore_errors: true
		    work_dir: /tmp
		    register: results
		    env:
		      foo: bar

		  - name: output
		    cmd: echo $results_stdout

EXAMPLES
       Initialize sake
	      ~	$ sake init

	      Initialized sake in /tmp
	      -	Created	sake.yaml

	      Following	servers	were added to sake.yaml

	       Server	 | Host
	      -----------+---------
	       localhost | 0.0.0.0

       List all	servers
	      ~	$ sake list servers

	       Server	 | Host
	      -----------+---------
	       localhost | 0.0.0.0

       List all	tasks
	      ~	$ sake list tasks

	       Task | Description
	      ------+-------------
	       ping | Pong

       Describe	a task
	      ~	$ sake describe	task ping

	      name: ping
	      desc: ping server
	      local: false
	      work_dir:
	      theme: default
	      target:
		  all: true
	      spec:
		  output: text
		  ignore_unreachable: true
		  omit_empty_rows: true
		  omit_empty_columns: true
	      cmd:
		  echo pong

       Run a task for all servers with tag 'local'
	      ~	$ sake run many	--tags local

	      TASK [ping: Pong]	********************

	      0.0.0.0 |	pong

       Run ad-hoc command for all servers
	      ~	$ sake exec --all --output table 'echo 123'

	       Server	 | Output
	      -----------+--------
	       localhost | 123

FILES
       When  running  a	command, sake will check the current directory and all
       parent  directories  for	 the  following	 files:	 sake.yaml,  sake.yml,
       .sake.yaml, .sake.yml.

       Additionally, it	will import (if	found) a config	file from:

	  Linux: $XDG_CONFIG_HOME/sake/config.yaml or $HOME/.config/sake/con-
	   fig.yaml if $XDG_CONFIG_HOME	is not set.

	  Darwin: $HOME/Library/Application/sake

       Both  the config	and user config	can be specified via flags or environ-
       ments variables.

ENVIRONMENT
       SAKE_CONFIG
	      Override config file path

       SAKE_USER_CONFIG
	      Override user config file	path

       SAKE_SSH_CONFIG
	      Override ssh config file path

       SAKE_KNOWN_HOSTS_FILE
	      Override known_hosts file	path

       NO_COLOR
	      If this env variable is set (regardless of value)	then all  col-
	      ors will be disabled

BUGS
       See GitHub Issues: <https://github.com/alajmo/sake/issues>.

AUTHOR
       sake  was  written by Samir Alajmovic <alajmovic.samir@gmail.com>.  For
       updates	 and   more   information   go	 to   sakecli.com    <https://
       www.sakecli.com>.

v0.15.1			    2023-09-25T11:47:19CEST		       SAKE(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=sake&sektion=1&manpath=FreeBSD+Ports+14.3.quarterly>

home | help