Add a command to run a script on all servers

This commit is contained in:
Andreas Zweili 2024-01-02 18:05:52 +01:00
parent 723a6a21f3
commit 779c42684b
1 changed files with 27 additions and 0 deletions

27
scripts/run-command Executable file
View File

@ -0,0 +1,27 @@
#!/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"
for host in "${hosts[@]}"; do
# Check if the host is in the skip list
if [[ " ${skip[*]} " =~ " ${host} " ]]; then
continue
fi
fqdn="$host.2li.local"
echo $fqdn
ssh -i $rsa_key $fqdn $1
echo
echo
done