Skip to content

Commit 63e23ee

Browse files
WolfgangPechoGreg Clough
authored andcommitted
Extended and adapted to install PostgreSQL 10 for CentOS and Ubuntu (ANXS#267)
* Extended and adapted to install PostgreSQL 10 for CentOS and Ubuntu Tested with ansible 2.4.1 for Ubuntu 16.04 and CentOS-7.4 - replaced deprecated 'include:' by 'include_tasks:' for ansible 2.4.1 - added config and config template for postgresql 10 - adapted defaults.yml - adapted templates/etc_systemd_system_postgresql.service.d_custom.conf.j2 for PostgreSQL 10 the template outputs the wrong line: ExecStartPre=/usr/pgsql-10/bin/postgresql10-check-db-dir the correct one must include an additional '-': ExecStartPre=/usr/pgsql-10/bin/postgresql-10-check-db-dir * Removed tabs from defaults/main.yml. * Adapted .travis.yml and yml files to run tests successfully for all given ansible versions. - added a test for ansible 2.4.2.0/posgresql 10. - replaced newer 'include_task' by 'include' again so that the role can be used with older ansible versions. NOTE: 'include' is deprecated and will be removed in ansible 2.8. - commeted out docker based tests because they do not run successfully and I do not know docker ;-) * Bug fix. Removed remains for my local teste in test/playbook.yml. * Bug fix and refinement for postgresql.conf-10.* . - added max_parallel_workers to postgresql.conf-10.j2 (forgotten/deleted in previous version) - hard coded value for wal_retrieve_retry_interval in postgresql.conf-10.j2 replaced by ansible variable Changes to be committed: modified: Vagrantfile modified: defaults/main.yml modified: templates/postgresql.conf-10.j2 modified: vagrant-inventory * Added suggestions from gclough. Changes to be committed: modified: Vagrantfile modified: defaults/main.yml modified: templates/HOWTO.postgresql.conf modified: templates/etc_systemd_system_postgresql.service.d_custom.conf.j2 modified: tests/playbook.yml modified: tests/vars.yml modified: vagrant-inventory * Replaced vagrant setup by project's master branch. * Updated tests/docker/group_vars/all.yml to include version 10. * Uncommented 'no_log: true' in users.yml. * Uncommented user baz in tests/docker/group_vars/postgresql.yml. * Recreated user baz but without passwd. We need him as database owner :-). * Added encrypted passwd for user baz. * Commented need for encrypted password if version >= 10. * Reenabled no_log: true for task PostgreSQL | Make sure the PostgreSQL users are present Fixed text in templates/HOWTO.posgresql.conf * Just to trigger a new build on github. Added blank in README.md. * Second try to trigger a rebuild. Blank in README.md deleted.
1 parent a0cda0f commit 63e23ee

File tree

8 files changed

+1390
-16
lines changed

8 files changed

+1390
-16
lines changed

defaults/main.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ postgresql_ssl_ciphers:
116116
- "@STRENGTH"
117117
postgresql_ssl_prefer_server_ciphers: on
118118
postgresql_ssl_ecdh_curve: "prime256v1"
119+
postgresal_ssl_dh_params_file: "" # (>= 10)
119120
postgresql_ssl_renegotiation_limit: 512MB # amount of data between renegotiations
120121
postgresql_ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem" # (>= 9.2)
121122
postgresql_ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key" # (>= 9.2)
@@ -199,6 +200,7 @@ postgresql_bgwriter_flush_after: 0 # (>= 9.6) 0 disables,
199200
postgresql_effective_io_concurrency: 1 # 1-1000; 0 disables prefetching
200201
postgresql_max_worker_processes: 8 # (change requires restart)
201202
postgresql_max_parallel_workers_per_gather: 0 # (>= 9.6) taken from max_worker_processes
203+
postgresql_max_parallel_workers: 8 # (>= 10)
202204
postgresql_old_snapshot_threshold: -1 # (>= 9.6) 1min-60d; -1 disables; 0 is immediate
203205
# (change requires restart)
204206
postgresql_backend_flush_after: 0 # (>= 9.6) 0 disables, default is 0
@@ -319,6 +321,15 @@ postgresql_wal_receiver_timeout: 60s
319321
# time to wait before retrying to retrieve WAL after a failed attempt
320322
postgresql_wal_retrieve_retry_interval: 5s # (>= 9.5)
321323

324+
# - Subscribers - (>= 10)
325+
326+
# These settings are ignored on a publisher.
327+
328+
postgresql_max_logical_replication_workers: 4 # (>= 10) taken from max_worker_processes
329+
# (change requires restart)
330+
postgresql_max_sync_workers_per_subscription: 2 # (>= 10) taken from max_logical_replication_workers
331+
332+
322333
#------------------------------------------------------------------------------
323334
# QUERY TUNING
324335
#------------------------------------------------------------------------------
@@ -347,7 +358,9 @@ postgresql_cpu_index_tuple_cost: 0.005 # same scale as above
347358
postgresql_cpu_operator_cost: 0.0025 # same scale as above
348359
postgresql_parallel_tuple_cost: 0.1 # same scale as above (>= 9.6)
349360
postgresql_parallel_setup_cost: 1000.0 # same scale as above (>= 9.6)
350-
postgresql_min_parallel_relation_size: 8MB # (>= 9.6)
361+
postgresql_min_parallel_relation_size: 8MB # (= 9.6) replaced by below two parameters in 10
362+
postgresql_min_parallel_table_scan_size: 8MB # (>= 10)
363+
postgresql_min_parallel_index_scan_size: 512kB # (>= 10)
351364
postgresql_effective_cache_size: 128MB
352365

353366

