aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorPaul B <paul@bonaud.fr>2020-05-06 13:51:59 +0200
committerPaul B <paul@bonaud.fr>2020-05-06 19:36:24 +0200
commit8d1689150f638c6330e321eba7baf3f97678216a (patch)
tree00dbf539552e176496e4029c42b172667086b7e3 /tasks
parentb9038ad7484a472f1e745906fb0d26530061b58d (diff)
downloadansible-postgresql-role-8d1689150f638c6330e321eba7baf3f97678216a.tar.gz
ansible-postgresql-role-8d1689150f638c6330e321eba7baf3f97678216a.tar.zst
ansible-postgresql-role-8d1689150f638c6330e321eba7baf3f97678216a.zip
core: Add compatibility with PG 12 major version
This PR adds compatibility for postgresql 12 major version. The PG12 configuration is as close as the PG11 one. All defaults have been kept back to avoid breaking backward compatibility within this ansible role. Here is a complete side-by-side diff between the current PG11 conf and the new PG12 conf: ```diff # 0 selects the syste # 0 selects the syste > #tcp_user_timeout = 0 # TCP_USER_TIMEOUT, i > # 0 selects the syste > #ssl_min_protocol_version = 'TLSv1' > #ssl_max_protocol_version = '' > #shared_memory_type = mmap # the default is the > # supported by the op > # mmap > # sysv > # windows > # (change requires re dynamic_shared_memory_type = posix # the default is the dynamic_shared_memory_type = posix # the default is the # supported by the op # supported by the op # posix # posix # sysv # sysv # windows # windows # mmap # mmap # use none to disable < # (change requires re # (change requires re wal_level = logical # minimal, replica, o | wal_level = {{ postgres_wal_level }} # min # (change requires re # (change requires re wal_log_hints = on # also do full page w wal_log_hints = on # also do full page w # (change requires re # (change requires re > #wal_init_zero = on # zero-fill new WAL f > #wal_recycle = on # recycle WAL files # (change requires re # (change requires re > # - Archive Recovery - > > # These are only used in recovery mode. > > {% if postgres_primary %} > {# In PG < 12 versions all the recovery settings were in a se > restore_command = '/usr/bin/barman-wal-restore --user barman > # placeholders: %p = path of > # %f = file nam > # e.g. 'cp /mnt/server/archiv > # (change requires restart) > {% else %} > #restore_command = '' # command to use to restore a > # placeholders: %p = path of > # %f = file nam > # e.g. 'cp /mnt/server/archiv > # (change requires restart) > {% endif %} > #archive_cleanup_command = '' # command to execute at every > #recovery_end_command = '' # command to execute at compl > > # - Recovery Target - > > # Set these only when performing a targeted recovery. > > #recovery_target = '' # 'immediate' to end recovery > # consistent state is reached > # (change requires restart) > #recovery_target_name = '' # the named restore point to > # (change requires restart) > #recovery_target_time = '' # the time stamp up to which > # (change requires restart) > #recovery_target_xid = '' # the transaction ID up to wh > # (change requires restart) > #recovery_target_lsn = '' # the WAL LSN up to which rec > # (change requires restart) > #recovery_target_inclusive = on # Specifies whether to stop: > # just after the specified re > # just before the recovery ta > # (change requires restart) > {% if postgres_primary %} > {# In PG < 12 versions all the recovery settings were in a se > recovery_target_timeline='latest' # 'current', 'latest' > # (change requires restart) > {% else %} > #recovery_target_timeline = 'latest' # 'current', 'latest' > # (change requires restart) > {% endif %} > #recovery_target_action = 'pause' # 'pause', 'promote', > # (change requires restart) max_wal_senders = 10 # max number of walsender pro | #max_wal_senders = 10 # max number of walsender pro # (change requires restart) # (change requires restart) > {% if postgres_primary %} > {# In PG < 12 versions this setting was defined in separate r > primary_conninfo = 'host={{ postgres_primary.host }} port={{ > # (change requires re > {% else %} > #primary_conninfo = '' # connection string t > # (change requires re > {% endif %} > #primary_slot_name = '' # replication slot on > # (change requires re > {% if postgres_primary %} > {# In PG < 12 versions this setting was defined in separate r > promote_trigger_file = '/var/lib/postgresql/{{ postgres_versi > {% else %} > #promote_trigger_file = '' # file name whose pre > {% endif %} # retrieve WAL after # retrieve WAL after > #recovery_min_apply_delay = 0 # minimum delay for a > #plan_cache_mode = auto # auto, force_generic > # force_custom_plan > # debug5 < # debug4 < # debug3 < # debug2 < # debug1 < # log < # notice < # warning < # error < < log_min_duration_statement = 10000 # -1 is disabled, 0 l log_min_duration_statement = 10000 # -1 is disabled, 0 l # and their durations # and their durations # statements running # statements running # of milliseconds # of milliseconds > #log_transaction_sample_rate = 0.0 # Fraction of transac > # are logged regardle > # statements from all > #client_min_messages = notice # values in order of > # debug5 > # debug4 > # debug3 > # debug2 > # debug1 > # log > # notice > # warning > # error # only default tables # only default tables > #default_table_access_method = 'heap' > # selects precise out > #data_sync_retry = off # retry or panic on f > # data? > # (change requires re > # assignments, so they can usefully be given more than once. ```
Diffstat (limited to 'tasks')
-rw-r--r--tasks/postgres-cluster.yml13
1 files changed, 11 insertions, 2 deletions
diff --git a/tasks/postgres-cluster.yml b/tasks/postgres-cluster.yml
index c052982..a8e96c1 100644
--- a/tasks/postgres-cluster.yml
+++ b/tasks/postgres-cluster.yml
@@ -5,6 +5,7 @@
5 postgres_port: "{{ postgres_cluster.port }}" 5 postgres_port: "{{ postgres_cluster.port }}"
6 postgres_fsync_enabled: "{{ postgres_cluster.fsync_enabled }}" 6 postgres_fsync_enabled: "{{ postgres_cluster.fsync_enabled }}"
7 postgres_archive_enabled: "{{ postgres_cluster.archive_enabled }}" 7 postgres_archive_enabled: "{{ postgres_cluster.archive_enabled }}"
8 postgres_wal_level: "{{ postgres_cluster.wal_level|default('logical') }}"
8 postgres_max_replication_slots: "{{ postgres_cluster.max_replication_slots | default(10) }}" 9 postgres_max_replication_slots: "{{ postgres_cluster.max_replication_slots | default(10) }}"
9 postgres_extra_config: "{{ postgres_cluster.extra_config | default({}) }}" 10 postgres_extra_config: "{{ postgres_cluster.extra_config | default({}) }}"
10 barman_directory: "{{ postgres_cluster.barman_directory | default(None) }}" 11 barman_directory: "{{ postgres_cluster.barman_directory | default(None) }}"
@@ -19,7 +20,7 @@
19 apt: name=postgresql-{{ postgres_version }}-repack 20 apt: name=postgresql-{{ postgres_version }}-repack
20 when: 21 when:
21 - ansible_distribution_release != 'NA' 22 - ansible_distribution_release != 'NA'
22 - postgres_version in ['9.3', '9.4', '9.5', '9.6', '10', '11'] 23 - postgres_version in ['9.3', '9.4', '9.5', '9.6', '10', '11', '12']
23 24
24- name: Set initdb options 25- name: Set initdb options
25 set_fact: postgres_initdb_option="{% if postgres_checksums %}--data-checksums{% endif %}" 26 set_fact: postgres_initdb_option="{% if postgres_checksums %}--data-checksums{% endif %}"
@@ -82,9 +83,17 @@
82 83
83- name: Upload recovery.conf 84- name: Upload recovery.conf
84 template: src=recovery.conf.j2 dest=/var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}/recovery.conf owner=postgres group=postgres mode=0600 85 template: src=recovery.conf.j2 dest=/var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}/recovery.conf owner=postgres group=postgres mode=0600
85 when: postgres_primary 86 when: postgres_primary and postgres_version is version('12', '<')
86 no_log: True 87 no_log: True
87 88
89- name: Define secondary nodes as secondaries with corresponding signal files
90 file:
91 path: "{{ item }}"
92 state: touch
93 when: postgres_primary and postgres_version is version('12', '>=')
94 with_items:
95 - /var/lib/postgresql/{{ postgres_version }}/{{ postgres_cluster_name }}/standby.signal
96
88- name: Create log file 97- name: Create log file
89 file: 98 file:
90 path={{ postgres_log_dir }}/postgresql-{{ postgres_version }}-{{ postgres_cluster_name }}.log 99 path={{ postgres_log_dir }}/postgresql-{{ postgres_version }}-{{ postgres_cluster_name }}.log