### Install Pre-commit (Debian/Ubuntu) Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Installs the pre-commit tool on Debian-based systems using the apt package manager. ```console sudo apt install pre-commit ``` -------------------------------- ### Install Community PostgreSQL Collection Source: https://github.com/ansible-collections/community.postgresql/blob/main/README.md Demonstrates how to install the community.postgresql Ansible collection using Ansible Galaxy. Includes installation via command line and using a requirements.yml file. Also shows how to upgrade and install specific versions. ```bash ansible-galaxy collection install community.postgresql ``` ```yaml --- collections: - name: community.postgresql ``` ```bash ansible-galaxy collection install community.postgresql --upgrade ``` ```bash ansible-galaxy collection install community.postgresql:==X.Y.Z ``` -------------------------------- ### Install Tox and Dependencies Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Sets up a Python virtual environment and installs tox for managing project dependencies and tasks. ```console python3 -m venv .venv source .venv pip install tox ``` -------------------------------- ### Ansible PostgreSQL Collection Contribution Guidelines Source: https://github.com/ansible-collections/community.postgresql/blob/main/README.md This snippet outlines the key resources and guidelines for contributing to the community.postgresql Ansible collection. It references the collection's CONTRIBUTING.md file, the Ansible Community Guide, the Ansible Development Guide, and the Ansible Collection Development Guide. ```ansible CONTRIBUTING.md: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Ansible Community Guide: https://docs.ansible.com/ansible/latest/community/index.html Ansible Development Guide: https://docs.ansible.com/ansible/devel/dev_guide/index.html Ansible Collection Development Guide: https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#contributing-to-collections ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Installs pre-commit hooks to automatically check code quality before each commit. This includes tools like autoflake, flake8, isort, and codespell. ```console $ pre-commit install ``` -------------------------------- ### Ansible PostgreSQL Module Usage Example Source: https://github.com/ansible-collections/community.postgresql/blob/main/tests/sanity/ignore-2.13.txt Example of how to use the community.postgresql.postgresql_db module in an Ansible playbook to create a database. ```yaml - name: Create a PostgreSQL database community.postgresql.postgresql_db: name: my_new_database state: present login_user: postgres login_password: mysecretpassword encoding: UTF8 owner: db_owner become: yes become_user: postgres ``` -------------------------------- ### PostgreSQL Query Module: SHOW Command Handling Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst The `postgresql_query` module now correctly reports 'not changed' for queries starting with 'SHOW'. This ensures accurate state reporting for SHOW commands. ```ansible - name: Execute a SHOW command community.postgresql.postgresql_query: query: "SHOW server_version;" register: show_result - name: Debug SHOW command result debug: var: show_result ``` -------------------------------- ### Run Linting with Tox Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Executes the linting process using tox. This command verifies code quality against defined standards. ```console $ tox -e lint ``` -------------------------------- ### Run All Pre-commit Checks Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Manually triggers all configured pre-commit hooks on all files in the repository to ensure code quality. ```console $ pre-commit run --all-file ``` -------------------------------- ### Deprecated 'keep_comments_at_rules' in postgresql_pg_hba Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst The 'keep_comments_at_rules' parameter in the 'postgresql_pg_hba' module has been deprecated starting from v3.11.0 and will be removed in version 5.0.0. It no longer performs any function as comments are kept by default. ```APIDOC Module: postgresql_pg_hba Deprecated Parameter: keep_comments_at_rules Description: This parameter has been deprecated and will be removed in 5.0.0. It no longer has any effect as comments are kept by default. Reference: https://github.com/ansible-collections/community.postgresql/pull/778 ``` -------------------------------- ### Run Integration Tests Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Runs integration tests for a specific module. It requires the module name and optionally a Docker container image for testing. The `-v` flag increases verbosity. ```console $ ansible-test integration --docker -v ``` -------------------------------- ### postgresql_info - Improved server version checking Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst Uses a more robust server check that is compatible with beta, release candidate, and actual release versions. ```ansible postgresql_info: # ... parameters ... ``` -------------------------------- ### Run Unit Tests Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Executes unit tests for specified test files. The `--docker` flag is used to run tests within a Docker container. ```console $ ansible-test units tests/unit/plugins/unit_test_file.py --docker ``` -------------------------------- ### postgresql_info: Add 'patch', 'full', 'raw' version values Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst The postgresql_info module's 'version' return value now includes 'patch', 'full', and 'raw' options for more detailed server version information. ```ansible postgresql_info: query: version register: pg_version_info - debug: var: pg_version_info.version.full ``` -------------------------------- ### postgresql_ext: Fix extension version handling with zero value Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst Addressed a bug in the postgresql_ext module where extension version handling failed when the version value was zero. ```ansible postgresql_ext: # Module now correctly handles zero version values for extensions ``` -------------------------------- ### Ansible Module Documentation Fields Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Details on required fields for new Ansible modules and arguments, including version tracking for changelog generation and SemVer compliance. ```ansible DOCUMENTATION: version_added: 'x.y.z' arguments: version_added: 'x.y.z' ``` -------------------------------- ### Shippable Timing Utility Source: https://github.com/ansible-collections/community.postgresql/blob/main/tests/sanity/ignore-2.16.txt This script, located in tests/utils/shippable/timing.py, is likely used for timing operations within the Shippable CI/CD environment for the PostgreSQL collection. ```python #!/usr/bin/env python # Content of tests/utils/shippable/timing.py ``` -------------------------------- ### PostgreSQL Extension Module: Idempotence and Return Values Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst The `postgresql_ext` module has received several updates to improve idempotence, especially in check mode and when managing extensions with specific versions. It now also returns previous version and version information. ```ansible - name: Ensure extension is present with idempotence in check mode community.postgresql.postgresql_ext: name: "pg_trgm" state: present check_mode: yes - name: Manage extension with version and get return values community.postgresql.postgresql_ext: name: "hstore" state: present version: "1.5" register: ext_result - name: Display extension version information debug: var: ext_result ``` -------------------------------- ### CI Testing Matrix Source: https://github.com/ansible-collections/community.postgresql/blob/main/README.md The CI process includes testing with various Docker images, specifying Psycopg and PostgreSQL versions. ```ansible CI Testing Matrix: | Docker image | Psycopg version | PostgreSQL version | |--------------|-----------------|--------------------| | RHEL 8 | 2.7.5 | 10 | | Fedora 39 | 2.9.6 | 15 | | Ubuntu 22.04 | 3.1.9 | 16 | | Fedora 40/41 | 2.9.9 | 16 | | RHEL 10 | 2.9.9 | 16 | | Ubuntu 24.04 | 3.2.2 | 17 | ``` -------------------------------- ### postgresql_db: Support 'directory' format for dump/restore Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst The postgresql_db module now supports the 'directory' format for the 'state' options 'dump' and 'restore', allowing backups and restores to be managed as directories. ```ansible postgresql_db: name: mydatabase state: dump format: directory target: /path/to/backup/directory ``` -------------------------------- ### PostgreSQL Query Module Enhancements and Fixes Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst Details bug fixes and new options for the postgresql_query module, including handling of datetime.timedelta, decimal types, and the introduction of the 'as_single_query' option to manage semicolon-separated queries. ```ansible postgresql_query: # Bugfix: Add a warning to set 'as_single_query' option explicitly. # Bugfix: Fix datetime.timedelta type handling. # Bugfix: Fix decimal handling. # Minor Change: Add 'as_single_query' option to execute script content as a single query. # Minor Change: Add 'query_list' and 'query_all_results' return values. ``` -------------------------------- ### postgresql_info: Add 'raw' return value for extension version Source: https://github.com/ansible-collections/community.postgresql/blob/main/CHANGELOG.rst The postgresql_info module now provides a 'raw' return value for the extension version, offering the unparsed version string. ```ansible postgresql_info: query: extensions name: pg_trgm register: pg_ext_info - debug: var: pg_ext_info.extensions['pg_trgm'].version.raw ``` -------------------------------- ### Run Sanity Tests Source: https://github.com/ansible-collections/community.postgresql/blob/main/CONTRIBUTING.md Executes sanity tests on specified files or directories. The `--docker` flag enables running tests within a Docker container, and `-v` increases verbosity. ```console $ ansible-test sanity path/to/changed_file.py --docker -v ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.