Skip to content

Commit 62fec28

Browse files
committed
Fix postgresql_user priv argument deprecation
Fix this warning: ``` [DEPRECATION WARNING]: Param 'priv' is deprecated. See the module docs for more information. This feature will be removed from community.postgreql in version 3.0.0. ``` See: ansible-collections/community.postgresql#212 ansible-collections/community.postgresql#227 ansible-collections/community.postgresql#493
1 parent 7b19b76 commit 62fec28

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ postgresql_database_schemas:
126126

127127
# List of user privileges to be applied (optional)
128128
postgresql_user_privileges:
129-
- name: baz # user name
130-
db: foobar # database
131-
priv: "ALL" # privilege string format: example: INSERT,UPDATE/table:SELECT/anothertable:ALL
132-
role_attr_flags: "CREATEDB" # role attribute flags
129+
- roles: baz # comma separated list of role (user/group) names to set permissions for.
130+
database: foobar # name of database to connect to.
131+
schema: acme_baz # schema that contains the database objects specified via objs (see documentation for details).
132+
type: table # type of database object to set privileges on. e.g.: table (default), sequence, function,... (see documentation for details)
133+
objs: employee # comma separated list of database objects to set privileges on (see documentation for details).
134+
privs: "ALL" # comma separated list of privileges to grant. e.g.: INSERT,UPDATE/ALL/USAGE
133135
```
134136
135137
There's a lot more knobs and bolts to set, which you can find in the [defaults/main.yml](./defaults/main.yml)

tasks/users_privileges.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# file: postgresql/tasks/users_privileges.yml
22

33
- name: PostgreSQL | Update the user privileges
4-
postgresql_user:
5-
name: "{{item.name}}"
6-
db: "{{item.db | default(omit)}}"
7-
port: "{{postgresql_port}}"
8-
priv: "{{item.priv | default(omit)}}"
4+
postgresql_privs:
5+
roles: "{{item.roles}}"
6+
database: "{{item.database | default(omit)}}"
7+
schema: "{{item.schema | default(omit)}}"
8+
type: "{{item.type | default(omit)}}"
9+
objs: "{{item.objs | default(omit)}}"
10+
privs: "{{item.privs | default(omit)}}"
911
state: present
12+
port: "{{postgresql_port}}"
1013
login_host: "{{item.host | default(omit)}}"
1114
login_user: "{{postgresql_admin_user}}"
1215
role_attr_flags: "{{item.role_attr_flags | default(omit)}}"

tests/docker/group_vars/postgresql.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ postgresql_database_schemas:
3535
owner: baz
3636

3737
postgresql_user_privileges:
38-
- name: baz
39-
db: foobar
38+
- roles: baz
39+
database: foobar
4040

4141
postgresql_ext_install_contrib: true
4242

tests/vars.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ postgresql_users:
3232
- name: zabaz
3333

3434
postgresql_user_privileges:
35-
- name: baz
36-
db: foobar
35+
- roles: baz
36+
database: foobar
3737

3838
postgresql_database_schemas:
3939
- database: foobar

0 commit comments

Comments
 (0)