SUMMARY
Currently there seems to be no way to specify exact list of groups for user. You can only grant or revoke individual groups, without ability to revoke all groups from user.
There should be something like append in user module (https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html#parameter-append), that allows to choose, if list of groups should be exact and exclusive.
Use case 1: revoke all groups from user.
Use case 2: user should be only in specified groups (and removed from any other groups).
ISSUE TYPE
COMPONENT NAME
community.postgresql.postgresql_membership and community.postgresql.postgresql_user.