From b615da174b44c1eebf83ca9fd7e18a01eb0a892b Mon Sep 17 00:00:00 2001 From: Greg Clough Date: Thu, 7 Mar 2019 16:07:39 +0000 Subject: [PATCH] Allow "archive_mode" to be on/off, or on/off/always >=9.5 Handle the new archive_mode option in v9.5 gracefully on all versions --- defaults/main.yml | 2 +- templates/postgresql.conf-10.j2 | 2 +- templates/postgresql.conf-9.1.j2 | 2 +- templates/postgresql.conf-9.2.j2 | 2 +- templates/postgresql.conf-9.3.j2 | 2 +- templates/postgresql.conf-9.4.j2 | 2 +- templates/postgresql.conf-9.5.j2 | 3 ++- templates/postgresql.conf-9.6.j2 | 3 ++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 8bc5f1a0..323287e9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -275,7 +275,7 @@ postgresql_checkpoint_warning: 30s # 0 disables # - Archiving - # allows archiving to be done -postgresql_archive_mode: off # Should be a string with quotes, but all templates need fixing first +postgresql_archive_mode: "off" # Command to use to archive a logfile segment. # Placeholders: %p = path of file to archive diff --git a/templates/postgresql.conf-10.j2 b/templates/postgresql.conf-10.j2 index bf8e03cf..3cd92fff 100644 --- a/templates/postgresql.conf-10.j2 +++ b/templates/postgresql.conf-10.j2 @@ -218,7 +218,7 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # enables archiving; off, on, or always +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else ( 'always' if postgresql_archive_mode == 'always' else 'off' ) }} # enables archiving; off, on, or always # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment # placeholders: %p = path of file to archive diff --git a/templates/postgresql.conf-9.1.j2 b/templates/postgresql.conf-9.1.j2 index e56a22be..383874be 100644 --- a/templates/postgresql.conf-9.1.j2 +++ b/templates/postgresql.conf-9.1.j2 @@ -179,7 +179,7 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # allows archiving to be done +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else 'off' }} # allows archiving to be done # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment archive_timeout = {{postgresql_archive_timeout}} # force a logfile segment switch after this diff --git a/templates/postgresql.conf-9.2.j2 b/templates/postgresql.conf-9.2.j2 index 652db52b..9cd3c34b 100644 --- a/templates/postgresql.conf-9.2.j2 +++ b/templates/postgresql.conf-9.2.j2 @@ -189,7 +189,7 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # allows archiving to be done +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else 'off' }} # allows archiving to be done # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment # placeholders: %p = path of file to archive diff --git a/templates/postgresql.conf-9.3.j2 b/templates/postgresql.conf-9.3.j2 index 6778c5d3..ee3fecca 100644 --- a/templates/postgresql.conf-9.3.j2 +++ b/templates/postgresql.conf-9.3.j2 @@ -190,7 +190,7 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # allows archiving to be done +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else 'off' }} # allows archiving to be done # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment # placeholders: %p = path of file to archive diff --git a/templates/postgresql.conf-9.4.j2 b/templates/postgresql.conf-9.4.j2 index dbc956cd..552752c9 100644 --- a/templates/postgresql.conf-9.4.j2 +++ b/templates/postgresql.conf-9.4.j2 @@ -204,7 +204,7 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # allows archiving to be done +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else 'off' }} # allows archiving to be done # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment # placeholders: %p = path of file to archive diff --git a/templates/postgresql.conf-9.5.j2 b/templates/postgresql.conf-9.5.j2 index 497d8875..c519a301 100644 --- a/templates/postgresql.conf-9.5.j2 +++ b/templates/postgresql.conf-9.5.j2 @@ -206,7 +206,8 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # enables archiving; off, on, or always +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else ( 'always' if postgresql_archive_mode == 'always' else 'off' ) }} # enables archiving; off, on, or always + # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment # placeholders: %p = path of file to archive # %f = file name only diff --git a/templates/postgresql.conf-9.6.j2 b/templates/postgresql.conf-9.6.j2 index f8cbeda4..5d878381 100644 --- a/templates/postgresql.conf-9.6.j2 +++ b/templates/postgresql.conf-9.6.j2 @@ -213,7 +213,8 @@ checkpoint_warning = {{postgresql_checkpoint_warning}} # 0 disables # - Archiving - -archive_mode = {{'on' if postgresql_archive_mode else 'off'}} # enables archiving; off, on, or always +archive_mode = {{ 'on' if ( postgresql_archive_mode|bool == true or postgresql_archive_mode == 'on' ) else ( 'always' if postgresql_archive_mode == 'always' else 'off' ) }} # enables archiving; off, on, or always + # (change requires restart) archive_command = '{{postgresql_archive_command}}' # command to use to archive a logfile segment # placeholders: %p = path of file to archive # %f = file name only