feat(validation): expand glob patterns in the spec list

This commit is contained in:
2026-10-05 18:10:23 +02:00
parent 73136b7ebb
commit 75ea3f10e2
2 changed files with 45 additions and 1 deletions
+10 -1
View File
@@ -7,6 +7,7 @@ against that sub-option, and a null entry means the entry is not managed. Messag
and the types involved but never a value, so secrets cannot leak into job output.
"""
import glob
from collections.abc import Mapping
from ansible.errors import AnsibleError
@@ -111,7 +112,15 @@ class ActionModule(ActionBase):
task_vars = task_vars or {}
validator = _Validator(self._templar)
declared = {}
for path in self._task.args["specs"]:
paths = []
# A pattern (`.../*/roles/*/meta/argument_specs.yml`) picks up every role's spec without a list
# to keep in sync; one that matches nothing is a broken path, not an empty set.
for entry in self._task.args["specs"]:
matches = sorted(glob.glob(entry)) if glob.has_magic(entry) else [entry]
if not matches:
raise AnsibleError(f"no spec file matches {entry}")
paths.extend(matches)
for path in paths:
options = self._loader.load_from_file(path)["argument_specs"]["inputs"]["options"]
_check_spec(options, path)
for name, spec in options.items():