Skip to content

Instantly share code, notes, and snippets.

@mathie
Created July 1, 2013 14:48
Show Gist options
  • Save mathie/5901480 to your computer and use it in GitHub Desktop.
Save mathie/5901480 to your computer and use it in GitHub Desktop.
Since Puppet stopped passing environment variables down to subprocesses (like, say, `apt-get install`), I've occasionally run into problems where a package postinst script relies on something in the environment. The PostgreSQL package (on Ubuntu 12.04 at least) is one such beast. It relies on the current locale (gleamed from the environment) to …
class postgresql::server::config {
exec {
'postgresql-drop-cluster':
command => '/usr/bin/pg_dropcluster --stop 9.1 main',
onlyif => "/usr/bin/psql -c '\\l+' |awk '/template0/ { print \$5 }' |grep 'SQL_ASCII'",
user => postgres,
notify => Exec['postgresql-create-cluster'];
'postgresql-create-cluster':
command => '/usr/bin/pg_createcluster --locale=en_GB.UTF-8 9.1 main',
user => postgres,
refreshonly => true,
before => [ File['/etc/postgresql/9.1/main/postgresql.conf'], File['/etc/postgresql/9.1/main/pg_hba.conf'] ];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment