From 66cb7f1a379f12f5449ccf4bd992ceb5c0eaaba7 Mon Sep 17 00:00:00 2001 From: Patrik Lundin Date: Tue, 13 May 2014 19:03:18 +0200 Subject: [PATCH] openbsd_pkg: revert "changed" simplification. module.exit_json() does not like when the "changed" variable contains a match object: TypeError: <_sre.SRE_Match object at 0x81e2ae58> is not JSON serializable --- lib/ansible/modules/extras/packaging/openbsd_pkg.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/openbsd_pkg.py b/lib/ansible/modules/extras/packaging/openbsd_pkg.py index a9e6f8c0572..14b4ff46024 100644 --- a/lib/ansible/modules/extras/packaging/openbsd_pkg.py +++ b/lib/ansible/modules/extras/packaging/openbsd_pkg.py @@ -336,9 +336,15 @@ def upgrade_packages(module): # Try to find any occurance of a package changing version like: # "bzip2-1.0.6->1.0.6p0: ok". - changed = re.search("\W\w.+->.+: ok\W", stdout) - if module.check_mode: - module.exit_json(changed=changed) + match = re.search("\W\w.+->.+: ok\W", stdout) + if match: + if module.check_mode: + module.exit_json(changed=True) + + changed=True + + else: + changed=False # It seems we can not trust the return value, so depend on the presence of # stderr to know if something failed.