From 36224c617a1e0924e95a64c047091d3678885d82 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Sat, 10 Oct 2020 14:54:09 +0200 Subject: [PATCH] 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 --- cluster/clustercfg/clustercfg.py | 3 +-- cluster/nix/provision.nix | 11 ++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cluster/clustercfg/clustercfg.py b/cluster/clustercfg/clustercfg.py index 13968261..410635b6 100644 --- a/cluster/clustercfg/clustercfg.py +++ b/cluster/clustercfg/clustercfg.py @@ -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(): diff --git a/cluster/nix/provision.nix b/cluster/nix/provision.nix index 70240f6b..20ed0a09 100644 --- a/cluster/nix/provision.nix +++ b/cluster/nix/provision.nix @@ -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: {