Merge pull request 'Host: actual setup ssh controlmaster' (#3515) from fix-control-master into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3515
This commit is contained in:
Mic92
2025-05-06 11:21:05 +00:00
3 changed files with 27 additions and 18 deletions

View File

@@ -149,13 +149,14 @@ class Machine:
@contextmanager
def target_host(self) -> Iterator[Host]:
yield parse_deployment_address(
with parse_deployment_address(
self.name,
self.target_host_address,
self.host_key_check,
private_key=self.private_key,
meta={"machine": self},
)
) as target_host:
yield target_host
@contextmanager
def build_host(self) -> Iterator[Host | None]:
@@ -168,14 +169,15 @@ class Machine:
yield None
return
# enable ssh agent forwarding to allow the build host to access the target host
yield parse_deployment_address(
with parse_deployment_address(
self.name,
build_host,
self.host_key_check,
forward_agent=True,
private_key=self.private_key,
meta={"machine": self},
)
) as build_host:
yield build_host
@cached_property
def deploy_as_root(self) -> bool:

View File

@@ -179,11 +179,11 @@ def deploy_machine(machine: Machine) -> None:
switch_cmd = [f"{machine._class_}-rebuild", "switch", *nix_options]
test_cmd = [f"{machine._class_}-rebuild", "test", *nix_options]
env = host.nix_ssh_env(None)
remote_env = host.nix_ssh_env(None, local_ssh=False)
ret = host.run(
switch_cmd,
RunOpts(check=False, msg_color=MsgColor(stderr=AnsiColor.DEFAULT)),
extra_env=env,
extra_env=remote_env,
become_root=become_root,
)
@@ -209,7 +209,7 @@ def deploy_machine(machine: Machine) -> None:
msg_color=MsgColor(stderr=AnsiColor.DEFAULT),
needs_user_terminal=True,
),
extra_env=env,
extra_env=remote_env,
become_root=become_root,
)