Skip to content

Commit 64b3da6

Browse files
authored
Merge pull request #564 from conscribtor/pg16
- Support PostgreSQL 16 - Reset config files to pg default - Fix PGDG repo key
2 parents 5361c5f + b45df59 commit 64b3da6

15 files changed

+1974
-163
lines changed

README.md

+13-20
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,36 @@ An example how to include this role as a task:
5454

5555
#### Compatibility matrix
5656

57-
| Distribution / PostgreSQL | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
58-
| ------------------------- |:--:|:--:|:--:|:--:|:--:|:--:|:--:|
59-
| CentOS 7.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
60-
| CentOS 8.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
61-
| Debian 9.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
62-
| Debian 10.x | :interrobang: | :interrobang: | :grey_question: | :grey_question: |:grey_question: | :grey_question: | :grey_question: |
63-
| Debian 11.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
64-
| Ubuntu 16.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
65-
| Ubuntu 18.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
66-
| Ubuntu 20.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:grey_question: | :grey_question: | :grey_question: |
67-
| Ubuntu 22.04.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:white_check_mark: | :white_check_mark: | :grey_question: |
68-
| Rockylinux 9.x | :interrobang: | :interrobang: | :white_check_mark: | :white_check_mark: |:white_check_mark: | :white_check_mark: | :grey_question: |
69-
| Fedora 37 | :interrobang: | :interrobang: | :grey_question: | :grey_question: |:grey_question: | :grey_question: | :grey_question: |
57+
| Distribution / PostgreSQL | 11 | 12 | 13 | 14 | 15 | 16 |
58+
| ------------------------- | :--------: | :----------------: | :----------------: | :----------------: | :----------------: | :-------------: |
59+
| CentOS 8.x | :no_entry: | :white_check_mark: | :white_check_mark: | :grey_question: | :grey_question: | :grey_question: |
60+
| Debian 11.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
61+
| Debian 12.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: | :interrobang: |
62+
| Ubuntu 20.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :grey_question: | :grey_question: | :grey_question: |
63+
| Ubuntu 22.04.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
64+
| Rockylinux 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
65+
| Fedora 39 | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: | :interrobang: |
7066

7167
- :white_check_mark: - tested, works fine
72-
- :warning: - Not for production use
68+
- :warning: - not for production use
7369
- :grey_question: - will work in the future (help out if you can)
7470
- :interrobang: - maybe works, not tested
75-
- :no_entry: - Has reached End of Life (EOL)
76-
71+
- :no_entry: - has reached End of Life (EOL)
7772

7873

7974
#### Variables
8075

