GRM-17: fix: make grm list retrieve runner status correctly

- run_ad_hoc() now raises AnsibleError on non-zero exit, surfacing
  stderr instead of silently returning empty stdout
- list_runners() passes become=True to run_ad_hoc since systemctl
  is-active requires root privileges
- Add i18n translations for ad-hoc failure messages
- Add unit test for run_ad_hoc failure case
- Update list_runners test to expect become=True
- 119 tests, 100% coverage, pyright clean, ruff clean
This commit is contained in:
Emil Simeonov
2026-06-19 02:05:06 +02:00
parent 677745ac99
commit 18760f6a2a
5 changed files with 38 additions and 2 deletions
+11
View File
@@ -206,3 +206,14 @@ class TestAnsibleExecutorAdHoc:
assert result == "ok"
cmd = mock_run.call_args.args[0]
assert "--become" in cmd
def test_run_ad_hoc_failure_raises(self, tmp_path: Path) -> None:
executor = AnsibleExecutor(log_dir=tmp_path)
result_mock = MagicMock()
result_mock.stdout = ""
result_mock.returncode = 1
result_mock.stderr = "SSH timeout"
with patch("subprocess.run", return_value=result_mock):
with pytest.raises(AnsibleError, match="SSH timeout"):
executor.run_ad_hoc("10.0.0.1", "ubuntu", None, "shell", "cmd")