p0d*_*eje 3 postgresql ubuntu puppet
我正在尝试构建使用Puppet配置的Vagrant盒子.
我使用http://files.vagrantup.com/precise64.box上的 Ubuntu 12.04 LTS框.
我还使用http://forge.puppetlabs.com/puppetlabs/postgresql模块安装带有以下清单的PostgreSQL:
class db {
class { 'postgresql': version => '9.1' }
class { 'postgresql::server': }
}
class { 'db': }
Run Code Online (Sandbox Code Playgroud)
它安装正确,但数据库是使用SQL_ASCII编码创建的:
$ psql -l -U postgres
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+-----------+---------+-------+-----------------------
postgres | postgres | SQL_ASCII | C | C |
template0 | postgres | SQL_ASCII | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | SQL_ASCII | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
Run Code Online (Sandbox Code Playgroud)
谷歌搜索后,我认为它可能是一个区域设置问题,但它看起来对我来说是正确的:
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Run Code Online (Sandbox Code Playgroud)
你知道我该怎么做才能安装默认的UTF8编码的PostgreSQL吗?能够使用Puppet也很好.
p0d*_*eje 12
显然,它是Puppet bug http://projects.puppetlabs.com/issues/4695.从问题评论中添加以下代码作为解决方法:
# workaround for http://projects.puppetlabs.com/issues/4695
# when PostgreSQL is installed with SQL_ASCII encoding instead of UTF8
exec { 'utf8 postgres':
command => 'pg_dropcluster --stop 9.1 main ; pg_createcluster --start --locale en_US.UTF-8 9.1 main',
unless => 'sudo -u postgres psql -t -c "\l" | grep template1 | grep -q UTF',
require => Class['postgresql::server'],
path => ['/bin', '/sbin', '/usr/bin', '/usr/sbin'],
}
Run Code Online (Sandbox Code Playgroud)