diff --git a/changelogs/fragments/651-fix-postgresql_set-warning.yaml b/changelogs/fragments/651-fix-postgresql_set-warning.yaml new file mode 100644 index 0000000000..8369a4cef5 --- /dev/null +++ b/changelogs/fragments/651-fix-postgresql_set-warning.yaml @@ -0,0 +1,4 @@ +--- +bugfixes: + - postgresql_set - only display a warning about restarts, when + restarting is needed (https://github.com/ansible-collections/community.general/pull/651). diff --git a/plugins/modules/database/postgresql/postgresql_set.py b/plugins/modules/database/postgresql/postgresql_set.py index 346993ea69..3aaed12026 100644 --- a/plugins/modules/database/postgresql/postgresql_set.py +++ b/plugins/modules/database/postgresql/postgresql_set.py @@ -406,9 +406,6 @@ def main(): changed = param_set(cursor, module, name, boot_val, context) - if restart_required: - module.warn("Restart of PostgreSQL is required for setting %s" % name) - cursor.close() db_connection.close() @@ -439,6 +436,10 @@ def main(): kw['changed'] = changed kw['restart_required'] = restart_required + + if restart_required and changed: + module.warn("Restart of PostgreSQL is required for setting %s" % name) + module.exit_json(**kw)