@@ -499,11 +512,13 @@ postgresql_log_line_prefix: "%t "
499512
# log lock waits >= deadlock_timeout
500513
postgresql_log_lock_waits: off
501514
postgresql_log_statement: "none" # none, ddl, mod, all
515+
postgresql_log_replication_commands: off
502516
# log temporary files equal or larger
503517
postgresql_log_temp_files: -1
504518
postgresql_log_timezone: "UTC"
505519

506520

521+
507522
#------------------------------------------------------------------------------
508523
# RUNTIME STATISTICS
509524
#------------------------------------------------------------------------------
@@ -588,6 +603,7 @@ postgresql_bytea_output: "hex" # hex, escape
588603
postgresql_xmlbinary: "base64"
589604
postgresql_xmloption: "content"
590605
postgresql_gin_fuzzy_search_limit: 0 # (<= 9.2)
606+
postgresql_gin_pending_list_limit: 4MB # (>= 9.5)
591607

592608

593609
# - Locale and Formatting -
@@ -639,6 +655,11 @@ postgresql_max_locks_per_transaction: 64 # min 10
639655
# lock table slots.
640656
postgresql_max_pred_locks_per_transaction: 64 # min 10
641657

658+
postgresql_max_pred_locks_per_relation: -2 # (>= 10) negative values mean
659+
# (max_pred_locks_per_transaction
660+
# / -max_pred_locks_per_relation) - 1
661+
postgresql_max_pred_locks_per_page: 2 # (>= 10) min 0
662+
642663

643664
#------------------------------------------------------------------------------
644665
# VERSION/PLATFORM COMPATIBILITY
@@ -713,6 +734,7 @@ postgresql_pgdg_releases:
713734
9.4: 3,
714735
9.5: 3,
715736
9.6: 3,
737+
10: 2,
716738
}
717739
centos: {
718740
9.1: 7,
@@ -721,6 +743,7 @@ postgresql_pgdg_releases:
721743
9.4: 3,
722744
9.5: 3,
723745
9.6: 3,
746+
10: 2,
724747
}
725748
sl: {
726749
9.1: 8,
@@ -729,6 +752,7 @@ postgresql_pgdg_releases:
729752
9.4: 3,
730753
9.5: 3,
731754
9.6: 3,
755+
10: 2,
732756
}
733757
oraclelinux: {
734758
9.1: 8,
@@ -737,6 +761,7 @@ postgresql_pgdg_releases:
737761
9.4: 3,
738762
9.5: 3,
739763
9.6: 3,
764+
10: 2,
740765
}
741766
postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}"
742767
postgresql_yum_repository_base_url: "http://yum.postgresql.org"

templates/HOWTO.postgresql.conf

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@
22
How to add a new PostgreSQL version
33
===================================
44

5-
1) Download the Debian package 'postgresql-9.X_[...].deb' from
6-
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-9.X/
5+
Note: (https://www.postgresql.org/support/versioning)
76

8-
2) Extract the 'usr/share/postgresql/9.1/postgresql.conf.sample' file
9-
and save it under the 'templates' role directory
10-
=> templates/postgresql.conf.9.{X}.orig
7+
Beginning with version 10, a major release is indicated by increasing the first part of the version,
8+
e.g. 10 to 11. Before version 10, a major release was indicated by increasing either the first or second
9+
part of the version number, e.g. 9.5 to 9.6.
1110

12-
3) Check the difference between another version:
13-
=> vimdiff postgresql.conf.9.{X-1}.orig postgresql.conf.9.{X}.orig
11+
Do the following steps: ( versions mentioned for transitioninng from version 9.6 to 10 )
1412

15-
4) Copy an existing template:
16-
=> cp postgresql.conf.9.{X-1}.j2 postgresql.conf.9.{X}.j2
13+
1) Download the Debian package 'postgresql-<major_version>_[...].deb' from
14+
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-<major_version>, e.g. for new version 10 from
15+
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-10
16+
17+
2) Extract the 'usr/share/postgresql/<major-version>/postgresql.conf.sample' file with
18+
dpkg-deb -x postgresql-<major_version>_[...].deb dir/to/extract/to/
19+
20+
and save it under the 'templates' role directory
21+
=> templates/postgresql.conf.<major_version>.orig
22+
23+
3) Check the difference between another version, e.g. for 9.6 -> 10:
24+
=> vimdiff postgresql.conf.10.orig postgresql.conf.9.6.orig
25+
26+
4) Copy an existing template, e.g.:
27+
=> cp postgresql.conf.9.6.j2 postgresql.conf.10.j2
1728

1829
5) Update the new template following the major differences.
1930

20-
5) If there are new options or some of them removed, update the 'default/main.yml' file and add a "(>= 9.X)" or "(<= 9.X)" comment to them.
31+
6) If there are new options or some of them removed, update the 'default/main.yml' file and add a "(>= 10)" or "(<= 10)" comment to them.
32+
33+
7) For yum based installation add version and minor version of postgresql in 'default/main.yml' under '# YUM settings' at end of file
2134

22-
6) Update the '.travis.yml' file to test its new version.
35+
8) Update the '.travis.yml' file to test its new version.

templates/etc_systemd_system_postgresql.service.d_custom.conf.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ User={{ postgresql_service_user }}
66
Group={{ postgresql_service_group }}
77

88
Environment=PGDATA={{ postgresql_conf_directory }}
9-
109
ExecStartPre=
10+
{% if postgresql_version | version_compare('10', '>=') %}
11+
ExecStartPre={{ postgresql_bin_directory }}/postgresql-{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }}
12+
{% else %}
1113
ExecStartPre={{ postgresql_bin_directory }}/postgresql{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }}
14+
{% endif %}

0 commit comments

Comments
 (0)