Skip to content

Commit 406b1b5

Browse files
committed
Remove redundant OS tool plugins
1 parent 5812a82 commit 406b1b5

8 files changed

Lines changed: 2 additions & 144 deletions

File tree

docs/plugins/generated.md

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7632,71 +7632,6 @@ with:
76327632
timezone: value
76337633
```
76347634

7635-
### `os.tool.check`
7636-
7637-
Check whether one executable exists on the remote PATH.
7638-
7639-
- Remote session: `true`
7640-
- Dry-run support: `true`
7641-
- Check mode support: `true`
7642-
7643-
| Parameter | Required | Type | Default | Description |
7644-
|---|---:|---|---|---|
7645-
| `name` | yes | `string` | | Package, user or group name. |
7646-
| `path` | no | `path` | | Remote or local path, depending on the plugin. |
7647-
7648-
Result fields:
7649-
7650-
- `changed`: Whether the plugin changed the target or controller state.
7651-
- `message`: Human-readable result message.
7652-
- `rc`: Process or command return code when applicable.
7653-
- `stdout`: Captured standard output when applicable.
7654-
- `stderr`: Captured standard error when applicable.
7655-
- `data`: Plugin-specific structured result data.
7656-
- `data.exists`: Whether the remote executable exists.
7657-
- `data.tool`: Checked executable name.
7658-
- `data.path`: Resolved executable path when present.
7659-
7660-
Example:
7661-
7662-
```yaml
7663-
use: os.tool.check
7664-
with:
7665-
name: nginx
7666-
```
7667-
7668-
### `os.tool.version_check`
7669-
7670-
Check whether a remote tool version output contains or matches the expected value.
7671-
7672-
- Remote session: `true`
7673-
- Dry-run support: `true`
7674-
- Check mode support: `true`
7675-
7676-
| Parameter | Required | Type | Default | Description |
7677-
|---|---:|---|---|---|
7678-
| `name` | yes | `string` | | Package, user or group name. |
7679-
| `version_arg` | no | `string` | `--version` | Argument used to print a tool version. |
7680-
| `contains` | no | `string` | | Required substring in stdout or HTTP response body. |
7681-
| `regex` | no | `string` | | Regular expression expected in command output. |
7682-
7683-
Result fields:
7684-
7685-
- `changed`: Whether the plugin changed the target or controller state.
7686-
- `message`: Human-readable result message.
7687-
- `rc`: Process or command return code when applicable.
7688-
- `stdout`: Captured standard output when applicable.
7689-
- `stderr`: Captured standard error when applicable.
7690-
- `data`: Plugin-specific structured result data.
7691-
7692-
Example:
7693-
7694-
```yaml
7695-
use: os.tool.version_check
7696-
with:
7697-
name: nginx
7698-
```
7699-
77007635
## security
77017636

77027637
### `security.apparmor.complain`

docs/plugins/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ os.time.status
240240
os.time.timezone.check
241241
os.time.timezone.get
242242
os.time.timezone.set
243-
os.tool.check
244-
os.tool.version_check
245243
security.apparmor.complain
246244
security.apparmor.disable
247245
security.apparmor.enforce

docs/plugins/security.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ Use `capabilities requirements` to derive remote tool requirements from the sele
108108
The explicit capability plugins are:
109109

110110
```text
111-
os.tool.check
112-
os.tool.version_check
113111
os.capability.check
114112
automax.plugin.requirements
115113
```

src/automax/plugins/capabilities.py

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from automax.core.capabilities import plugin_tools
1111
from automax.core.models import ExecutionContext, PluginResult
1212
from automax.plugins.base import BasePlugin, PluginValidationError
13-
from automax.plugins.remote_utils import exec_remote, predicate_result_from_remote, quote
13+
from automax.plugins.remote_utils import exec_remote, quote
1414

1515

1616
def _as_list(value: Any) -> list[str]:
@@ -21,70 +21,6 @@ def _as_list(value: Any) -> list[str]:
2121
return [str(value)]
2222

2323

24-
class ToolCheckPlugin(BasePlugin):
25-
name = "os.tool.check"
26-
description = "Check whether one executable exists on the remote PATH."
27-
required_params = ("name",)
28-
optional_params = ("path",)
29-
opens_remote_session = True
30-
supports_check_mode = True
31-
32-
def diff_preview_reason(self, params: Dict[str, Any], context: ExecutionContext) -> str:
33-
return "os.tool.check is a read-only remote dependency check"
34-
35-
def manual_commands(self, params: Dict[str, Any], context: ExecutionContext) -> list[str]:
36-
self.validate(params)
37-
path_prefix = f"PATH={quote(params['path'])}:$PATH " if params.get("path") else ""
38-
return [f"{path_prefix}command -v {quote(params['name'])}"]
39-
40-
def execute(self, params: Dict[str, Any], context: ExecutionContext) -> PluginResult:
41-
rc, out, err = exec_remote(context, self.manual_commands(params, context)[0])
42-
return predicate_result_from_remote(
43-
rc=rc,
44-
stdout=out,
45-
stderr=err,
46-
message=f"os.tool.check failed for tool: {params['name']}",
47-
data_key="exists",
48-
data={"tool": params["name"], "path": out.strip() if rc == 0 else ""},
49-
)
50-
51-
52-
class ToolVersionAssertPlugin(BasePlugin):
53-
name = "os.tool.version_check"
54-
description = "Check whether a remote tool version output contains or matches the expected value."
55-
required_params = ("name",)
56-
optional_params = ("version_arg", "contains", "regex")
57-
opens_remote_session = True
58-
supports_check_mode = True
59-
60-
def validate(self, params: Dict[str, Any]) -> None:
61-
super().validate(params)
62-
if not params.get("contains") and not params.get("regex"):
63-
raise PluginValidationError("os.tool.version_check requires contains or regex")
64-
65-
def diff_preview_reason(self, params: Dict[str, Any], context: ExecutionContext) -> str:
66-
return "os.tool.version_check is a read-only remote dependency check"
67-
68-
def manual_commands(self, params: Dict[str, Any], context: ExecutionContext) -> list[str]:
69-
self.validate(params)
70-
arg = str(params.get("version_arg", "--version"))
71-
command = f"{quote(params['name'])} {arg} 2>&1"
72-
if params.get("contains"):
73-
return [f"{command} | grep -F -- {quote(params['contains'])}"]
74-
return [f"{command} | grep -E -- {quote(params['regex'])}"]
75-
76-
def execute(self, params: Dict[str, Any], context: ExecutionContext) -> PluginResult:
77-
rc, out, err = exec_remote(context, self.manual_commands(params, context)[0])
78-
return predicate_result_from_remote(
79-
rc=rc,
80-
stdout=out,
81-
stderr=err,
82-
message=f"os.tool.version_check failed for tool: {params['name']}",
83-
data_key="matches",
84-
data={"tool": params["name"], "version": out.strip() if rc == 0 else ""},
85-
)
86-
87-
8824
class CapabilityAssertPlugin(BasePlugin):
8925
name = "os.capability.check"
9026
description = "Check remote tools, paths and optional shell checks required by a job preflight."

src/automax/plugins/metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@
398398
"network.http.wait": {"data.status": "HTTP response status code.", "data.body": "Decoded response body."},
399399
"network.connectivity.port_wait": {"data.host": "Checked host.", "data.port": "Checked TCP port."},
400400
"network.connectivity.port_check": {"data.host": "Checked host.", "data.port": "Checked TCP/UDP port.", "data.reachable": "Whether the remote target can reach the port."},
401-
"os.tool.check": {"data.exists": "Whether the remote executable exists.", "data.tool": "Checked executable name.", "data.path": "Resolved executable path when present."},
402401
"data.transfer.upload": {"data.src": "Local source path.", "data.dest": "Remote destination path"},
403402
"data.transfer.download": {"data.src": "Remote source path.", "data.dest": "Local destination path."},
404403
"data.transfer.rsync": {"data.command": "Executed rsync argument vector."},

src/automax/plugins/registry.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _load_module_file(self, path: Path) -> None:
9393

9494
def build_builtin_registry(extra_plugin_paths: Iterable[str] = ()) -> PluginRegistry:
9595
"""Create a registry with builtin plugins and optional external plugins."""
96-
from automax.plugins.capabilities import CapabilityAssertPlugin, PluginRequirementsPlugin, ToolCheckPlugin, ToolVersionAssertPlugin
96+
from automax.plugins.capabilities import CapabilityAssertPlugin, PluginRequirementsPlugin
9797
from automax.plugins.block import (
9898
BlockFactsPlugin,
9999
BlockIdentityPlugin,
@@ -530,8 +530,6 @@ def build_builtin_registry(extra_plugin_paths: Iterable[str] = ()) -> PluginRegi
530530
AlternativesGetPlugin(),
531531
AlternativesListPlugin(),
532532
AlternativesCheckPlugin(),
533-
ToolCheckPlugin(),
534-
ToolVersionAssertPlugin(),
535533
CapabilityAssertPlugin(),
536534
PluginRequirementsPlugin(),
537535
AlternativesSetPlugin(),

tests/test_documentation_and_regressions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,6 @@ def test_os_namespace_replaces_legacy_operating_system_plugin_names():
12161216
"os.time.timezone.check",
12171217
"os.time.timezone.get",
12181218
"os.time.timezone.set",
1219-
"os.tool.check",
1220-
"os.tool.version_check",
12211219
} <= names
12221220

12231221
searched = [

tests/test_next_engine.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5221,8 +5221,6 @@ def test_capability_and_redaction_plugins_render_safe_previews():
52215221
)
52225222
registry = AutomaxEngine().plugin_registry
52235223

5224-
assert registry.get("os.tool.check").manual_commands({"name": "rsync"}, context) == ["command -v rsync"]
5225-
assert "grep -F" in registry.get("os.tool.version_check").manual_commands({"name": "rsync", "contains": "rsync"}, context)[0]
52265224
assert "command -v setfacl" in registry.get("os.capability.check").manual_commands({"tools": ["setfacl"]}, context)[0]
52275225
assert registry.get("automax.plugin.requirements").execute({"plugin": "data.transfer.rsync"}, context).data["requirements"]["data.transfer.rsync"] == ["rsync"]
52285226

@@ -5765,7 +5763,6 @@ def test_presence_check_plugins_return_predicates_without_failing_on_absence():
57655763
for plugin_name, params in (
57665764
("identity.user.check", {"name": "missing-user"}),
57675765
("identity.group.check", {"name": "missing-group"}),
5768-
("os.tool.check", {"name": "missing-tool"}),
57695766
):
57705767
result = registry.get(plugin_name).execute(params, _remote_context_for_result(1, stderr="not found"))
57715768
assert result.ok is True
@@ -5861,7 +5858,6 @@ def test_os_check_plugins_return_predicates_on_condition_false():
58615858
("os.env.check", {"name": "DEMO", "value": "1"}, "matches"),
58625859
("os.package.key.check", {"name": "demo"}, "exists"),
58635860
("os.package.check", {"name": "curl"}, "matches"),
5864-
("os.tool.version_check", {"name": "rsync", "contains": "3."}, "matches"),
58655861
("os.capability.check", {"tools": ["missing-tool"]}, "matches"),
58665862
):
58675863
result = registry.get(plugin_name).execute(params, _remote_context_for_result(1, stderr="missing"))

0 commit comments

Comments
 (0)