diff --git a/manifests/server/initdb.pp b/manifests/server/initdb.pp index fe5de37..740fecc 100644 --- a/manifests/server/initdb.pp +++ b/manifests/server/initdb.pp @@ -80,5 +80,21 @@ class postgresql::server::initdb { } } } + } elsif $encoding != undef { + # [workaround] + # by default pg_createcluster encoding derived from locale + # but it do does not work by installing postgresql via puppet because puppet + # always override LANG to 'C' + postgresql_psql { "Set template1 encoding to ${encoding}": + command => "UPDATE pg_database + SET datistemplate = FALSE + WHERE datname = 'template1' + ; + UPDATE pg_database + SET encoding = pg_char_to_encoding('${encoding}'), datistemplate = TRUE + WHERE datname = 'template1'", + unless => "SELECT datname FROM pg_database WHERE + datname = 'template1' AND pg_encoding_to_char(encoding) = '${encoding}'", + } } }