From f257f25a2e7dd1d6c63f94c7b85f16206a4b5b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 30 Jan 2021 20:55:55 +0100 Subject: [PATCH] move documentation from head comment to README --- README | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ eoptasks.py | 48 +++++++++------------------------ 2 files changed, 90 insertions(+), 36 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..08f7993 --- /dev/null +++ b/README @@ -0,0 +1,78 @@ +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. + + +Configuration +------------- + +In ~/.config/eoptasks.ini:: + + [config] + servers = /path/to/servers.yaml + ignore = server1, server2 + stripsuffix = .entrouvert.org + +It is possible to add extra command shortcuts with additional sections, ex:: + + [command:memcached.restart] + cmd = sudo service memcached restart; /bin/true + + +Examples +-------- + + 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.) + + +License +------- + +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 +version. + +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 +details. + +You should have received a copy of the GNU Affero General Public License along +with this program. If not, see . diff --git a/eoptasks.py b/eoptasks.py index 4f1dad0..7c6f882 100755 --- a/eoptasks.py +++ b/eoptasks.py @@ -1,44 +1,20 @@ #! /usr/bin/python3 # -# This script provides parallel remote execution of commands, while having -# some special knownledge of servers that should *not* be handled in parallel. +# eoptasks - run commands on servers +# Copyright (C) 2018-2021 Entr’ouvert # -# It defers terminal-handling to tmux(1). +# 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 version. # -# 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. +# 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 General Public License for more details. # -# It takes any shell command and has some builtin shortcuts such as apt.update -# and apt.upgrade. -# -# Requirements: libtmux and pyyaml. -# -# Configuration: ~/.config/eoptasks.ini -# [config] -# servers = /path/to/servers.yaml -# ignore = server1, server2 -# stripsuffix = .entrouvert.org -# -# It is possible to add extra command shortcuts with additional sections, ex: -# [command:memcached.restart] -# cmd = sudo service memcached restart; /bin/true -# -# Examples: -# -# 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. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . import argparse import configparser