Introduction
community.postgresql is the Ansible collection that provides modules and plugins for managing PostgreSQL databases and clusters, including roles, databases, privileges, publications, extensions, and server configuration via ALTER SYSTEM. Version 5.1.3 has been published to Ansible Galaxy as a patch release following 5.1.2, containing only bugfixes to existing modules and plugins, with no new features or breaking changes.
Whats New
This release focuses almost entirely on postgresql_alter_system, with additional fixes for postgresql_db, postgresql_publication, and postgresql_query/postgresql_script.
postgresql_alter_system fixes
- Boolean values are now compared across every spelling PostgreSQL accepts (
true,yes,1, etc.), and enum values are compared case-insensitively. Setting the same value again in a different spelling or case (for exampleWARNINGforlog_min_messages) no longer reports a spurious change (PR #998). - Parameters of type
realare now compared as floating point numbers using the 6 significant digits shown bypg_settings. Previously, values such as1.0failed withcannot be converted to int, and parameters shown in scientific notation (for example1e-05) always failed. Real-type parameters with a time unit, such asvacuum_cost_delay, now correctly accept fractional values (PR #997). output_plugin_libraries(PostgreSQL 14.24, 15.19, 16.15, 17.11, 18.6 and later) andoauth_validator_libraries(PostgreSQL 18+) are now treated asGUC_LIST_QUOTElist parameters, so re-applying the same list no longer reports a change (PR #996).- When a parameter is set at role, database, connection, or session level (
ALTER ROLE/DATABASE ... SET,ALTER ROLE ALL ... SET), the module now compares the desired value against the value stored in the configuration files instead of the current session value frompg_settings. Previously this could cause the module to report no change and leave the server configuration untouched (PR #999).
Other module fixes
postgresql_db- errors frompsqlorpg_restoreduring a compressed dump restore are now properly reported. Previously, if the restore program exited early (for example due to an unknown option intarget_optsor a failed login), the decompressor would die withSIGPIPEand the module returnedrc=-13with an empty message (issue #916).postgresql_publication- fixed change detection forpublish_via_partition_root(PR #984).postgresql_query,postgresql_script- lists of strings passed inpositional_argsornamed_argsare now quoted as PostgreSQL array elements instead of embedding Python's single quotes literally (issue #411).postgresql_query,postgresql_script-Noneelements inside a list passed inpositional_argsornamed_argsare now sent as SQLNULLinstead of the literal stringNone, which previously got stored as text in a text array and failed outright for other array types such asint[].
How to Test
Install or upgrade the collection from Ansible Galaxy and confirm the version is reported correctly.
# Install the latest version
ansible-galaxy collection install community.postgresql --upgrade
# Or pin the exact version
ansible-galaxy collection install community.postgresql:==5.1.3
# Verify the installed version
ansible-galaxy collection list community.postgresql
| Component | Previous version | New version |
|---|---|---|
| community.postgresql | 5.1.2 | 5.1.3 |
After upgrading, it is worth re-running playbooks that use postgresql_alter_system with real-type or list-type GUC parameters, as well as any that rely on postgresql_query/postgresql_script with array arguments containing None values, to confirm the previously reported false changes no longer appear.

Go deeper · Ebook by Luca Berton
Ansible by Examples: get the ebook on Leanpub (opens in a new tab)
Copy-and-paste Ansible playbooks that automate everyday system administration on Linux and Windows.
- Ebook
- Leanpub
- PDF & EPUB