Skip to content

Commit

Permalink
[PR #295/fd11383f backport][stable-1] deprecate groups argument (#298)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Co-authored-by: Douglas J Hunley <doug.hunley@gmail.com>
  • Loading branch information
3 people authored Jun 22, 2022
1 parent b988411 commit 1cbe469
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/0-postgresql_user-deprecate-privs-manipulation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_changes:
- postgresql_user - the ``groups`` argument has been deprecated and will be removed in ``community.postgresql 3.0.0``. Please use the ``postgresql_membership`` module to specify group/role memberships instead (https://github.com/ansible-collections/community.postgresql/issues/277).
13 changes: 12 additions & 1 deletion plugins/modules/postgresql_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
whether the user has been removed or not.
- B(WARNING) The I(priv) option has been B(deprecated) and will be removed in community.postgresql 3.0.0. Please use the
M(community.postgresql.postgresql_privs) module instead.
- B(WARNING) The I(groups) option has been B(deprecated) ans will be removed in community.postgresql 3.0.0.
Please use the M(community.postgresql.postgresql_membership) module instead.
options:
name:
description:
Expand Down Expand Up @@ -139,6 +141,9 @@
aliases: [ ssl_rootcert ]
groups:
description:
- This option has been B(deprecated) and will be removed in community.postgresql 3.0.0.
Please use the I(postgresql_membership) module to GRANT/REVOKE group/role memberships
instead.
- The list of groups (roles) that you want to grant to the user.
type: list
elements: str
Expand Down Expand Up @@ -252,6 +257,8 @@
user: test
password: ""
# This example uses the `group` argument which is deprecated.
# You should use the `postgresql_membership` module instead.
- name: Create user test and grant group user_ro and user_rw to it
community.postgresql.postgresql_user:
name: test
Expand Down Expand Up @@ -926,7 +933,8 @@ def main():
expires=dict(type='str', default=None),
conn_limit=dict(type='int', default=None),
session_role=dict(type='str'),
groups=dict(type='list', elements='str'),
# WARNING: groups are deprecated and will be removed in community.postgresql 3.0.0
groups=dict(type='list', elements='str', removed_in_version='3.0.0', removed_from_collection='community.postgreql'),
comment=dict(type='str', default=None),
trust_input=dict(type='bool', default=True),
)
Expand All @@ -952,6 +960,7 @@ def main():
expires = module.params["expires"]
conn_limit = module.params["conn_limit"]
role_attr_flags = module.params["role_attr_flags"]
# WARNING: groups are deprecated and will be removed in community.postgresql 3.0.0
groups = module.params["groups"]
if groups:
groups = [e.strip() for e in groups]
Expand All @@ -961,6 +970,7 @@ def main():
trust_input = module.params['trust_input']
if not trust_input:
# Check input for potentially dangerous elements:
# WARNING: groups are deprecated and will be removed in community.postgresql 3.0.0
check_input(module, user, password, privs, expires,
role_attr_flags, groups, comment, session_role)

Expand Down Expand Up @@ -1000,6 +1010,7 @@ def main():
except SQLParseError as e:
module.fail_json(msg=to_native(e), exception=traceback.format_exc())

# WARNING: groups are deprecated and will be removed in community.postgresql 3.0.0
if groups:
target_roles = []
target_roles.append(user)
Expand Down

0 comments on commit 1cbe469

Please sign in to comment.