Skip to content

Commit

Permalink
Fix postgresql_user priv argument deprecation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jamal-B committed Feb 15, 2024
1 parent a0c970e commit 0c842a6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ postgresql_database_schemas:

# List of user privileges to be applied (optional)
postgresql_user_privileges:
- name: baz # user name
db: foobar # database
priv: "ALL" # privilege string format: example: INSERT,UPDATE/table:SELECT/anothertable:ALL
role_attr_flags: "CREATEDB" # role attribute flags
- roles: baz # comma separated list of role (user/group) names to set permissions for.
database: foobar # name of database to connect to.
schema: acme_baz # schema that contains the database objects specified via objs (see documentation for details).
type: table # type of database object to set privileges on. e.g.: table (default), sequence, function,... (see documentation for details)
objs: employee # comma separated list of database objects to set privileges on (see documentation for details).
privs: "ALL" # comma separated list of privileges to grant. e.g.: INSERT,UPDATE/ALL/USAGE
```
There's a lot more knobs and bolts to set, which you can find in the [defaults/main.yml](./defaults/main.yml)
Expand Down
13 changes: 8 additions & 5 deletions tasks/users_privileges.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# file: postgresql/tasks/users_privileges.yml

- name: PostgreSQL | Update the user privileges
postgresql_user:
name: "{{item.name}}"
db: "{{item.db | default(omit)}}"
port: "{{postgresql_port}}"
priv: "{{item.priv | default(omit)}}"
postgresql_privs:
roles: "{{item.roles}}"
database: "{{item.database | default(omit)}}"
schema: "{{item.schema | default(omit)}}"
type: "{{item.type | default(omit)}}"
objs: "{{item.objs | default(omit)}}"
privs: "{{item.privs | default(omit)}}"
state: present
port: "{{postgresql_port}}"
login_host: "{{item.host | default(omit)}}"
login_user: "{{postgresql_admin_user}}"
role_attr_flags: "{{item.role_attr_flags | default(omit)}}"
Expand Down
4 changes: 2 additions & 2 deletions tests/docker/group_vars/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ postgresql_database_schemas:
owner: baz

postgresql_user_privileges:
- name: baz
db: foobar
- roles: baz
database: foobar

postgresql_ext_install_contrib: true

Expand Down
4 changes: 2 additions & 2 deletions tests/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ postgresql_users:
- name: zabaz

postgresql_user_privileges:
- name: baz
db: foobar
- roles: baz
database: foobar

postgresql_database_schemas:
- database: foobar
Expand Down

0 comments on commit 0c842a6

Please sign in to comment.