From 439aa353f1f2dc32608627bf3037930048d2c42d Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Mon, 5 Sep 2016 08:49:49 -0400 Subject: [PATCH] fixes bug when template is missing src argument adds AttributeError to exception handling to change missing src argument fixes #17391 --- lib/ansible/plugins/action/net_template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/action/net_template.py b/lib/ansible/plugins/action/net_template.py index 3d27cac5f25..1561e7e2154 100644 --- a/lib/ansible/plugins/action/net_template.py +++ b/lib/ansible/plugins/action/net_template.py @@ -41,7 +41,7 @@ class ActionModule(ActionBase): try: self._handle_template() - except ValueError as exc: + except (ValueError, AttributeError) as exc: return dict(failed=True, msg=exc.message) result.update(self._execute_module(module_name=self._task.action, @@ -75,9 +75,12 @@ class ActionModule(ActionBase): def _handle_template(self): src = self._task.args.get('src') + if not src: + raise ValueError('missing required arguments: src') + working_path = self._get_working_path() - if os.path.isabs(src) or urlparse.urlsplit('src').scheme: + if os.path.isabs(src) or urlparse.urlsplit(src).scheme: source = src else: source = self._loader.path_dwim_relative(working_path, 'templates', src)