winch exec
run a shell command on hosts
Examples
# show the uptime of every host
winch exec all -- uptime# show the last 50 log lines of the app container on the web hosts
winch exec web -- docker logs app --tail 50# check nginx on the web hosts without web3, as JSON
winch exec 'web & !web3' --json -- systemctl is-active nginxUsage
winch exec <pattern> [flags] -- <command ...>Exec runs a shell command on the hosts of the pattern, in parallel, and shows its output. It makes no plan and asks no question.
A host pattern is a group or a host, with "," for union, "&" for intersection, and "!" for exclusion.
winch joins the words after -- with spaces and runs them through sh -c as root, in /, with stdin from /dev/null.
When the project has secrets, exec needs the age key. It decrypts the secrets, so that its output hides them.
Each host shows one block: the host name, then the output. Hosts with the same output and exit code share one block. A command that exits non-zero adds "exit status N" to its block. winch exits with code 1 when the command fails on a host.
With --json, each host gives one exec event with output and exit_code.
The command stops after 600 seconds, or after --timeout. Each host then sends SIGTERM to the command, and SIGKILL 10 seconds later.
Ctrl-C stops the commands. Each host sends SIGINT to the command, and SIGKILL when it still runs after 10 seconds.
With a terminal, ssh can ask questions, and winch connects to the hosts one at a time. Without one, or with --batch, ssh asks nothing, and winch connects to them in parallel.
Flags
| Flag | Value | Default | Meaning |
|---|---|---|---|
--inventory | <name> | inventory in winch.yaml | inventory for the run |
--user | [<host>=]<name> | from the inventory | SSH login user, for all hosts or one; repeatable |
--batch | no questions from ssh | ||
--timeout | <seconds> | 600 | time limit of the command |
--json | one exec event per host on stdout |
See
winch doc inventorywinch doc remote