From c93cf6780227c53afd2f34218f8e2561aef2c87f Mon Sep 17 00:00:00 2001 From: Jamal Boukaffal Date: Mon, 11 Sep 2023 15:23:26 +0200 Subject: [PATCH] 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: https://github.com/ansible-collections/community.postgresql/issues/212 https://github.com/ansible-collections/community.postgresql/pull/227 https://github.com/ansible-collections/community.postgresql/issues/493 --- README.md | 10 ++++++---- tasks/users_privileges.yml | 13 ++++++++----- tests/docker/group_vars/postgresql.yml | 4 ++-- tests/vars.yml | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 761263fb..86cec798 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,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) diff --git a/tasks/users_privileges.yml b/tasks/users_privileges.yml index 94aaea24..6b2451cc 100644 --- a/tasks/users_privileges.yml +++ b/tasks/users_privileges.yml @@ -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)}}" diff --git a/tests/docker/group_vars/postgresql.yml b/tests/docker/group_vars/postgresql.yml index b21122a1..7c5b413d 100644 --- a/tests/docker/group_vars/postgresql.yml +++ b/tests/docker/group_vars/postgresql.yml @@ -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 diff --git a/tests/vars.yml b/tests/vars.yml index 3ff59a66..55bcf3c2 100644 --- a/tests/vars.yml +++ b/tests/vars.yml @@ -32,8 +32,8 @@ postgresql_users: - name: zabaz postgresql_user_privileges: - - name: baz - db: foobar + - roles: baz + database: foobar postgresql_database_schemas: - database: foobar