machines update: support --target-host localhost

This is basically
<af7ce9b8ed>,
but with support for deploying locally.

This failed to install secrets to `/var/lib/sops-nix`. That's because
our `LocalHost` didn't have support for sudo yet. I fixed that.
This commit is contained in:
Jeremy Fleischman
2025-08-06 12:31:24 -07:00
committed by Mic92
parent e2cb75784c
commit 1129862293
3 changed files with 15 additions and 22 deletions

View File

@@ -174,7 +174,7 @@
##############
print("TEST: update with --build-host local")
print("TEST: update with --build-host localhost --target-host localhost")
with open(machine_config_path, "w") as f:
f.write("""
{
@@ -197,15 +197,6 @@
check=True
)
# allow machine to ssh into itself
subprocess.run([
"ssh",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
f"root@192.168.1.1",
"mkdir -p /root/.ssh && chmod 700 /root/.ssh && echo \"$(cat \"${../assets/ssh/privkey}\")\" > /root/.ssh/id_ed25519 && chmod 600 /root/.ssh/id_ed25519",
], check=True)
# install the clan-cli package into the container's Nix store
subprocess.run(
[
@@ -225,7 +216,7 @@
},
)
# Run ssh on the host to run the clan update command via --build-host local
# Run ssh on the host to run the clan update command via --build-host localhost
subprocess.run([
"ssh",
"-o", "UserKnownHostsFile=/dev/null",
@@ -239,8 +230,8 @@
"--host-key-check", "none",
"--upload-inputs", # Use local store instead of fetching from network
"--build-host", "localhost",
"--target-host", "localhost",
"test-update-machine",
"--target-host", f"root@localhost",
], check=True)
# Verify the update was successful