Run commands on servers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Emmanuel Cazenave f2e1d878c2
restore compat with libtmux < 0.17 (#75452)
2 weeks ago
.git-blame-ignore-revs misc: add black files/notes 2 years ago
.pre-commit-config.yaml misc: add pyupgrade and isort to pre-commit 2 months ago
COPYING license as GPL 2 years ago
README add basic key automation 2 years ago restore compat with libtmux < 0.17 (#75452) 2 weeks ago


eoptasks - run commands on servers

This script provides parallel remote execution of commands, while having
some special knownledge of servers that should *not* be handled in parallel.

It defers terminal-handling to tmux(1).

It has some targeting capacities using keywords. Commas for 'OR' and slashes
for 'AND', ex: ext/test,saas/test/passerelle will select all external test
servers + all passerelle servers on the SaaS.

It takes any shell command and has some builtin shortcuts such as apt.update
and apt.upgrade.

Requirements: libtmux and pyyaml.


In ~/.config/eoptasks.ini::

 servers = /path/to/servers.yaml
 ignore = server1, server2
 stripsuffix =

It is possible to add extra command shortcuts with additional sections, ex::

 cmd = sudo service memcached restart; /bin/true

It is also possible to declare additional servers, in a [servers] section, ex::

 host.domain = keyword1, keyword2

And custom keywords mapping can be defined, for shortcuts or alternative names,

 monitoring = munin,scrutiny,prometheus

or to prevent common errors or misconceptions::

 saas/test = saas/test,-hds,-re,-docbow

Custom server options can be defined in [server:SERVER_NAME] sections, ex::

  env = TERM=xterm

Any option starting with env will be used to define or replace environment
variables, ex::

  env = TERM=xterm
  env1 = PS1=LANG=C.UTF-8

There is also basic support for automation, mostly for situations where
key-based authentication is not possible. Server sections can have expect and
send entries, when the output ends with an expected string the "send" keys will
be sent (as well as a carriage return), ex::

  expect = password:
  send = my_password


 eoptasks -k test apt.upgrade
  Run (sudo) apt upgrade on all test servers.

 eoptasks -k test,-database sudo apt install python-gadjo
  Run sudo apt install python-gadjo on all test servers except database servers.

 eoptasks -k saas/test/passerelle,ext/test --list-servers
  List servers that have saas AND test AND passerelle keywords, OR the
  ext AND test keywords.

 eoptasks -k saas/prod -x ^node,^database.node,.*docbow sudo apt install publik-base-theme
  Install/upgrade publik-base-theme on all production server of the SaaS excepted
  the hypervisor, database, and docbow nodes.

Code Style

black is used to format the code, using thoses parameters:

    black --target-version py37 --skip-string-normalization --line-length 110

There is .pre-commit-config.yaml to use pre-commit to automatically run black
before commits. (execute `pre-commit install` to install the git hook.)


This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <>.