From c50222cfe73ad799a9ead5b2e4008bc4643e802a Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Mon, 17 Jun 2024 01:01:16 -0400 Subject: [PATCH] deploy: allow excluding hosts --- pkgs/deploy/deploy.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/deploy/deploy.py b/pkgs/deploy/deploy.py index 72e0dda..422d531 100755 --- a/pkgs/deploy/deploy.py +++ b/pkgs/deploy/deploy.py @@ -27,16 +27,24 @@ def get_deployment(): def expand(ln): hosts = set() for item in ln.split(","): - if item == "all": - hosts.update(depl) - elif item in tags: - hosts.update(name for name in depl if item in depl[name]["tags"]) + if item[0] == "-": + item = item[1:] + action = hosts.difference_update else: - hosts.add(item) + action = hosts.update + + if item == "all": + action(depl) + elif item in tags: + action(name for name in depl if item in depl[name]["tags"]) + else: + action([item]) + for host in hosts: for c in host: if not c in (ascii_letters + digits + "-"): raise RuntimeError(f"Invalid hostname: {host}") + return sorted(hosts)