How can I provision a postgresql database with ASCII encoding?

asked 2015-08-19 08:45:17 -0500

drubio1989 gravatar image

I am using Vagrant to create a sandbox environment and then use Puppet to provision a Postgresql 9.2 database. What I'd like to do is to have the database created with SQL_ASCII encoding instead of UTF-8. I've found a few posts solving the problem of converting a database to UTF-8 from ASCII but not the reverse. How can I do the opposite. Here is my tree directory for Vagrant. BTW Vagrant has a section in the docs for provisioning with Puppet which I have followed.

Vagrant tree directory:

- Vagrantfile
- manifests
   - default.pp

Here are the contents of my default.pp manifest file:

class { 'postgresql::globals':
  manage_package_repo => true,
  version => '9.2',

class { 'postgresql::server':
  listen_addresses =>  '*',

postgresql::server::db { 'openhub_testing':
  owner => 'ruby',
  user => 'ruby',
  password => 'blackswan',
  template => 'template1', 

postgresql::server::pg_hba_rule { 'allow a connection from ohloh-ui on my Mac OSX':
  description => 'Open up access for',
  type => host,
  database => 'openhub_testing',
  user => all,
  address => '',
  auth_method => 'trust',

I've read the documentation for the puppetlabs/postgresql documentation and accordingly the encoding setting can be changed in postgresql::globals, postgresql::server, postgresql::server::db.

I've tried adding this line of code to all three individually at some point encoding => 'ASCII,'

I've also tried encoding => 'SQL_ASCII',

None of these variations work and they all post these three errors when I try to provision my vagrant box.

==> default: Error: /Stage[main]/Main/Postgresql::Server::Db[openhub_testing]/Postgresql::Server::Database[openhub_testing]/Exec[/usr/lib/postgresql/9.2/bin/createdb --port='5432' --owner='ruby' --template=template1 --encoding 'SQL_ASCII'  'openhub_testing']: Failed to call refresh: /usr/lib/postgresql/9.2/bin/createdb --port='5432' --owner='ruby' --template=template1 --encoding 'SQL_ASCII'  'openhub_testing' returned 1 instead of one of [0]

==> default: Error: /Stage[main]/Main/Postgresql::Server::Db[openhub_testing]/Postgresql::Server::Database[openhub_testing]/Exec[/usr/lib/postgresql/9.2/bin/createdb --port='5432' --owner='ruby' --template=template1 --encoding 'SQL_ASCII'  'openhub_testing']: /usr/lib/postgresql/9.2/bin/createdb --port='5432' --owner='ruby' --template=template1 --encoding 'SQL_ASCII'  'openhub_testing' returned 1 instead of one of [0]

==> default: Notice: /Stage[main]/Main/Postgresql::Server::Db[openhub_testing]/Postgresql::Server::Database[openhub_testing]/Postgresql_psql[UPDATE pg_database SET datistemplate = false WHERE datname = 'openhub_testing']/command: command changed 'notrun' to 'UPDATE pg_database SET datistemplate = false WHERE datname = 'openhub_testing''

==> default: Error: /Stage[main]/Main/Postgresql::Server::Db[openhub_testing]/Postgresql::Server::Database_grant[GRANT ruby - ALL - openhub_testing]/Postgresql::Server::Grant[database:GRANT ruby - ALL - openhub_testing]/Postgresql_psql[grant:database:GRANT ruby - ALL - openhub_testing]: Could not evaluate: Error evaluating 'unless' clause, returned pid 4764 exit 1: 'ERROR:  database "openhub_testing" does not exist

Has anyone experienced this problem? What seems to be happening is that when I set the encoding to ASCII the provision fails, doesn't create the database, and then the end product is a standard default cluster with postgres, UTF8, etc. This field also fails with any other encoding format supported by Postgresql. Is there a known issue? Any help would be greatly appreciated. Thank you.

edit retag flag offensive close merge delete