From 81a51834281355eba14524152d4f437e9b95caef Mon Sep 17 00:00:00 2001 From: Andrey Klychkov Date: Wed, 7 Aug 2019 23:58:37 +0300 Subject: [PATCH] Backport/2.8/60105: turn off the default db warning where it doesn't make sense (#60107) * Bugfix 60043: turn off the default db warning where it doesn't make sense (#60105) (cherry picked from commit d2cc9f5f06816935747638f5b4019b84d5932a51) * Backport of 60105: turn off the default db warning where it doesn't make sense --- ...0105-postgresql_turn_off_db_default_warnings.yml | 5 +++++ .../database/postgresql/postgresql_membership.py | 2 +- .../modules/database/postgresql/postgresql_ping.py | 2 +- .../modules/database/postgresql/postgresql_slot.py | 13 ++++++++++++- .../database/postgresql/postgresql_tablespace.py | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/60105-postgresql_turn_off_db_default_warnings.yml diff --git a/changelogs/fragments/60105-postgresql_turn_off_db_default_warnings.yml b/changelogs/fragments/60105-postgresql_turn_off_db_default_warnings.yml new file mode 100644 index 00000000000..095139e6125 --- /dev/null +++ b/changelogs/fragments/60105-postgresql_turn_off_db_default_warnings.yml @@ -0,0 +1,5 @@ +bugfixes: +- postgresql_slot - turn off the default database warning for slot_type physical (https://github.com/ansible/ansible/issues/60043) +- postgresql_membership - turn off the default database warning (https://github.com/ansible/ansible/pull/60043) +- postgresql_ping - turn off the default database warning (https://github.com/ansible/ansible/pull/60043) +- postgresql_tablespace - turn off the default database warning (https://github.com/ansible/ansible/pull/60043) diff --git a/lib/ansible/modules/database/postgresql/postgresql_membership.py b/lib/ansible/modules/database/postgresql/postgresql_membership.py index 369cc279033..f82d5561097 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_membership.py +++ b/lib/ansible/modules/database/postgresql/postgresql_membership.py @@ -294,7 +294,7 @@ def main(): fail_on_role = module.params['fail_on_role'] state = module.params['state'] - conn_params = get_conn_params(module, module.params) + conn_params = get_conn_params(module, module.params, warn_db_default=False) db_connection = connect_to_db(module, conn_params, autocommit=False) cursor = db_connection.cursor(cursor_factory=DictCursor) diff --git a/lib/ansible/modules/database/postgresql/postgresql_ping.py b/lib/ansible/modules/database/postgresql/postgresql_ping.py index 495995751e0..568e979a65e 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_ping.py +++ b/lib/ansible/modules/database/postgresql/postgresql_ping.py @@ -147,7 +147,7 @@ def main(): server_version=dict(), ) - conn_params = get_conn_params(module, module.params) + conn_params = get_conn_params(module, module.params, warn_db_default=False) db_connection = connect_to_db(module, conn_params, fail_on_conn=False) if db_connection is not None: diff --git a/lib/ansible/modules/database/postgresql/postgresql_slot.py b/lib/ansible/modules/database/postgresql/postgresql_slot.py index 2ec458d1b85..6435cc1cd5b 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_slot.py +++ b/lib/ansible/modules/database/postgresql/postgresql_slot.py @@ -255,7 +255,18 @@ def main(): if immediately_reserve and slot_type == 'logical': module.fail_json(msg="Module parameters immediately_reserve and slot_type=logical are mutually exclusive") - conn_params = get_conn_params(module, module.params) + # When slot_type is logical and parameter db is not passed, + # the default database will be used to create the slot and + # the user should know about this. + # When the slot type is physical, + # it doesn't matter which database will be used + # because physical slots are global objects. + if slot_type == 'logical': + warn_db_default = True + else: + warn_db_default = False + + conn_params = get_conn_params(module, module.params, warn_db_default=warn_db_default) db_connection = connect_to_db(module, conn_params, autocommit=True) cursor = db_connection.cursor(cursor_factory=DictCursor) diff --git a/lib/ansible/modules/database/postgresql/postgresql_tablespace.py b/lib/ansible/modules/database/postgresql/postgresql_tablespace.py index 6aef0fac57f..ea09fc237ce 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_tablespace.py +++ b/lib/ansible/modules/database/postgresql/postgresql_tablespace.py @@ -346,7 +346,7 @@ def main(): module.fail_json(msg="state=absent is mutually exclusive location, " "owner, rename_to, and set") - conn_params = get_conn_params(module, module.params) + conn_params = get_conn_params(module, module.params, warn_db_default=False) db_connection = connect_to_db(module, conn_params, autocommit=True) cursor = db_connection.cursor(cursor_factory=DictCursor)