mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #5099 from tartansandal/postgresql_db_check_mode
postgres_db CHECKMODE changed status
This commit is contained in:
commit
7182486fd2
1 changed files with 23 additions and 1 deletions
|
@ -192,6 +192,23 @@ def db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype):
|
||||||
else:
|
else:
|
||||||
return False
|
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.
|
# Module execution.
|
||||||
#
|
#
|
||||||
|
@ -254,7 +271,12 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if module.check_mode:
|
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":
|
if state == "absent":
|
||||||
changed = db_delete(cursor, db)
|
changed = db_delete(cursor, db)
|
||||||
|
|
Loading…
Reference in a new issue