Skip to content

Commit

Permalink
Merge pull request #564 from conscribtor/pg16
Browse files Browse the repository at this point in the history
- Support PostgreSQL 16
- Reset config files to pg default
- Fix PGDG repo key
  • Loading branch information
MrMegaNova authored Jan 19, 2024
2 parents 5361c5f + b45df59 commit 64b3da6
Show file tree
Hide file tree
Showing 15 changed files with 1,974 additions and 163 deletions.
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,36 @@ An example how to include this role as a task:

#### Compatibility matrix

| Distribution / PostgreSQL | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| ------------------------- |:--:|:--:|:--:|:--:|:--:|:--:|:--:|
| CentOS 7.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
| CentOS 8.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
| Debian 9.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
| Debian 10.x | :interrobang: | :interrobang: | :grey_question: | :grey_question: |:grey_question: | :grey_question: | :grey_question: |
| Debian 11.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
| Ubuntu 16.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
| Ubuntu 18.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
| Ubuntu 20.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
| Ubuntu 22.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:white_check_mark: | :white_check_mark: | :grey_question: |
| Rockylinux 9.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:white_check_mark: | :white_check_mark: | :grey_question: |
| Fedora 37 | :interrobang: | :interrobang: | :grey_question: | :grey_question: |:grey_question: | :grey_question: | :grey_question: |
| Distribution / PostgreSQL | 11 | 12 | 13 | 14 | 15 | 16 |
| ------------------------- | :--------: | :----------------: | :----------------: | :----------------: | :----------------: | :-------------: |
| CentOS 8.x | :no_entry: | :white_check_mark: | :white_check_mark: | :grey_question: | :grey_question: | :grey_question: |
| Debian 11.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
| Debian 12.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: | :interrobang: |
| Ubuntu 20.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :grey_question: | :grey_question: | :grey_question: |
| Ubuntu 22.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
| Rockylinux 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
| Fedora 39 | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: | :interrobang: |

- :white_check_mark: - tested, works fine
- :warning: - Not for production use
- :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)

- :no_entry: - has reached End of Life (EOL)


#### Variables

