1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

postgresql modules: missing_required_libs, removed excess param mapping (#55506)

This commit is contained in:
Andrey Klychkov 2019-04-18 11:57:22 +03:00 committed by John R Barker
parent 62badd76a5
commit 0ff67d0a1c
7 changed files with 9 additions and 29 deletions

View file

@ -473,7 +473,7 @@ try:
except ImportError: except ImportError:
HAS_PSYCOPG2 = False HAS_PSYCOPG2 = False
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.database import SQLParseError from ansible.module_utils.database import SQLParseError
from ansible.module_utils.postgres import postgres_common_argument_spec from ansible.module_utils.postgres import postgres_common_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -922,10 +922,7 @@ def main():
argument_spec = postgres_common_argument_spec() argument_spec = postgres_common_argument_spec()
argument_spec.update( argument_spec.update(
db=dict(type='str', aliases=['login_db']), db=dict(type='str', aliases=['login_db']),
port=dict(type='int', default=5432, aliases=['login_port']),
filter=dict(type='list'), filter=dict(type='list'),
ssl_mode=dict(type='str', default='prefer', choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']),
ca_cert=dict(type='str', aliases=['ssl_rootcert']),
session_role=dict(type='str'), session_role=dict(type='str'),
) )
module = AnsibleModule( module = AnsibleModule(
@ -934,7 +931,7 @@ def main():
) )
if not HAS_PSYCOPG2: if not HAS_PSYCOPG2:
module.fail_json(msg="The python psycopg2 module is required") module.fail_json(msg=missing_required_lib('psycopg2'))
filter_ = module.params["filter"] filter_ = module.params["filter"]
sslrootcert = module.params["ca_cert"] sslrootcert = module.params["ca_cert"]

View file

@ -174,10 +174,10 @@ import traceback
PSYCOPG2_IMP_ERR = None PSYCOPG2_IMP_ERR = None
try: try:
import psycopg2 import psycopg2
postgresqldb_found = True HAS_PSYCOPG2 = True
except ImportError: except ImportError:
PSYCOPG2_IMP_ERR = traceback.format_exc() PSYCOPG2_IMP_ERR = traceback.format_exc()
postgresqldb_found = False HAS_PSYCOPG2 = False
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.postgres import postgres_common_argument_spec from ansible.module_utils.postgres import postgres_common_argument_spec
@ -267,7 +267,7 @@ def main():
sslrootcert = module.params["ca_cert"] sslrootcert = module.params["ca_cert"]
session_role = module.params["session_role"] session_role = module.params["session_role"]
if not postgresqldb_found: if not HAS_PSYCOPG2:
module.fail_json(msg=missing_required_lib('psycopg2'), exception=PSYCOPG2_IMP_ERR) module.fail_json(msg=missing_required_lib('psycopg2'), exception=PSYCOPG2_IMP_ERR)
# To use defaults values, keyword arguments must be absent, so # To use defaults values, keyword arguments must be absent, so

View file

@ -78,7 +78,7 @@ try:
except ImportError: except ImportError:
HAS_PSYCOPG2 = False HAS_PSYCOPG2 = False
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.database import SQLParseError from ansible.module_utils.database import SQLParseError
from ansible.module_utils.postgres import postgres_common_argument_spec from ansible.module_utils.postgres import postgres_common_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -142,7 +142,7 @@ def main():
) )
if not HAS_PSYCOPG2: if not HAS_PSYCOPG2:
module.fail_json(msg="The python psycopg2 module is required") module.fail_json(msg=missing_required_lib('psycopg2'))
sslrootcert = module.params["ca_cert"] sslrootcert = module.params["ca_cert"]

View file