8176
```yaml
8277
# Basic settings
83-
postgresql_version: 15
78+
postgresql_version: 16
8479
postgresql_encoding: "UTF-8"
8580
postgresql_locale: "en_US.UTF-8"
8681
postgresql_ctype: "en_US.UTF-8"
8782
8883
postgresql_admin_user: "postgres"
8984
postgresql_default_auth_method: "peer"
9085
91-
postgresql_service_enabled: false # should the service be enabled, default is true
92-
93-
postgresql_cluster_name: "main"
86+
postgresql_cluster_name: main
9487
postgresql_cluster_reset: false
9588
9689
# List of databases to be created (optional)

defaults/main.yml

+52-34
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# file: postgresql/defaults/main.yml
22

33
# Basic settings
4-
postgresql_version: 15
4+
postgresql_version: 16
55
postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}" # Short version of the postgresql_version, used in some path and filenames
66
postgresql_encoding: "UTF-8"
77
postgresql_data_checksums: false
@@ -28,9 +28,8 @@ postgresql_default_auth_method_hosts: "{{ 'scram-sha-256' if postgresql_version
2828
postgresql_service_user: "{{ postgresql_admin_user }}"
2929
postgresql_service_user_pgsql_profile: false
3030
postgresql_service_group: "{{ postgresql_admin_user }}"
31-
postgresql_service_enabled: true
3231

33-
postgresql_cluster_name: "main"
32+
postgresql_cluster_name: "main" # postgres default is ''
3433
postgresql_cluster_reset: false
3534

3635
postgresql_database_owner: "{{ postgresql_admin_user }}"
@@ -48,6 +47,7 @@ postgresql_postgis_release_compatibility:
4847
13: "3.1"
4948
14: "3.2"
5049
15: "3.2"
50+
16: "3.4"
5151

5252
postgresql_ext_postgis_version: "{{ postgresql_postgis_release_compatibility.get(postgresql_version) }}"
5353
postgresql_ext_postgis_version_terse: "{{ postgresql_ext_postgis_version | replace('.','') }}"
@@ -126,6 +126,7 @@ postgresql_listen_addresses:
126126
postgresql_port: 5432
127127

128128
postgresql_max_connections: 100
129+
postgresql_reserved_connections: 0 # (>= 16)
129130
postgresql_superuser_reserved_connections: 3
130131

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

149150
# - Authentication -
150151

151-
postgresql_authentication_timeout: 60s
152+
postgresql_authentication_timeout: 60s # 1s-600s
152153
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)
154+
posgresql_scram_iterations: 4096 # (>= 16)
153155
postgresql_db_user_namespace: off
154156

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

160163
# - SSL -
161164

@@ -192,9 +195,9 @@ postgresql_max_prepared_transactions: 0 # zero disables the feature
192195

193196
# Caution: it is not advisable to set max_prepared_transactions nonzero unless
194197
# you actively intend to use prepared transactions.
195-
postgresql_work_mem: 1MB # min 64kB
196-
postgresql_hash_mem_multiplier: 1.0 # (>= 13)
197-
postgresql_maintenance_work_mem: 16MB # min 1MB
198+
postgresql_work_mem: 4MB # min 64kB
199+
postgresql_hash_mem_multiplier: "{{ 2.0 if postgresql_version is version_compare('15', '>=') else 1.0 }}" # (>= 13)
200+
postgresql_maintenance_work_mem: 64MB # min 1MB
198201
postgresql_replacement_sort_tuples: 150000 # (>= 9.6) limits use of replacement selection sort
199202
postgresql_autovacuum_work_mem: -1 # min 1MB, or -1 to use maintenance_work_mem
200203
postgresql_logical_decoding_work_mem: 64MB # (>= 13)
@@ -208,7 +211,10 @@ postgresql_dynamic_shared_memory_type: "posix" # the default is the first optio
208211
# windows
209212
# mmap
210213
# use none to disable dynamic shared memory
211-
postgresql_min_dynamic_shared_memory: 0MB # (>= 14) (change requires restart)
214+
postgresql_min_dynamic_shared_memory: 0MB # (>= 14) (change requires restart)
215+
postgres_vacuum_buffer_usage_limit: 256kB # (>= 16) size of vacuum and analyze buffer access strategy ring;
216+
# 0 to disable vacuum buffer access strategy;
217+
# range 128kB to 16GB
212218

213219
# - Disk -
214220

@@ -217,13 +223,13 @@ postgresql_temp_file_limit: -1
217223

218224
# - Kernel Resources -
219225

220-
postgresql_max_files_per_process: 1000 # min 25
226+
postgresql_max_files_per_process: 1000 # min 25, (>= 13) min 64
221227

222228
# - Cost-Based Vacuum Delay -
223229

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

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

285291
# - Prefetching during recovery -
@@ -338,15 +344,15 @@ postgresql_synchronous_standby_names: [] # '*' means 'all'
338344
postgresql_synchronous_standby_num_sync: "" # >= 9.6 (NOTE: If you use the ANY/ALL syntax in v10, then note the new variable below)
339345
postgresql_synchronous_standby_choose_sync: "FIRST" # >= 10
340346
# number of xacts by which cleanup is delayed
341-
postgresql_vacuum_defer_cleanup_age: 0
347+
postgresql_vacuum_defer_cleanup_age: 0 # (<= 15)
342348

343349
# - Standby Servers -
344350
# These settings are ignored on a primary server.
345351
postgresql_primary_conninfo: "" # (>= 12)
346352
postgresql_primary_slot_name: "" # (>= 12)
347-
postgresql_promote_trigger_file: "" # (>= 12)
353+
postgresql_promote_trigger_file: "" # (>= 12, <= 15)
348354
# "on" allows queries during recovery
349-
postgresql_hot_standby: off
355+
postgresql_hot_standby: on
350356
# max delay before canceling queries when reading WAL from archive
351357
postgresql_max_standby_archive_delay: 30s # -1 allows indefinite delay
352358
# max delay before canceling queries when reading streaming WAL;
@@ -367,6 +373,7 @@ postgresql_recovery_min_apply_delay: 0 # (>= 12)
367373
postgresql_max_logical_replication_workers: 4 # (>= 10) taken from max_worker_processes
368374
# (change requires restart)
369375
postgresql_max_sync_workers_per_subscription: 2 # (>= 10) taken from max_logical_replication_workers
376+
postgresql_max_parallel_apply_workers_per_subscription: 2 # (>= 16) taken from max_logical_replication_workers
370377

371378
#------------------------------------------------------------------------------
372379
# QUERY TUNING
@@ -389,6 +396,7 @@ postgresql_enable_parallel_hash: on # (>= 11)
389396
postgresql_enable_partition_pruning: on # (>= 11)
390397
postgresql_enable_partitionwise_join: off # (>= 11)
391398
postgresql_enable_partitionwise_aggregate: off # (>= 11)
399+
postgres_enable_presorted_aggregate: on # (>= 16)
392400
postgresql_enable_seqscan: on
393401
postgresql_enable_sort: on
394402
postgresql_enable_tidscan: on
@@ -404,11 +412,16 @@ postgresql_parallel_setup_cost: 1000.0 # same scale as above (>= 9.6)
404412
postgresql_min_parallel_relation_size: 8MB # (= 9.6) replaced by below two parameters in 10
405413
postgresql_min_parallel_table_scan_size: 8MB # (>= 10)
406414
postgresql_min_parallel_index_scan_size: 512kB # (>= 10)
407-
postgresql_effective_cache_size: 128MB
415+
postgresql_effective_cache_size: 4GB
408416

409-
postgresql_jit_above_cost: 100000 # perform JIT compilation if available
410-
postgresql_jit_inline_above_cost: 500000 # inline small functions if query is
411-
postgresql_jit_optimize_above_cost: 500000 # use expensive JIT optimizations if
417+
postgresql_jit_above_cost: 100000 # (>= 11) perform JIT compilation if available
418+
# and query more expensive than this;
419+
# -1 disables
420+
postgresql_jit_inline_above_cost: 500000 # (>= 11) inline small functions if query is
421+
# more expensive than this; -1 disables
422+
postgresql_jit_optimize_above_cost: 500000 # (>= 11) use expensive JIT optimizations if
423+
# query is more expensive than this;
424+
# -1 disables
412425

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

445458
# These are only used if logging_collector is on:
446459
# Directory where log files are written, can be absolute or relative to PGDATA
447-
postgresql_log_directory: "pg_log"
460+
postgresql_log_directory: "log"
448461
# Log file name pattern, can include strftime() escapes
449462
postgresql_log_filename: "postgresql-%Y-%m-%d_%H%M%S.log"
450463
postgresql_log_file_mode: "0600" # begin with 0 to use octal notation
@@ -513,8 +526,8 @@ postgresql_debug_print_parse: off
513526
postgresql_debug_print_rewritten: off
514527
postgresql_debug_print_plan: off
515528
postgresql_debug_pretty_print: on
516-
postgresql_log_autovacuum_min_duration: -1
517-
postgresql_log_checkpoints: off
529+
postgresql_log_autovacuum_min_duration: "{{ '10min' if postgresql_version is version_compare('15', '>=') else -1 }}"
530+
postgresql_log_checkpoints: "{{ 'on' if postgresql_version is version_compare('15', '>=') else 'off' }}"
518531
postgresql_log_connections: off
519532
postgresql_log_disconnections: off
520533
postgresql_log_duration: off
@@ -544,7 +557,7 @@ postgresql_log_hostname: off
544557
# processes
545558
# %% = '%'
546559
# e.g. '<%u%%%d> '
547-
postgresql_log_line_prefix: "%t "
560+
postgresql_log_line_prefix: "%m [%p] "
548561

549562
# log lock waits >= deadlock_timeout
550563
postgresql_log_lock_waits: off
@@ -575,7 +588,7 @@ postgresql_track_counts: on
575588
postgresql_track_io_timing: off # (>= 9.2)
576589
postgresql_track_wal_io_timing: off # (>= 14)
577590
postgresql_track_functions: "none" # none, pl, all
578-
postgresql_stats_fetch_consistency: cache # (>= 15)
591+
postgresql_stats_fetch_consistency: cache # (>= 15) cache, none, snapshot
579592
postgresql_stats_temp_directory: "pg_stat_tmp" # (<= 14)
580593

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

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

669683
# - Locale and Formatting -
670684

671685
postgresql_datestyle:
672686
- "iso"
673687
- "mdy"
674688
postgresql_intervalstyle: "postgres"
675-
postgresql_timezone: "UTC"
689+
postgresql_timezone: "UTC" # postgres default is GMT
676690

677691
# Select the set of available time zone abbreviations. Currently, there are:
678692
# Default
679693
# Australia
680694
# India
681695
# You can create your own file in `share/timezonesets/`.
682696
postgresql_timezone_abbreviations: "Default"
683-
684-
postgresql_extra_float_digits: 0 # min -15, max 3
697+
# min -15, max 3; (>= 12) any value >0 actually selects precise output mode
698+
postgresql_extra_float_digits: "{{ 1 if postgresql_version is version_compare('12', '>=') else 0 }}"
685699
postgresql_client_encoding: false # actually defaults to database encoding
686700
# 'sql_ascii', 'UTF8', ...
687701

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

712+
postgresql_icu_validation_level: "warning" # (>= 16) report ICU locale validation
713+
# errors at the given level
714+
698715
# default configuration for text search
699-
postgresql_default_text_search_config: "pg_catalog.english"
716+
postgresql_default_text_search_config: "pg_catalog.english" # default is 'pg_catalog.simple'
700717

701718
# - Shared Library Preloading -
702719

703720
postgresql_local_preload_libraries: []
704721
postgresql_session_preload_libraries: []
705722
postgresql_shared_preload_libraries: []
706-
postgresql_jit_provider: "llvmjit"
723+
postgresql_jit_provider: "llvmjit" # (>= 11)
707724

708725
# - Other Defaults -
709726

710727
postgresql_dynamic_library_path: "$libdir"
711-
postgresql_extension_destdir: "" # (>= 14)
728+
postgresql_extension_destdir: "" # prepend path when loading extensions
729+
# and shared objects (added by Debian)
712730

713-
postgresql_gin_fuzzy_search_limit: 0 # (<= 9.2)
731+
postgresql_gin_fuzzy_search_limit: 0
714732

715733
#------------------------------------------------------------------------------
716734
# LOCK MANAGEMENT
@@ -759,7 +777,7 @@ postgresql_exit_on_error: off
759777
# Reinitialize after backend crash?
760778
postgresql_restart_after_crash: on
761779
# Retry or panic on failure to fsync data?
762-
postgresql_data_sync_retry: off
780+
postgresql_data_sync_retry: off # (>= 11)
763781
postgresql_recovery_init_sync_method: fsync #(>= 14) fsync, syncfs (Linux 5.8+)
764782

765783
#------------------------------------------------------------------------------

molecule/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory is the home of the test playbooks:
77

88
## Molecule
99

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

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

@@ -96,4 +96,4 @@ MOLECULE_DISTRO=ubuntu2204 molecule destroy
9696

9797
## References
9898

99-
* https://github.com/search?q=user%3Ageerlingguy+docker-.*-ansible
99+
* https://github.com/search?q=user%3Ageerlingguy+docker-.*-ansible

tasks/configure.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
state: directory
4444
mode: 0700
4545
register: pglog_dir_exist
46-
when: postgresql_log_directory != "pg_log"
46+
when: postgresql_log_directory != "pg_log" or postgresql_log_directory != "log"
4747

4848
- name: PostgreSQL | Ensure the locale for lc_collate and lc_ctype is generated | Debian
4949
become: yes

0 commit comments

Comments
 (0)