From 2137844cb54f644f1fb7a8a0c56c740f0a16a588 Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Tue, 21 Mar 2017 14:34:07 +0100 Subject: [PATCH] Add support for --data-checksums on initdb --- README.md | 12 ++++++++++++ manifests/globals.pp | 1 + manifests/params.pp | 5 +++++ manifests/server.pp | 1 + manifests/server/initdb.pp | 10 ++++++++-- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1128623fd9..44da51c58d 100644 --- a/README.md +++ b/README.md @@ -411,6 +411,12 @@ Overrides the default PostgreSQL data directory for the target platform. Default **Warning:** If datadir is changed from the default, Puppet does not manage purging of the original data directory, which causes it to fail if the data directory is changed back to the original. +##### `data_checksums` + +Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Valid values: 'true' or 'false'. Default: initdb's default ('false'). + +**Warning:** This option is used during initialization by initdb, and cannot be changed later. If set, checksums are calculated for all objects, in all databases. + ##### `default_database` Specifies the name of the default database to connect with. On most systems, this is 'postgres'. @@ -619,6 +625,12 @@ The name of the PostgreSQL Python package. **Deprecated.** Specifies the path to the `createdb` command. Default: "${bindir}/createdb". +##### `data_checksums` + +Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Valid values: 'true' or 'false'. Default: initdb's default ('false'). + +**Warning:** This option is used during initialization by initdb, and cannot be changed later. If set, checksums are calculated for all objects, in all databases. + ##### `default_database` Specifies the name of the default database to connect with. On most systems this is "postgres". diff --git a/manifests/globals.pp b/manifests/globals.pp index 298439d8c9..dac2b64ecb 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -47,6 +47,7 @@ $repo_baseurl = undef, $needs_initdb = undef, + $data_checksums = undef, $encoding = undef, $locale = undef, diff --git a/manifests/params.pp b/manifests/params.pp index 8b30728bda..e3c410d440 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,6 +12,7 @@ $encoding = $postgresql::globals::encoding $locale = $postgresql::globals::locale $timezone = $postgresql::globals::timezone + $data_checksums = $postgresql::globals::data_checksums $service_ensure = 'running' $service_enable = true $service_manage = true @@ -308,6 +309,10 @@ } } + if($data_checksums and versioncmp($version, '9.3') < 0) { + fail('data_checksums require version 9.3 or greater') + } + $validcon_script_path = pick($validcon_script_path, '/usr/local/bin/validate_postgresql_connection.sh') $initdb_path = pick($initdb_path, "${bindir}/initdb") $pg_hba_conf_path = pick($pg_hba_conf_path, "${confdir}/pg_hba.conf") diff --git a/manifests/server.pp b/manifests/server.pp index 2e90178197..249fb6ce51 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -45,6 +45,7 @@ $group = $postgresql::params::group, $needs_initdb = $postgresql::params::needs_initdb, + $data_checksums = $postgresql::params::data_checksums, $encoding = $postgresql::params::encoding, $locale = $postgresql::params::locale, diff --git a/manifests/server/initdb.pp b/manifests/server/initdb.pp index 2252a198f1..31b3fd0bb0 100644 --- a/manifests/server/initdb.pp +++ b/manifests/server/initdb.pp @@ -1,6 +1,7 @@ # PRIVATE CLASS: do not call directly class postgresql::server::initdb { $needs_initdb = $postgresql::server::needs_initdb + $data_checksums = $postgresql::server::data_checksums $initdb_path = $postgresql::server::initdb_path $datadir = $postgresql::server::datadir $xlogdir = $postgresql::server::xlogdir @@ -74,6 +75,11 @@ default => "${ic_base} --xlogdir '${xlogdir}'" } + $ic_checksums = $data_checksums ? { + true => "${ic_xlog} --data-checksums", + default => $ic_xlog, + } + # The xlogdir need to be present before initdb runs. # If xlogdir is default it's created by package installer if($xlogdir) { @@ -83,8 +89,8 @@ } $initdb_command = $locale ? { - undef => $ic_xlog, - default => "${ic_xlog} --locale '${locale}'" + undef => $ic_checksums, + default => "${ic_checksums} --locale '${locale}'" } # This runs the initdb command, we use the existance of the PG_VERSION