```yaml
# Basic settings
postgresql_version: 15
postgresql_version: 16
postgresql_encoding: "UTF-8"
postgresql_locale: "en_US.UTF-8"
postgresql_ctype: "en_US.UTF-8"
postgresql_admin_user: "postgres"
postgresql_default_auth_method: "peer"
postgresql_service_enabled: false # should the service be enabled, default is true
postgresql_cluster_name: "main"
postgresql_cluster_name: main
postgresql_cluster_reset: false
# List of databases to be created (optional)
Expand Down
86 changes: 52 additions & 34 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: 15
postgresql_version: 16
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 All @@ -28,9 +28,8 @@ postgresql_default_auth_method_hosts: "{{ 'scram-sha-256' if postgresql_version
postgresql_service_user: "{{ postgresql_admin_user }}"
postgresql_service_user_pgsql_profile: false
postgresql_service_group: "{{ postgresql_admin_user }}"
postgresql_service_enabled: true

postgresql_cluster_name: "main"
postgresql_cluster_name: "main" # postgres default is ''
postgresql_cluster_reset: false

postgresql_database_owner: "{{ postgresql_admin_user }}"
Expand All @@ -48,6 +47,7 @@ postgresql_postgis_release_compatibility:
13: "3.1"
14: "3.2"
15: "3.2"
16: "3.4"

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 @@ -126,6 +126,7 @@ postgresql_listen_addresses:
postgresql_port: 5432

postgresql_max_connections: 100
postgresql_reserved_connections: 0 # (>= 16)
postgresql_superuser_reserved_connections: 3

postgresql_unix_socket_directory: "" # (<= 9.2)
Expand All @@ -148,14 +149,16 @@ postgresql_client_connection_check_interval: 0 # (>= 14)

# - Authentication -

postgresql_authentication_timeout: 60s
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

# GSSAPI using Kerberos
postgresql_krb_server_keyfile: ""
postgresql_krb_server_keyfile: "{{ 'FILE:${sysconfdir}/krb5.keytab' if postgresql_version is version_compare('14', '>=') else '' }}"
postgresql_krb_srvname: "postgres" # (<= 9.3)
postgresql_krb_caseins_users: off
postgresql_gss_accept_delegation: off # (>= 16)

# - SSL -

Expand Down Expand Up @@ -192,9 +195,9 @@ postgresql_max_prepared_transactions: 0 # zero disables the feature

# Caution: it is not advisable to set max_prepared_transactions nonzero unless
# you actively intend to use prepared transactions.
postgresql_work_mem: 1MB # min 64kB
postgresql_hash_mem_multiplier: 1.0 # (>= 13)
postgresql_maintenance_work_mem: 16MB # min 1MB
postgresql_work_mem: 4MB # min 64kB
postgresql_hash_mem_multiplier: "{{ 2.0 if postgresql_version is version_compare('15', '>=') else 1.0 }}" # (>= 13)
postgresql_maintenance_work_mem: 64MB # min 1MB
postgresql_replacement_sort_tuples: 150000 # (>= 9.6) limits use of replacement selection sort
postgresql_autovacuum_work_mem: -1 # min 1MB, or -1 to use maintenance_work_mem
postgresql_logical_decoding_work_mem: 64MB # (>= 13)
Expand All @@ -208,7 +211,10 @@ postgresql_dynamic_shared_memory_type: "posix" # the default is the first optio
# windows
# mmap
# use none to disable dynamic shared memory
postgresql_min_dynamic_shared_memory: 0MB # (>= 14) (change requires restart)
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;
# 0 to disable vacuum buffer access strategy;
# range 128kB to 16GB

# - Disk -

Expand All @@ -217,13 +223,13 @@ postgresql_temp_file_limit: -1

# - Kernel Resources -

postgresql_max_files_per_process: 1000 # min 25
postgresql_max_files_per_process: 1000 # min 25, (>= 13) min 64

# - Cost-Based Vacuum Delay -

postgresql_vacuum_cost_delay: 0 # 0-100 milliseconds
postgresql_vacuum_cost_page_hit: 1 # 0-10000 credits
postgresql_vacuum_cost_page_miss: 10 # 0-10000 credits
postgresql_vacuum_cost_page_miss: "{{ 2 if postgresql_version is version_compare('14', '>=') else 10 }}" # 0-10000 credits
postgresql_vacuum_cost_page_dirty: 20 # 0-10000 credits
postgresql_vacuum_cost_limit: 200 # 1-10000 credits

Expand Down Expand Up @@ -279,7 +285,7 @@ postgresql_min_wal_size: 80MB # (>= 9.5)
postgresql_checkpoint_flush_after: 0 # (>= 9.6) 0 disables,
# default is 256kB on linux, 0 otherwise
postgresql_checkpoint_timeout: 5min # range 30s-1d
postgresql_checkpoint_completion_target: 0.5 # checkpoint target duration, 0.0 - 1.0
postgresql_checkpoint_completion_target: "{{ 0.9 if postgresql_version is version_compare('14', '>=') else 0.5 }}" # checkpoint target duration, 0.0 - 1.0
postgresql_checkpoint_warning: 30s # 0 disables

# - Prefetching during recovery -
Expand Down Expand Up @@ -338,15 +344,15 @@ postgresql_synchronous_standby_names: [] # '*' means 'all'
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
postgresql_vacuum_defer_cleanup_age: 0
postgresql_vacuum_defer_cleanup_age: 0 # (<= 15)

# - Standby Servers -
# These settings are ignored on a primary server.
postgresql_primary_conninfo: "" # (>= 12)
postgresql_primary_slot_name: "" # (>= 12)
postgresql_promote_trigger_file: "" # (>= 12)
postgresql_promote_trigger_file: "" # (>= 12, <= 15)
# "on" allows queries during recovery
postgresql_hot_standby: off
postgresql_hot_standby: on
# max delay before canceling queries when reading WAL from archive
postgresql_max_standby_archive_delay: 30s # -1 allows indefinite delay
# max delay before canceling queries when reading streaming WAL;
Expand All @@ -367,6 +373,7 @@ postgresql_recovery_min_apply_delay: 0 # (>= 12)
postgresql_max_logical_replication_workers: 4 # (>= 10) taken from max_worker_processes
# (change requires restart)
postgresql_max_sync_workers_per_subscription: 2 # (>= 10) taken from max_logical_replication_workers
postgresql_max_parallel_apply_workers_per_subscription: 2 # (>= 16) taken from max_logical_replication_workers

#------------------------------------------------------------------------------
# QUERY TUNING
Expand All @@ -389,6 +396,7 @@ postgresql_enable_parallel_hash: on # (>= 11)
postgresql_enable_partition_pruning: on # (>= 11)
postgresql_enable_partitionwise_join: off # (>= 11)
postgresql_enable_partitionwise_aggregate: off # (>= 11)
postgres_enable_presorted_aggregate: on # (>= 16)
postgresql_enable_seqscan: on
postgresql_enable_sort: on
postgresql_enable_tidscan: on
Expand All @@ -404,11 +412,16 @@ postgresql_parallel_setup_cost: 1000.0 # same scale as above (>= 9.6)
postgresql_min_parallel_relation_size: 8MB # (= 9.6) replaced by below two parameters in 10
postgresql_min_parallel_table_scan_size: 8MB # (>= 10)
postgresql_min_parallel_index_scan_size: 512kB # (>= 10)
postgresql_effective_cache_size: 128MB
postgresql_effective_cache_size: 4GB

postgresql_jit_above_cost: 100000 # perform JIT compilation if available
postgresql_jit_inline_above_cost: 500000 # inline small functions if query is
postgresql_jit_optimize_above_cost: 500000 # use expensive JIT optimizations if
postgresql_jit_above_cost: 100000 # (>= 11) perform JIT compilation if available
# and query more expensive than this;
# -1 disables
postgresql_jit_inline_above_cost: 500000 # (>= 11) inline small functions if query is
# more expensive than this; -1 disables
postgresql_jit_optimize_above_cost: 500000 # (>= 11) use expensive JIT optimizations if
# query is more expensive than this;
# -1 disables

# - Genetic Query Optimizer -
postgresql_geqo: on
Expand All @@ -424,7 +437,7 @@ postgresql_default_statistics_target: 100 # range 1-10000
postgresql_constraint_exclusion: "partition" # on, off, or partition
postgresql_cursor_tuple_fraction: 0.1 # range 0.0-1.0
postgresql_from_collapse_limit: 8
postgresql_jit: on # (>= 11: off, 12: on)
postgresql_jit: on # (>= 11: off, >= 12: on)
postgresql_join_collapse_limit: 8 # 1 disables collapsing of explicit
postgresql_force_parallel_mode: off # on, off, regress (>= 9.6 <= 13)
postgresql_plan_cache_mode: "auto" # (>= 12)
Expand All @@ -444,7 +457,7 @@ postgresql_logging_collector: off

# These are only used if logging_collector is on:
# Directory where log files are written, can be absolute or relative to PGDATA
postgresql_log_directory: "pg_log"
postgresql_log_directory: "log"
# Log file name pattern, can include strftime() escapes
postgresql_log_filename: "postgresql-%Y-%m-%d_%H%M%S.log"
postgresql_log_file_mode: "0600" # begin with 0 to use octal notation
Expand Down Expand Up @@ -513,8 +526,8 @@ postgresql_debug_print_parse: off
postgresql_debug_print_rewritten: off
postgresql_debug_print_plan: off
postgresql_debug_pretty_print: on
postgresql_log_autovacuum_min_duration: -1
postgresql_log_checkpoints: off
postgresql_log_autovacuum_min_duration: "{{ '10min' if postgresql_version is version_compare('15', '>=') else -1 }}"
postgresql_log_checkpoints: "{{ 'on' if postgresql_version is version_compare('15', '>=') else 'off' }}"
postgresql_log_connections: off
postgresql_log_disconnections: off
postgresql_log_duration: off
Expand Down Expand Up @@ -544,7 +557,7 @@ postgresql_log_hostname: off
# processes
# %% = '%'
# e.g. '<%u%%%d> '
postgresql_log_line_prefix: "%t "
postgresql_log_line_prefix: "%m [%p] "

# log lock waits >= deadlock_timeout
postgresql_log_lock_waits: off
Expand Down Expand Up @@ -575,7 +588,7 @@ postgresql_track_counts: on
postgresql_track_io_timing: off # (>= 9.2)
postgresql_track_wal_io_timing: off # (>= 14)
postgresql_track_functions: "none" # none, pl, all
postgresql_stats_fetch_consistency: cache # (>= 15)
postgresql_stats_fetch_consistency: cache # (>= 15) cache, none, snapshot
postgresql_stats_temp_directory: "pg_stat_tmp" # (<= 14)

# - Monitoring -
Expand Down Expand Up @@ -641,7 +654,7 @@ postgresql_row_security: on # (>= 9.5)
postgresql_default_tablespace: "" # a tablespace name, "" uses the default
postgresql_default_toast_compression: "pglz" # (>= 14) 'pglz' or 'lz4'
postgresql_temp_tablespaces: [] # a list of tablespace names
postgresql_default_table_access_method: "heap"
postgresql_default_table_access_method: "heap" # (>= 12)
postgresql_tablespaces_dirs: [] # a list of directories for tablespaces to be created

postgresql_check_function_bodies: on
Expand All @@ -665,23 +678,24 @@ postgresql_bytea_output: "hex" # hex, escape
postgresql_xmlbinary: "base64"
postgresql_xmloption: "content"
postgresql_gin_pending_list_limit: 4MB # (>= 9.5)
postgresql_createrole_self_grant: '' # (>= 16) 'set', 'inherit' or 'set, inherit'

# - Locale and Formatting -

postgresql_datestyle:
- "iso"
- "mdy"
postgresql_intervalstyle: "postgres"
postgresql_timezone: "UTC"
postgresql_timezone: "UTC" # postgres default is GMT

# Select the set of available time zone abbreviations. Currently, there are:
# Default
# Australia
# India
# You can create your own file in `share/timezonesets/`.
postgresql_timezone_abbreviations: "Default"

postgresql_extra_float_digits: 0 # min -15, max 3
# min -15, max 3; (>= 12) any value >0 actually selects precise output mode
postgresql_extra_float_digits: "{{ 1 if postgresql_version is version_compare('12', '>=') else 0 }}"
postgresql_client_encoding: false # actually defaults to database encoding
# 'sql_ascii', 'UTF8', ...

Expand All @@ -695,22 +709,26 @@ postgresql_lc_numeric: "{{ postgresql_locale }}"
# locale for time formatting
postgresql_lc_time: "{{ postgresql_locale }}"

postgresql_icu_validation_level: "warning" # (>= 16) report ICU locale validation
# errors at the given level

# default configuration for text search
postgresql_default_text_search_config: "pg_catalog.english"
postgresql_default_text_search_config: "pg_catalog.english" # default is 'pg_catalog.simple'

# - Shared Library Preloading -

postgresql_local_preload_libraries: []
postgresql_session_preload_libraries: []
postgresql_shared_preload_libraries: []
postgresql_jit_provider: "llvmjit"
postgresql_jit_provider: "llvmjit" # (>= 11)

# - Other Defaults -

postgresql_dynamic_library_path: "$libdir"
postgresql_extension_destdir: "" # (>= 14)
postgresql_extension_destdir: "" # prepend path when loading extensions
# and shared objects (added by Debian)

postgresql_gin_fuzzy_search_limit: 0 # (<= 9.2)
postgresql_gin_fuzzy_search_limit: 0

#------------------------------------------------------------------------------
# LOCK MANAGEMENT
Expand Down Expand Up @@ -759,7 +777,7 @@ postgresql_exit_on_error: off
# Reinitialize after backend crash?
postgresql_restart_after_crash: on
# Retry or panic on failure to fsync data?
postgresql_data_sync_retry: off
postgresql_data_sync_retry: off # (>= 11)
postgresql_recovery_init_sync_method: fsync #(>= 14) fsync, syncfs (Linux 5.8+)

#------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions molecule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This directory is the home of the test playbooks:

## Molecule

The default tested version is postgresql 12, 13, 14, 15 and 16 on Debian 11. Linting is disabled for the tests.
The default tested versions are postgresql 12, 13, 14, 15 and 16 on Debian 11. Linting is disabled for the tests.

The default distribution is ubuntu2204. You can override th with setting the environment variable MOLECULE_DISTRO to one of:

Expand Down Expand Up @@ -96,4 +96,4 @@ MOLECULE_DISTRO=ubuntu2204 molecule destroy

## References

* https://github.com/search?q=user%3Ageerlingguy+docker-.*-ansible
* https://github.com/search?q=user%3Ageerlingguy+docker-.*-ansible
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
state: directory
mode: 0700
register: pglog_dir_exist
when: postgresql_log_directory != "pg_log"
when: postgresql_log_directory != "pg_log" or postgresql_log_directory != "log"

- name: PostgreSQL | Ensure the locale for lc_collate and lc_ctype is generated | Debian
become: yes
Expand Down
Loading

0 comments on commit 64b3da6

Please sign in to comment.