community.postgresql 4.2.0 Released - Whats New and How to Test
Introduction
community.postgresql is the Ansible Collection that provides modules and plugins to manage PostgreSQL databases, roles, privileges, extensions, and configuration through Ansible playbooks. It is one of the collections bundled in the ansible community package and is commonly used to automate PostgreSQL database provisioning and administration.
Version 4.2.0 has been published to Ansible Galaxy. This is a minor release that adds one new privilege-related feature for PostgreSQL 17 and fixes three bugs in the postgresql_db module.
Whats New
Minor Changes
postgresql_privs- now supports granting theMAINTAINprivilege on tables. This privilege was introduced in PostgreSQL 17 and covers maintenance operations such asVACUUM,ANALYZE,REINDEX, andCLUSTERwithout requiring ownership of the table (https://github.com/ansible-collections/community.postgresql/pull/888).
Bugfixes
postgresql_db- fixed connection limit not being applied when the value is set to"0"(https://github.com/ansible-collections/community.postgresql/issues/879).postgresql_db- fixed thesession_roleparameter, which was being silently ignored for raw connections (https://github.com/ansible-collections/community.postgresql/pull/865).postgresql_db- fixed a bug where restoring from.sqlfiles caused the file to be executed twice. The module now avoids combining--fileand stdin redirection at the same time when invoking the restore command (https://github.com/ansible-collections/community.postgresql/issues/882).
Affected Components
| Component | Type | Change |
|---|---|---|
| postgresql_privs | Module | Adds support for MAINTAIN privilege (PostgreSQL 17) |
| postgresql_db | Module | Fixes connection limit handling for value "0" |
| postgresql_db | Module | Fixes session_role being ignored on raw connections |
| postgresql_db | Module | Fixes double execution when restoring .sql files |
How to Install and Test
Install or upgrade the collection from Ansible Galaxy:
ansible-galaxy collection install community.postgresql --upgrade
ansible-galaxy collection list community.postgresql
ansible-doc postgresql_privs -s
ansible-doc postgresql_db -s
To confirm the exact version installed and pin it explicitly in a requirements.yml file:
cat > requirements.yml << 'EOF'
collections:
- name: community.postgresql
version: 4.2.0
EOF
ansible-galaxy collection install -r requirements.yml
Users relying on the MAINTAIN privilege support should verify the target PostgreSQL server is version 17 or later, since this privilege does not exist on older PostgreSQL versions. Users who restore databases from .sql files with postgresql_db should re-test their state: restore tasks against version 4.2.0 to confirm the file is no longer executed twice.