From a1800a7c836099a3ff83ceb32833e93461c7ebee Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Thu, 28 Dec 2023 14:30:30 +0100 Subject: [PATCH] Add a script to reboot all machines --- scripts/reboot-all-machines | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/reboot-all-machines diff --git a/scripts/reboot-all-machines b/scripts/reboot-all-machines new file mode 100755 index 0000000..08e5759 --- /dev/null +++ b/scripts/reboot-all-machines @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +cd /home/andreas/.nixos + +hosts=($(echo $(nix eval .#nixosConfigurations --apply 'pkgs: builtins.concatStringsSep " " (builtins.attrNames pkgs)') | xargs)) +skip=( + "desktop-vm" + "gwyn" + "loki-test" + "mobile" + "staubfinger" + "test-raspi" +) + +rsa_key="$HOME/.nixos/secrets/ssh_keys/ansible/ansible.key" +export NIX_SSHOPTS="-t -i $rsa_key" + +for host in "${hosts[@]}"; do + fqdn="$host.2li.local" + echo $fqdn + ssh -i $rsa_key $fqdn 'sudo reboot' + echo + echo +done