feat: bootstrap ssh-monitor updater when missing on host (0.20.2)
SAC now clones the ssh-monitor repo and installs update_ssh_monitor.sh before running the update when the remote updater script is absent.
This commit is contained in:
@@ -141,7 +141,12 @@ def process_agent_update_ingest(db: Session, host: Host, event_type: str, detail
|
||||
_clear_pending(host)
|
||||
|
||||
|
||||
def run_linux_agent_update_fallback(host: Host, cfg_linux) -> tuple[bool, str, str | None]:
|
||||
def run_linux_agent_update_fallback(
|
||||
host: Host,
|
||||
cfg_linux,
|
||||
*,
|
||||
repo_url: str | None = None,
|
||||
) -> tuple[bool, str, str | None]:
|
||||
if not is_linux_host(host):
|
||||
return False, "Host is not Linux", None
|
||||
if not cfg_linux.configured:
|
||||
@@ -154,8 +159,14 @@ def run_linux_agent_update_fallback(host: Host, cfg_linux) -> tuple[bool, str, s
|
||||
except (HostNotLinuxError, HostTargetMissingError) as exc:
|
||||
return False, str(exc), None
|
||||
|
||||
effective_repo = (repo_url or "").strip() or None
|
||||
for target in targets:
|
||||
result = run_ssh_monitor_update(target=target, user=cfg_linux.user, password=cfg_linux.password)
|
||||
result = run_ssh_monitor_update(
|
||||
target=target,
|
||||
user=cfg_linux.user,
|
||||
password=cfg_linux.password,
|
||||
repo_url=effective_repo,
|
||||
)
|
||||
last_message = result.message
|
||||
if result.ok:
|
||||
version = result.agent_version
|
||||
@@ -204,7 +215,9 @@ def execute_agent_update_fallback(db: Session, host: Host) -> tuple[bool, str, s
|
||||
|
||||
if product == PRODUCT_SSH or is_linux_host(host):
|
||||
linux_cfg = get_effective_linux_admin_config(db)
|
||||
ok, message, version = run_linux_agent_update_fallback(host, linux_cfg)
|
||||
agent_cfg = get_effective_agent_update_config(db)
|
||||
repo_url = (agent_cfg.ssh_git_repo_url or "").strip() or None
|
||||
ok, message, version = run_linux_agent_update_fallback(host, linux_cfg, repo_url=repo_url)
|
||||
elif product == PRODUCT_RDP or is_windows_host(host):
|
||||
win_cfg = get_effective_win_admin_config(db)
|
||||
ok, message, version = run_windows_agent_update_fallback(host, win_cfg, cfg.win_agent_update_script)
|
||||
|
||||
Reference in New Issue
Block a user