diff options
author | Kahlil (Kal) Hodgson <kahlil.hodgson@dealmax.com.au> | 2013-11-29 00:50:01 +0100 |
---|---|---|
committer | Kahlil (Kal) Hodgson <kahlil.hodgson@dealmax.com.au> | 2013-11-29 01:29:03 +0100 |
commit | ab14ec840bf7df9853b6cc2c7a1cd580afe1e5f8 (patch) | |
tree | d032a3baaf817a55c5bf357c6945baa9e22b84b9 /library | |
parent | Add bigip_monitor_http to changelog (diff) | |
download | ansible-ab14ec840bf7df9853b6cc2c7a1cd580afe1e5f8.tar.xz ansible-ab14ec840bf7df9853b6cc2c7a1cd580afe1e5f8.zip |
postgres_db CHECKMODE changed status
Make the changed status for postgres_db under CHECKMODE match the
status that would be returned normally.
Diffstat (limited to 'library')
-rw-r--r-- | library/database/postgresql_db | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/library/database/postgresql_db b/library/database/postgresql_db index f7274da884..ddd3ccbc59 100644 --- a/library/database/postgresql_db +++ b/library/database/postgresql_db @@ -192,6 +192,23 @@ def db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype): else: return False +def db_matches(cursor, db, owner, template, encoding, lc_collate, lc_ctype): + if not db_exists(cursor, db): + return False + else: + db_info = get_db_info(cursor, db) + if (encoding and + get_encoding_id(cursor, encoding) != db_info['encoding_id']): + return False + elif lc_collate and lc_collate != db_info['lc_collate']: + return False + elif lc_ctype and lc_ctype != db_info['lc_ctype']: + return False + elif owner and owner != db_info['owner']: + return False + else: + return True + # =========================================== # Module execution. # @@ -254,7 +271,12 @@ def main(): try: if module.check_mode: - module.exit_json(changed=True,db=db) + if state == "absent": + changed = not db_exists(cursor, db) + elif state == "present": + changed = not db_matches(cursor, db, owner, template, encoding, + lc_collate, lc_ctype) + module.exit_json(changed=changed,db=db) if state == "absent": changed = db_delete(cursor, db) |