summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-06-26 14:41:52 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-06-26 14:41:52 (GMT)
commitab26266cff893efcaee5ed9dd67633431f6b99a7 (patch)
tree88aea93fa153ecd9ca4d63509624760f67b1ea16
parent44b299c31d7f9441d9d949eb2a5230f909bc8256 (diff)
downloadmisc-fred-ab26266cff893efcaee5ed9dd67633431f6b99a7.zip
misc-fred-ab26266cff893efcaee5ed9dd67633431f6b99a7.tar.gz
misc-fred-ab26266cff893efcaee5ed9dd67633431f6b99a7.tar.bz2
eoptasks: add -x to exclude hosts based on regex match
-rwxr-xr-xeoptasks/eoptasks.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/eoptasks/eoptasks.py b/eoptasks/eoptasks.py
index 34259cd..3507583 100755
--- a/eoptasks/eoptasks.py
+++ b/eoptasks/eoptasks.py
@@ -30,6 +30,10 @@
# 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.
import argparse
import configparser
@@ -96,6 +100,7 @@ def parse_args():
parser.add_argument('--command-server-name', dest='command_server_name', type=str)
parser.add_argument('--noinput', dest='noinput', action='store_true')
parser.add_argument('-k', dest='keywords', type=str)
+ parser.add_argument('-x', dest='exclude', type=str)
parser.add_argument('cmd', type=str, nargs='?', default=None)
parser.add_argument('args', nargs=argparse.REMAINDER)
args = parser.parse_args()
@@ -114,8 +119,13 @@ def filter_servers(servers, args):
selected_servers = [x for x in selected_servers if keyword[1:] not in x.keywords]
else:
selected_servers = servers
+ if args.exclude:
+ for exclude in args.exclude.split(','):
+ regex = re.compile(exclude)
+ selected_servers = [x for x in selected_servers if not regex.match(x.name)]
return selected_servers
+
def status_window(args):
session_name = args.session_name
curses.setupterm()