summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2021-02-06 13:12:57 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2021-02-06 13:12:57 (GMT)
commite445ebc24edc459fdfb30c0257d799a79fa3ef50 (patch)
tree3c36fd8796ada9e374816de84ac781a1ed32fc62
parent868b870979ea730c07f3f4eb384c02aa8127f90a (diff)
downloadeoptasks-e445ebc24edc459fdfb30c0257d799a79fa3ef50.zip
eoptasks-e445ebc24edc459fdfb30c0257d799a79fa3ef50.tar.gz
eoptasks-e445ebc24edc459fdfb30c0257d799a79fa3ef50.tar.bz2
add support for declaring additional servers in configuration file
-rw-r--r--README6
-rwxr-xr-xeoptasks.py8
2 files changed, 14 insertions, 0 deletions
diff --git a/README b/README
index 08f7993..e792b54 100644
--- a/README
+++ b/README
@@ -32,6 +32,12 @@ 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::
+
+ [servers]
+ host.domain = keyword1, keyword2
+
+
Examples
--------
diff --git a/eoptasks.py b/eoptasks.py
index 781f1ad..19ec628 100755
--- a/eoptasks.py
+++ b/eoptasks.py
@@ -82,12 +82,20 @@ def get_servers():
return x[: -len(stripsuffix)]
return x
+ # load servers from servers.yaml
for s in yaml.safe_load(open(serversfile))['servers']:
servername, tags = s.get('name'), s.get('tags', [])
if servername in ignorelist:
continue
servers.append(Server(servername, tags, display_name=get_display_name(servername)))
+ # load additional servers from eoptasks.ini
+ if config.has_section('servers'):
+ for server in config.options('servers'):
+ servername = server
+ tags = [x.strip() for x in config.get('servers', server).split(',')]
+ servers.append(Server(servername, tags, display_name=get_display_name(servername)))
+
return servers