mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-07-06 10:38:54 +00:00
Add postgresql_db and postgresql_use checkmode.
This commit is contained in:
parent
6d604469d8
commit
621eb5eccc
2 changed files with 32 additions and 2 deletions
|
|
@ -59,6 +59,11 @@ options:
|
|||
- Encoding of the database
|
||||
required: false
|
||||
default: null
|
||||
encoding:
|
||||
description:
|
||||
- Encoding of the database
|
||||
required: false
|
||||
default: null
|
||||
state:
|
||||
description:
|
||||
- The database state
|
||||
|
|
@ -143,7 +148,8 @@ def main():
|
|||
template=dict(default=""),
|
||||
encoding=dict(default=""),
|
||||
state=dict(default="present", choices=["absent", "present"]),
|
||||
)
|
||||
),
|
||||
supports_check_mode = True
|
||||
)
|
||||
|
||||
if not postgresqldb_found:
|
||||
|
|
@ -182,10 +188,15 @@ def main():
|
|||
module.fail_json(msg="unable to connect to database: %s" % e)
|
||||
|
||||
try:
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True,db=db)
|
||||
|
||||
if state == "absent":
|
||||
changed = db_delete(cursor, db)
|
||||
|
||||
elif state == "present":
|
||||
changed = db_create(cursor, db, owner, template, encoding)
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg="Database query failed: %s" % e)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue