Skip to content

deprecates the db-alias in postgresql_user #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/0-postgresql-user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
breaking_changes:
- postgresql_user - the ``db`` alias is deprecated and will be removed in the next major release, use the ``login_db`` argument instead.
28 changes: 17 additions & 11 deletions plugins/modules/postgresql_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
- Note that if the provided password string is already in MD5-hashed
format, then it is used as-is, regardless of I(encrypted) option.
type: str
db:
login_db:
description:
- Name of database to connect to and where user's permissions are granted.
type: str
default: ''
aliases:
- login_db
- db
fail_on_user:
description:
- If C(true), fails when the user (role) cannot be removed. Otherwise just log and continue.
Expand Down Expand Up @@ -220,15 +220,15 @@
# You should use the 'postgresql_privs' module instead.
- name: Connect to acme database, create django user, and grant access to database and products table
community.postgresql.postgresql_user:
db: acme
login_db: acme
name: django
password: ceec4eif7ya
priv: "CONNECT/products:ALL"
expires: "Jan 31 2020"

- name: Add a comment on django user
community.postgresql.postgresql_user:
db: acme
login_db: acme
name: django
comment: This is a test user

Expand All @@ -249,7 +249,7 @@
# You should use the 'postgresql_privs' module instead.
- name: Connect to acme database and remove test user privileges from there
community.postgresql.postgresql_user:
db: acme
login_db: acme
name: test
priv: "ALL/products:ALL"
state: absent
Expand All @@ -259,7 +259,7 @@
# You should use the 'postgresql_privs' module instead.
- name: Connect to test database, remove test user from cluster
community.postgresql.postgresql_user:
db: test
login_db: test
name: test
priv: ALL
state: absent
Expand All @@ -268,7 +268,7 @@
# You should use the 'postgresql_privs' module instead.
- name: Connect to acme database and set user's password with no expire date
community.postgresql.postgresql_user:
db: acme
login_db: acme
name: django
password: mysupersecretword
priv: "CONNECT/products:ALL"
Expand All @@ -279,7 +279,7 @@

- name: Connect to test database and remove an existing user's password
community.postgresql.postgresql_user:
db: test
login_db: test
user: test
password: ""

Expand Down Expand Up @@ -1096,7 +1096,13 @@ def main():
password=dict(type='str', default=None, no_log=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
priv=dict(type='str', default=None, removed_in_version='4.0.0', removed_from_collection='community.postgreql'),
db=dict(type='str', default='', aliases=['login_db']),
login_db=dict(type='str', default="", aliases=['db'], deprecated_aliases=[
{
'name': 'db',
'version': '4.0.0',
'collection_name': 'community.postgresql',
}],
),
fail_on_user=dict(type='bool', default=True, aliases=['fail_on_role']),
role_attr_flags=dict(type='str', default=''),
encrypted=dict(type='bool', default=True),
Expand All @@ -1119,10 +1125,10 @@ def main():
state = module.params["state"]
fail_on_user = module.params["fail_on_user"]
# WARNING: privs are deprecated and will be removed in community.postgresql 4.0.0
if module.params['db'] == '' and module.params["priv"] is not None:
if module.params['login_db'] == '' and module.params["priv"] is not None:
module.fail_json(msg="privileges require a database to be specified")
# WARNING: privs are deprecated and will be removed in community.postgresql 4.0.0
privs = parse_privs(module.params["priv"], module.params["db"])
privs = parse_privs(module.params["priv"], module.params["login_db"])
no_password_changes = module.params["no_password_changes"]
if module.params["encrypted"]:
encrypted = "ENCRYPTED"
Expand Down