Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ name: CI
push:
branches:
- development
- decrease-ansible-deprecation-5-0-0
schedule:
- cron: "0 4 * * 4"

Expand All @@ -26,7 +27,7 @@ jobs:
with:
path: 'postgresql'

- name: Set up Python 3.
- name: Set up Python.
uses: actions/setup-python@v5
with:
python-version: '3.x'
Expand All @@ -44,26 +45,37 @@ jobs:
strategy:
matrix:
include:
- distro: rockylinux8
- distro: rockylinux9
# - distro: rockylinux8
# - distro: rockylinux9
- distro: debian11
- distro: debian12
- distro: ubuntu2004
- distro: ubuntu2204
- distro: ubuntu2404

steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'postgresql'

- name: Set up Python 3.
- name: Set up Python.
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.12'

- name: Install test dependencies.
run: pip3 install ansible molecule molecule-plugins[docker] docker
- name: Upgrade pip & install deps
run: |
python -m pip install --upgrade pip wheel setuptools
# Meta-package Ansible 10/11 (include ansible-core ≥2.20)
pip install "ansible>10,<12"
# Testing tools
pip install "molecule" "molecule-plugins[docker]" docker ansible-compat

- name: Show versions
run: |
python -V
ansible --version
molecule --version

- name: Run Molecule tests.
run: molecule -v test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Icon
test
*.retry
ANXS-postgresql.code-workspace
tests/roles
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,26 @@ An example how to include this role as a task:

#### Compatibility matrix

| Distribution / PostgreSQL | 11 | 12 | 13 | 14 | 15 | 16 |
| ------------------------- | :--------: | :----------------: | :----------------: | :----------------: | :----------------: | :-------------: |
| Debian 11.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Debian 12.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Rockylinux 8.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Rockylinux 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Ubuntu 20.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Ubuntu 22.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Distribution / PostgreSQL | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| ------------------------- | :--------: | :--------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
| Debian 11.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Debian 12.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Rockylinux 8.x | :no_entry: | :no_entry: | :warning: | :warning: | :warning: | :warning: | :warning: |
| Rockylinux 9.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :warning: |
| Ubuntu 22.04.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Ubuntu 24.04.x | :no_entry: | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |


- :white_check_mark: - tested, works fine
- :warning: - not for production use
- :grey_question: - will work in the future (help out if you can)
- :interrobang: - maybe works, not tested
- :no_entry: - has reached End of Life (EOL)
- :white_check_mark: - works fine
- :warning: - has known issues
- :no_entry: - is unsupported and/or EOL


#### Variables

