Fix template1 encoding on debian

This commit is contained in:
Mickaël Canévet 2014-12-05 10:24:32 +01:00
parent 0daf411a3e
commit e1034d9bee

View file

@ -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}'",
}
} }
} }