diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2019-02-25 16:46:33 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 16:46:33 +0530 |
commit | cb67235eabdce502a84f5ce7e4b0aa6c8f45c226 (patch) | |
tree | 6251de99d76fcc69805c4bbccbdcfd8fb2c8a3c4 | |
parent | f2495ef0d320678a84e4c8f1da199e9dde4e9a5a (diff) | |
download | ansible-cb67235eabdce502a84f5ce7e4b0aa6c8f45c226.tar.gz |
Fix network config module invalid src option error (#52912)
Fixes #52911
Raise AnsibleError execption if the file
path mentioned in src option in not found or
failed to load
-rw-r--r-- | lib/ansible/plugins/action/network.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/ansible/plugins/action/network.py b/lib/ansible/plugins/action/network.py index e7d7140ef9..d7b8a61f42 100644 --- a/lib/ansible/plugins/action/network.py +++ b/lib/ansible/plugins/action/network.py @@ -49,12 +49,6 @@ class ActionModule(_ActionModule): return result - def _handle_src_option(self): - try: - self._handle_template() - except ValueError as exc: - return dict(failed=True, msg=to_text(exc)) - def _handle_backup_option(self, result, task_vars): filename = None @@ -132,7 +126,7 @@ class ActionModule(_ActionModule): cwd = self._task._role._role_path return cwd - def _handle_template(self, convert_data=True): + def _handle_src_option(self, convert_data=True): src = self._task.args.get('src') working_path = self._get_working_path() @@ -144,13 +138,13 @@ class ActionModule(_ActionModule): source = self._loader.path_dwim_relative(working_path, src) if not os.path.exists(source): - raise ValueError('path specified in src not found') + raise AnsibleError('path specified in src not found') try: with open(source, 'r') as f: template_data = to_text(f.read()) - except IOError: - return dict(failed=True, msg='unable to load src file') + except IOError as e: + raise AnsibleError("unable to load src file {0}, I/O error({1}): {2}".format(source, e.errno, e.strerror)) # Create a template search path in the following order: # [working_path, self_role_path, dependent_role_paths, dirname(source)] |