summaryrefslogtreecommitdiff
path: root/database/postgresql/postgresql_ext.py
diff options
context:
space:
mode:
authorStrahinja Kustudic <kustodian@gmail.com>2016-06-16 18:46:12 +0200
committerBrian Coca <bcoca@ansible.com>2016-06-16 12:46:12 -0400
commit127ddc1f059ff5898cd56a4207989041a2d02379 (patch)
treef133f0b9b4271fa2f8df3f0ae13c77dfd2217fb5 /database/postgresql/postgresql_ext.py
parenteed9d601b5b727586e16f3afa5824031dfbc88df (diff)
downloadansible-modules-extras-127ddc1f059ff5898cd56a4207989041a2d02379.tar.gz
Fixes check mode error on Python 2.4 and wrong changed state (#2438)
* Fixes check mode error on Python 2.4 and wrong changed state * Changes code as suggested by @bcoca
Diffstat (limited to 'database/postgresql/postgresql_ext.py')
-rw-r--r--database/postgresql/postgresql_ext.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/database/postgresql/postgresql_ext.py b/database/postgresql/postgresql_ext.py
index d3079630..684f3b2c 100644
--- a/database/postgresql/postgresql_ext.py
+++ b/database/postgresql/postgresql_ext.py
@@ -164,23 +164,22 @@ def main():
try:
if module.check_mode:
- if state == "absent":
+ if state == "present":
changed = not ext_exists(cursor, ext)
- elif state == "present":
+ elif state == "absent":
changed = ext_exists(cursor, ext)
- module.exit_json(changed=changed,ext=ext)
-
- if state == "absent":
- changed = ext_delete(cursor, ext)
-
- elif state == "present":
- changed = ext_create(cursor, ext)
+ else:
+ if state == "absent":
+ changed = ext_delete(cursor, ext)
+
+ elif state == "present":
+ changed = ext_create(cursor, ext)
except NotSupportedError, e:
module.fail_json(msg=str(e))
except Exception, e:
module.fail_json(msg="Database query failed: %s" % e)
- module.exit_json(changed=changed, db=db)
+ module.exit_json(changed=changed, db=db, ext=ext)
# import module snippets
from ansible.module_utils.basic import *