deploy: print hostnames while processing

This commit is contained in:
Sean Buckley 2024-06-17 01:19:30 -04:00
parent c50222cfe7
commit 79f1a07fc5

View file

@ -92,6 +92,8 @@ def check(hosts):
print("#" * 64) print("#" * 64)
for host in hosts: for host in hosts:
print(host.rjust(hostwidth + 1), end=" ", flush=True)
current_sys, cur_kernel, boot_kernel = ( current_sys, cur_kernel, boot_kernel = (
run( run(
[ [
@ -113,8 +115,6 @@ def check(hosts):
reboot_needed = cur_kernel != boot_kernel reboot_needed = cur_kernel != boot_kernel
update_needed = current_sys != new_sys[host] update_needed = current_sys != new_sys[host]
print(host.rjust(hostwidth + 1), end=" ")
if not (reboot_needed or update_needed): if not (reboot_needed or update_needed):
print(icon_good, "[OK]") print(icon_good, "[OK]")
continue continue
@ -150,9 +150,9 @@ def push(hosts):
def rexec(hosts, cmd): def rexec(hosts, cmd):
hostwidth = max(map(len, hosts)) hostwidth = max(map(len, hosts))
for host in hosts: for host in hosts:
print(host.rjust(hostwidth), end=" ", flush=True)
r = run(["ssh", host, "--"] + cmd, stdout=PIPE, stderr=STDOUT) r = run(["ssh", host, "--"] + cmd, stdout=PIPE, stderr=STDOUT)
lines = r.stdout.decode("utf8").strip("\n").splitlines() lines = r.stdout.decode("utf8").strip("\n").splitlines()
print(host.rjust(hostwidth), end=" ")
print(icon_bad if r.returncode else icon_good, end=" ") print(icon_bad if r.returncode else icon_good, end=" ")
if len(lines) == 1: if len(lines) == 1:
print(lines[0]) print(lines[0])