-
-
Notifications
You must be signed in to change notification settings - Fork 558
Description
Cookbook version
7.1.2
Chef-client version
14.8.12
Platform Details
Ubuntu 16.04 LTS
Scenario:
Trying to set initdb_locale for repo-installation of PostgreSQL.
Steps to Reproduce:
postgresql_server_install 'Install server from Repo' do
action :install
version POSTGRESQL_VERSION
password 'MyP4$$w0rd'
setup_repo true
initdb_locale 'de_DE.utf-8'
endExpected Result:
The template1 DB that is being initialized by initdb should have a de_DE.utf-8 locale but is using the system locale instead.
The initdb_locale value is only used for some linux distros as well:
postgresql/resources/server_install.rb
Lines 48 to 53 in a66d05c
| execute 'init_db' do | |
| command rhel_init_db_command(new_resource) | |
| user new_resource.user | |
| not_if { initialized? } | |
| only_if { platform_family?('rhel', 'fedora', 'amazon') } | |
| end |
postgresql/libraries/helpers.rb
Lines 206 to 217 in a66d05c
| # determine the appropriate DB init command to run based on RHEL/Fedora/Amazon release | |
| # initdb defaults to the execution environment. | |
| # https://www.postgresql.org/docs/9.5/static/locale.html | |
| def rhel_init_db_command(new_resource) | |
| cmd = if platform_family?('amazon') | |
| '/usr/bin/initdb' | |
| else | |
| "/usr/pgsql-#{new_resource.version}/bin/initdb" | |
| end | |
| cmd << " --locale '#{new_resource.initdb_locale}'" if new_resource.initdb_locale | |
| cmd << " -D '#{data_dir(new_resource.version)}'" | |
| end |
Actual Result:
On Debian/Ubuntu using the repo versions the initdb locale is set automatically to the system locale (if I understood the links below correctly), in this case en_US.utf8 because that's what we use on our host system. We could try to overwrite the LC_* environment variables to manipulate this, but instead what we're currently doing at work is using an explicit locale when creating databases, using the template0 database instead of template1.
For a given locale category, say the collation, the following environment variables are consulted in this order until one is found to be set:
LC_ALL,LC_COLLATE(or the variable corresponding to the respective category),LANG. source
Debian PostgreSQL installation automatically calls the initdb i.e. it initializes the cluster with default encoding and locale. Encoding can be changed later but the locale cannot. source
The above quote from the debian wiki might not exactly describe what's happening here, since setup_repo used the PGPD and not the official debian packages, but it's what I am experiencing.