Add optional input check to postgresql_ext (#282)

* Add optional input check to postgresql_ext

Have added a new trust_input check to the postgresql_ext module that
allows for checking the input that is passed to the module.

* Add changelog fragment

* Update tests/integration/targets/postgresql_ext/tasks/postgresql_ext_initial.yml

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
Thomas O'Donnell 2020-05-05 14:04:33 +02:00 committed by GitHub
parent 177314321b
commit 6c1c1604fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 0 deletions

View file

@ -80,6 +80,11 @@ options:
When version downgrade is needed, remove the extension and create new one with appropriate version.
- Set I(version=latest) to update the extension to the latest available version.
type: str
trust_input:
description:
- If C(no), check whether values of some parameters are potentially dangerous.
type: bool
default: yes
seealso:
- name: PostgreSQL extensions
description: General information about PostgreSQL extensions.
@ -175,6 +180,9 @@ except ImportError:
pass
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.database import (
check_input,
)
from ansible_collections.community.general.plugins.module_utils.postgres import (
connect_to_db,
get_conn_params,
@ -309,6 +317,7 @@ def main():
cascade=dict(type="bool", default=False),
session_role=dict(type="str"),
version=dict(type="str"),
trust_input=dict(type="bool", default=True),
)
module = AnsibleModule(
@ -321,8 +330,13 @@ def main():
state = module.params["state"]
cascade = module.params["cascade"]
version = module.params["version"]
session_role = module.params["session_role"]
trust_input = module.params["trust_input"]
changed = False
if not trust_input:
check_input(module, ext, schema, version, session_role)
if version and state == 'absent':
module.warn("Parameter version is ignored when state=absent")