Skip to content

Commit 8cba2c3

Browse files
Mark0016Mark VasiRuchip16pre-commit-ci[bot]
authored
cli_parse: Fix finding relative template_path when used inside role/collection (#333)
* Fix finding relative template_path when provided This allows parser.template_path to behave as expected inside roles or collections when a path relative to the role/collection directory is provided. * add tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update tests * add working tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updates * minor changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Delete tests/integration/inventory * add tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add netcommon dependency * changes * delete tests as CI is failing * changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Mark Vasi <mark.vasi@embedit.com> Co-authored-by: Ruchi Pakhle <ruchipakhle@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com>
1 parent db14f96 commit 8cba2c3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- 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.

plugins/action/cli_parse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ def _update_template_path(self, template_extension):
165165
cmd_as_fname = self._task.args.get("parser").get("command").replace(" ", "_")
166166
fname = "{os}_{cmd}.{ext}".format(os=oper_sys, cmd=cmd_as_fname, ext=template_extension)
167167
source = self._find_needle("templates", fname)
168-
self._debug("template_path in task args updated to {source}".format(source=source))
169-
self._task.args["parser"]["template_path"] = source
168+
else:
169+
source = self._task.args.get("parser").get("template_path")
170+
source = self._find_needle("templates", source)
171+
self._debug("template_path in task args updated to {source}".format(source=source))
172+
self._task.args["parser"]["template_path"] = source
170173

171174
def _get_template_contents(self):
172175
"""Retrieve the contents of the parser template

0 commit comments

Comments
 (0)