From a0cb974575b3828489bd9557a28cf28715cd94bb Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 13 Mar 2014 15:06:59 -0500 Subject: [PATCH] Be sure to return to the old directory if cwd is set in run_command --- lib/ansible/module_utils/basic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index d0bfde69179..42b9d3d669b 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1096,6 +1096,7 @@ class AnsibleModule(object): self.fail_json(rc=e.errno, msg=str(e), cmd=clean_args) except: self.fail_json(rc=257, msg=traceback.format_exc(), cmd=clean_args) + if rc != 0 and check_rc: msg = err.rstrip() self.fail_json(cmd=clean_args, rc=rc, stdout=out, stderr=err, msg=msg)