From 4f61fb6cce251d40d65115e2af74b41bc21f479c Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Thu, 4 Feb 2016 14:44:22 -0500 Subject: [PATCH] Add safety check on _backup key. --- lib/ansible/plugins/action/net_template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/action/net_template.py b/lib/ansible/plugins/action/net_template.py index ffd09324a3..c626c8dc6b 100644 --- a/lib/ansible/plugins/action/net_template.py +++ b/lib/ansible/plugins/action/net_template.py @@ -47,7 +47,9 @@ class ActionModule(ActionBase): result.update(self._execute_module(module_name=self._task.action, module_args=self._task.args, task_vars=task_vars)) - if self._task.args.get('backup'): + if self._task.args.get('backup') and result.get('_backup'): + # User requested backup and no error occurred in module. + # NOTE: If there is a parameter error, _backup key may not be in results. self._write_backup(task_vars['inventory_hostname'], result['_backup']) if '_backup' in result: