mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
deploy: allow excluding hosts
This commit is contained in:
parent
0fbf2573cc
commit
c50222cfe7
1 changed files with 13 additions and 5 deletions
|
@ -27,16 +27,24 @@ def get_deployment():
|
||||||
def expand(ln):
|
def expand(ln):
|
||||||
hosts = set()
|
hosts = set()
|
||||||
for item in ln.split(","):
|
for item in ln.split(","):
|
||||||
if item == "all":
|
if item[0] == "-":
|
||||||
hosts.update(depl)
|
item = item[1:]
|
||||||
elif item in tags:
|
action = hosts.difference_update
|
||||||
hosts.update(name for name in depl if item in depl[name]["tags"])
|
|
||||||
else:
|
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 host in hosts:
|
||||||
for c in host:
|
for c in host:
|
||||||
if not c in (ascii_letters + digits + "-"):
|
if not c in (ascii_letters + digits + "-"):
|
||||||
raise RuntimeError(f"Invalid hostname: {host}")
|
raise RuntimeError(f"Invalid hostname: {host}")
|
||||||
|
|
||||||
return sorted(hosts)
|
return sorted(hosts)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue