diff --git a/changelogs/fragments/add_template_path.yaml b/changelogs/fragments/add_template_path.yaml new file mode 100644 index 00000000..c408d407 --- /dev/null +++ b/changelogs/fragments/add_template_path.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Allows the cli_parse module to find parser.template_path inside roles or collections when a path relative to the role/collection directory is provided. diff --git a/plugins/action/cli_parse.py b/plugins/action/cli_parse.py index 68a02b6f..97f94b9e 100644 --- a/plugins/action/cli_parse.py +++ b/plugins/action/cli_parse.py @@ -165,8 +165,11 @@ def _update_template_path(self, template_extension): cmd_as_fname = self._task.args.get("parser").get("command").replace(" ", "_") fname = "{os}_{cmd}.{ext}".format(os=oper_sys, cmd=cmd_as_fname, ext=template_extension) source = self._find_needle("templates", fname) - self._debug("template_path in task args updated to {source}".format(source=source)) - self._task.args["parser"]["template_path"] = source + else: + source = self._task.args.get("parser").get("template_path") + source = self._find_needle("templates", source) + self._debug("template_path in task args updated to {source}".format(source=source)) + self._task.args["parser"]["template_path"] = source def _get_template_contents(self): """Retrieve the contents of the parser template