```yaml
# Basic settings
postgresql_version: 16
postgresql_version: 17
postgresql_encoding: "UTF-8"
postgresql_locale: "en_US.UTF-8"
postgresql_ctype: "en_US.UTF-8"
Expand Down
51 changes: 43 additions & 8 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# file: postgresql/defaults/main.yml

# Basic settings
postgresql_version: 16
postgresql_version: 17
postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}" # Short version of the postgresql_version, used in some path and filenames
postgresql_encoding: "UTF-8"
postgresql_data_checksums: false
Expand Down Expand Up @@ -48,6 +48,7 @@ postgresql_postgis_release_compatibility:
14: "3.2"
15: "3.2"
16: "3.4"
17: "3.5"

postgresql_ext_postgis_version: "{{ postgresql_postgis_release_compatibility.get(postgresql_version) }}"
postgresql_ext_postgis_version_terse: "{{ postgresql_ext_postgis_version | replace('.','') }}"
Expand Down Expand Up @@ -153,7 +154,7 @@ postgresql_client_connection_check_interval: 0 # (>= 14)
postgresql_authentication_timeout: 60s # 1s-600s
postgresql_password_encryption: "{{ 'scram-sha-256' if postgresql_version is version_compare('14', '>=') else 'md5' }}" # (>=14.0 set to scram-sha-256 for best security)
posgresql_scram_iterations: 4096 # (>= 16)
postgresql_db_user_namespace: off
postgresql_db_user_namespace: off # (<= 16)

# GSSAPI using Kerberos
postgresql_krb_server_keyfile: "{{ 'FILE:${sysconfdir}/krb5.keytab' if postgresql_version is version_compare('14', '>=') else '' }}"
Expand Down Expand Up @@ -213,15 +214,26 @@ postgresql_dynamic_shared_memory_type: "posix" # the default is the first optio
# mmap
# use none to disable dynamic shared memory
postgresql_min_dynamic_shared_memory: 0MB # (>= 14) (change requires restart)
postgres_vacuum_buffer_usage_limit: 256kB # (>= 16) size of vacuum and analyze buffer access strategy ring;
postgresql_vacuum_buffer_usage_limit: "{{ '256kB' if postgresql_version is version_compare('16', '=') else '2MB' }}" # (>= 16) size of vacuum and analyze buffer access strategy ring;
# 0 to disable vacuum buffer access strategy;
# range 128kB to 16GB

# SLRU buffers (change requires restart)
postgresql_commit_timestamp_buffers: 0 # (>= 17) memory for pg_commit_ts
postgresql_multixact_offset_buffers: 16 # (>= 17) memory for pg_multixact/offsets
postgresql_multixact_member_buffers: 32 # (>= 17) memory for pg_multixact/members
postgresql_notify_buffers: 16 # (>= 17) memory for pg_notify
postgresql_serializable_buffers: 32 # (>= 17) memory for pg_serial
postgresql_subtransaction_buffers: 0 # (>= 17) memory for pg_subtrans (0 = auto)
postgresql_transaction_buffers: 0 # (>= 17) memory for pg_xact (0 = auto)

# - Disk -

# limits per-process temp file space in kB, or -1 for no limit (>= 9.2)
postgresql_temp_file_limit: -1

postgresql_max_notify_queue_pages: 1048576 # (>= 17)

# - Kernel Resources -

postgresql_max_files_per_process: 1000 # min 25, (>= 13) min 64
Expand All @@ -246,12 +258,13 @@ postgresql_bgwriter_flush_after: 512kB # measured in pages, 0 disables
postgresql_backend_flush_after: 0 # (>= 9.6) 0 disables, default is 0
postgresql_effective_io_concurrency: 1 # 1-1000; 0 disables prefetching
postgresql_maintenance_io_concurrency: 10 # (>= 13)
postgresql_io_combine_limit: 128kB # (>= 17) usually 1-32 blocks (depends on OS)
postgresql_max_worker_processes: 8 # (change requires restart)
postgresql_max_parallel_workers_per_gather: 2 # (>= 9.6) taken from max_worker_processes
postgresql_max_parallel_maintenance_workers: 2 # (>= 11) taken from max_parallel_workers
postgresql_max_parallel_workers: 8 # (>= 10)
postgresql_parallel_leader_participation: on # (>= 11)
postgresql_old_snapshot_threshold: -1 # (>= 9.6) 1min-60d; -1 disables; 0 is immediate
postgresql_old_snapshot_threshold: -1 # (>= 9.6 and <= 16) 1min-60d; -1 disables; 0 is immediate
# (change requires restart)

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -321,6 +334,10 @@ postgresql_recovery_target_inclusive: "" # (>= 12)
postgresql_recovery_target_timeline: "latest" # (>= 12)
postgresql_recovery_target_action: "pause" # (>= 12)

# - WAL Summarization -
postgresql_summarize_wal: off # (>= 17) run WAL summarizer process?
postgresql_wal_summary_keep_time: 10d # (>= 17) when to remove old summary files, 0 = never

#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------
Expand All @@ -342,6 +359,7 @@ postgresql_track_commit_timestamp: off # (>= 9.5)
# standby servers that provide sync rep.
# number of sync standbys (>= 9.6) and comma-separated list of application_name from standby(s)
postgresql_synchronous_standby_names: [] # '*' means 'all'
postgresql_synchronized_standby_slots: "" # (>= 17) streaming replication standby server slot
postgresql_synchronous_standby_num_sync: "" # >= 9.6 (NOTE: If you use the ANY/ALL syntax in v10, then note the new variable below)
postgresql_synchronous_standby_choose_sync: "FIRST" # >= 10
# number of xacts by which cleanup is delayed
Expand All @@ -368,6 +386,7 @@ postgresql_wal_receiver_timeout: 60s
# time to wait before retrying to retrieve WAL after a failed attempt
postgresql_wal_retrieve_retry_interval: 5s # (>= 9.5)
postgresql_recovery_min_apply_delay: 0 # (>= 12)
postgresql_sync_replication_slots: off # (>= 17) enables slot synchronization on the physical standby from the primary

# - Subscribers - (>= 10)
# These settings are ignored on a publisher.
Expand Down Expand Up @@ -401,6 +420,7 @@ postgres_enable_presorted_aggregate: on # (>= 16)
postgresql_enable_seqscan: on
postgresql_enable_sort: on
postgresql_enable_tidscan: on
postgresql_enable_group_by_reordering: on

# - Planner Cost Constants -
postgresql_seq_page_cost: 1.0 # measured on an arbitrary scale
Expand Down Expand Up @@ -665,6 +685,7 @@ postgresql_default_transaction_deferrable: off
postgresql_session_replication_role: "origin"

postgresql_statement_timeout: 0 # in milliseconds, 0 is disabled
postgresql_transaction_timeout: 0 # (>= 17) in milliseconds, 0 is disabled
postgresql_lock_timeout: 0 # in milliseconds, 0 is disabled (>= 9.3)
postgresql_idle_in_transaction_session_timeout: 0 # in milliseconds, 0 is disabled (>= 9.6)
postgresql_idle_session_timeout: 0 # in milliseconds, 0 is disabled (>= 14)
Expand All @@ -680,6 +701,7 @@ postgresql_xmlbinary: "base64"
postgresql_xmloption: "content"
postgresql_gin_pending_list_limit: 4MB # (>= 9.5)
postgresql_createrole_self_grant: '' # (>= 16) 'set', 'inherit' or 'set, inherit'
postgresql_event_triggers: on # (>= 17)

# - Locale and Formatting -

Expand Down Expand Up @@ -768,6 +790,7 @@ postgresql_sql_inheritance: on # (<= 9.6)
# - Other Platforms and Clients -

postgresql_transform_null_equals: off
postgresql_allow_alter_system: on # (>= 17)

#------------------------------------------------------------------------------
# ERROR HANDLING
Expand Down Expand Up @@ -815,8 +838,22 @@ postgresql_install_repository: true
# APT settings
postgresql_apt_key_id: "ACCC4CF8"
postgresql_apt_key_url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
postgresql_apt_repository: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main {{ postgresql_version }}"
# postgresql_apt_keyring: "/usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg"

# repsoitory base
postgresql_apt_repo_base: "https://apt.postgresql.org/pub/repos/apt"
postgresql_apt_repo_components: "main"

# (codename + -pgdg)
postgresql_apt_suite: "{{ ansible_facts['distribution_release'] | default('') }}-pgdg"

# Ligne de dépôt finale (utilise les variables ci-dessus)
postgresql_apt_repository: >-
deb [signed-by={{ postgresql_apt_keyring }}]
{{ postgresql_apt_repo_base }} {{ postgresql_apt_suite }} {{ postgresql_apt_repo_components }}

# Pin-Priority of PGDG repository
postgresql_apt_pin_enabled: true
postgresql_apt_pin_priority: 500

# YUM repository locations
Expand All @@ -831,8 +868,6 @@ postgresql_yum_repository_gpgkey: "{{ postgresql_pgdg_repository_url }}/keys/PGD
postgresql_dnf_repository_baseurl: "{{ postgresql_yum_repository_url }}/{{ postgresql_version }}/fedora/fedora-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}"
postgresql_dnf_repository_gpgkey: "{{ postgresql_yum_repository_gpgkey }}"

postgresql_apt_py3_dependencies: ["python3-psycopg2", "locales"]
postgresql_apt_py2_dependencies: ["python-psycopg2", "python-pycurl", "locales"]
postgresql_apt_dependencies: "{{ postgresql_apt_py3_dependencies if 'python3' in ansible_python_interpreter|default('') else postgresql_apt_py2_dependencies }}"
postgresql_apt_dependencies: ["python3-psycopg2", "locales"]

postgresql_hide_passwords: false
8 changes: 6 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# file: postgresql/handlers/main.yml

- name: restart postgresql
shell: "pg_ctlcluster {{ postgresql_version }} {{ postgresql_cluster_name }} restart"
- name: restart postgresql
shell: "pg_ctlcluster {{ postgresql_version }} {{ postgresql_cluster_name }} restart"

- name: Reload systemd daemon
ansible.builtin.command: systemctl daemon-reload
become: true
58 changes: 29 additions & 29 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# file: postgresql/meta/main.yml

galaxy_info:
Expand All @@ -6,42 +7,41 @@ galaxy_info:
namespace: anxs
role_name: postgresql
description: "Install and configure PostgreSQL, dependencies, extensions, databases and users."
min_ansible_version: 2.4.0
min_ansible_version: 2.12.0
license: MIT

platforms:
- name: Debian
versions:
- stretch
- buster
- name: Debian
versions:
- bullseye
- bookworm

- name: EL
versions:
- 7
- 8
- name: EL
versions:
- "8"
- "9"

- name: Ubuntu
versions:
- bionic
- focal
- xenial
- jammy
- name: Ubuntu
versions:
- focal
- jammy
- noble

- name: Fedora
versions:
- 37
- name: Fedora
versions:
- "40"

galaxy_tags:
- postgresql
- postgres
- database
- database:sql
- sql
- postgis
- debian
- centos
- redhat
- fedora
- ubuntu
- postgresql
- postgres
- database
- database:sql
- sql
- postgis
- debian
- rockylinux
- redhat
- fedora
- ubuntu

dependencies: []
Loading