clustercfg: show diff before switching to new configuration

This is mildly hacky, but lets us be more informed before we switch to a
new configuration.

Change-Id: I008f3f698db702f1e0992bd41a8d1050449d59b5
changes/63/463/2
q3k 2020-10-10 14:54:09 +02:00 committed by q3k
parent a4a5a66f88
commit 36224c617a
2 changed files with 11 additions and 3 deletions

View File

@ -205,8 +205,7 @@ def nodestrap(args, nocerts=False):
subprocess.check_call(["nix", "run",
"-f", os.path.join(local_root, "cluster/nix/default.nix"),
"provision",
"-c", "provision-{}".format(fqdn.split('.')[0]),
"switch"])
"-c", "provision-{}".format(fqdn.split('.')[0])])
def usage():

View File

@ -20,7 +20,16 @@ let
remote=root@${machine.fqdn}
echo "Configuration for ${machine.fqdn} is ${configuration.toplevel}"
nix copy --no-check-sigs -s --to ssh://$remote ${configuration.toplevel}
ssh $remote ${configuration.toplevel}/bin/switch-to-configuration $1
echo "/etc/systemd/system diff:"
ssh $remote diff -ur /var/run/current-system/etc/systemd/system ${configuration.toplevel}/etc/systemd/system || true
echo ""
echo ""
ssh $remote ${configuration.toplevel}/bin/switch-to-configuration dry-activate
read -p "Do you want to switch to this configuration? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
ssh $remote ${configuration.toplevel}/bin/switch-to-configuration switch
fi
'';
machineProvisioners = builtins.listToAttrs (map (machine: {