Compare commits

..

1 commit

Author SHA1 Message Date
acd8533135
factor out TF setup
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
2025-09-30 11:58:33 +02:00
3 changed files with 12 additions and 9 deletions

View file

@ -5,10 +5,9 @@
}: }:
let let
inherit (pkgs) system; inherit (pkgs) system;
nodeName = "ssh";
deployment-config = { deployment-config = {
inherit nodeName;
inherit (import ./constants.nix) pathToRoot; inherit (import ./constants.nix) pathToRoot;
nodeName = "ssh";
targetSystem = system; targetSystem = system;
sshOpts = [ ]; sshOpts = [ ];
}; };
@ -59,10 +58,9 @@ in
ssh.fail("hello 1>&2") ssh.fail("hello 1>&2")
with subtest("Run the deployment"): with subtest("Run the deployment"):
output = deployer.fail(""" deployer.succeed("""
${lib.getExe deploy} ${lib.getExe deploy}
""") """)
assert "Timeout, server ${nodeName} not responding" in output
ssh.wait_for_unit("multi-user.target") ssh.wait_for_unit("multi-user.target")
ssh.succeed("su - operator -c hello 1>&2") ssh.succeed("su - operator -c hello 1>&2")
''; '';

View file

@ -5,10 +5,9 @@
}: }:
let let
inherit (pkgs) system; inherit (pkgs) system;
nodeName = "target";
deployment-config = { deployment-config = {
inherit nodeName;
inherit (import ./constants.nix) pathToRoot; inherit (import ./constants.nix) pathToRoot;
nodeName = "target";
targetSystem = system; targetSystem = system;
sshOpts = [ ]; sshOpts = [ ];
}; };
@ -52,10 +51,9 @@ in
target.fail("hello 1>&2") target.fail("hello 1>&2")
with subtest("Run the deployment"): with subtest("Run the deployment"):
output = deployer.fail(""" deployer.succeed("""
${lib.getExe deploy} ${lib.getExe deploy}
""") """)
assert "Timeout, server ${nodeName} not responding" in output
target.wait_for_unit("multi-user.target") target.wait_for_unit("multi-user.target")
target.succeed("su - operator -c hello 1>&2") target.succeed("su - operator -c hello 1>&2")
''; '';

View file

@ -37,4 +37,11 @@ NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$destination" "$outPath" --gz
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh "${sshOpts[@]}" "$destination" "nix-env --profile /nix/var/nix/profiles/system --set $outPath" ssh "${sshOpts[@]}" "$destination" "nix-env --profile /nix/var/nix/profiles/system --set $outPath"
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh -o "ConnectTimeout=1" -o "ServerAliveInterval=1" "${sshOpts[@]}" "$destination" "nohup $outPath/bin/switch-to-configuration switch &" 2>&1 output=$(ssh -o "ConnectTimeout=1" -o "ServerAliveInterval=1" "${sshOpts[@]}" "$destination" "nohup $outPath/bin/switch-to-configuration switch &" 2>&1) || echo "status code: $?"
echo "output: $output"
if [[ $output != *"Timeout, server $host not responding"* ]]; then
echo "non-timeout error: $output"
exit 1
else
exit 0
fi