@ -218,19 +218,11 @@ def schema_matches(cursor, schema, owner):
def main(): def main():
argument_spec = postgres_common_argument_spec() argument_spec = postgres_common_argument_spec()
argument_spec.update( argument_spec.update(
login_user=dict(type="str", default="postgres"),
login_password=dict(type="str", default="", no_log=True),
login_host=dict(type="str", default=""),
login_unix_socket=dict(type="str", default=""),
port=dict(type="int", default=5432, aliases=["login_port"]),
schema=dict(type="str", required=True, aliases=['name']), schema=dict(type="str", required=True, aliases=['name']),
owner=dict(type="str", default=""), owner=dict(type="str", default=""),
database=dict(type="str", default="postgres", aliases=["db", "login_db"]), database=dict(type="str", default="postgres", aliases=["db", "login_db"]),
cascade_drop=dict(type="bool", default=False), cascade_drop=dict(type="bool", default=False),
state=dict(type="str", default="present", choices=["absent", "present"]), state=dict(type="str", default="present", choices=["absent", "present"]),
ssl_mode=dict(type="str", default='prefer', choices=[
'disable', 'allow', 'prefer', 'require', 'verify-ca', 'verify-full']),
ca_cert=dict(type="str", default=None, aliases=['ssl_rootcert']),
session_role=dict(type="str"), session_role=dict(type="str"),
) )

View file

@ -165,7 +165,7 @@ try:
except ImportError: except ImportError:
HAS_PSYCOPG2 = False HAS_PSYCOPG2 = False
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.database import SQLParseError from ansible.module_utils.database import SQLParseError
from ansible.module_utils.postgres import postgres_common_argument_spec from ansible.module_utils.postgres import postgres_common_argument_spec
from ansible.module_utils.six import iteritems from ansible.module_utils.six import iteritems
@ -296,9 +296,6 @@ def main():
argument_spec.update( argument_spec.update(
name=dict(type='str', required=True), name=dict(type='str', required=True),
db=dict(type='str', aliases=['login_db']), db=dict(type='str', aliases=['login_db']),
port=dict(type='int', default=5432, aliases=['login_port']),
ssl_mode=dict(type='str', default='prefer', choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']),
ca_cert=dict(type='str', aliases=['ssl_rootcert']),
value=dict(type='str'), value=dict(type='str'),
reset=dict(type='bool'), reset=dict(type='bool'),
session_role=dict(type='str'), session_role=dict(type='str'),
@ -309,7 +306,7 @@ def main():
) )
if not HAS_PSYCOPG2: if not HAS_PSYCOPG2:
module.fail_json(msg="the python psycopg2 module is required") module.fail_json(msg=missing_required_lib('psycopg2'))
name = module.params["name"] name = module.params["name"]
value = module.params["value"] value = module.params["value"]

View file

@ -444,9 +444,6 @@ def main():
table=dict(type='str', required=True, aliases=['name']), table=dict(type='str', required=True, aliases=['name']),
state=dict(type='str', default="present", choices=["absent", "present"]), state=dict(type='str', default="present", choices=["absent", "present"]),
db=dict(type='str', default='', aliases=['login_db']), db=dict(type='str', default='', aliases=['login_db']),
port=dict(type='int', default=5432, aliases=['login_port']),
ssl_mode=dict(type='str', default='prefer', choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']),
ca_cert=dict(type='str', aliases=['ssl_rootcert']),
tablespace=dict(type='str'), tablespace=dict(type='str'),
owner=dict(type='str'), owner=dict(type='str'),
unlogged=dict(type='bool'), unlogged=dict(type='bool'),

View file

@ -347,9 +347,6 @@ def main():
set=dict(type='dict'), set=dict(type='dict'),
rename_to=dict(type='str'), rename_to=dict(type='str'),
db=dict(type='str', aliases=['login_db']), db=dict(type='str', aliases=['login_db']),
port=dict(type='int', default=5432, aliases=['login_port']),
ssl_mode=dict(type='str', default='prefer', choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']),
ca_cert=dict(type='str', aliases=['ssl_rootcert']),
session_role=dict(type='str'), session_role=dict(type='str'),
) )