Skip to content

Instantly share code, notes, and snippets.

@hSATAC
Last active January 3, 2019 22:09
Show Gist options
  • Save hSATAC/51a13739c2fc678ed3f4 to your computer and use it in GitHub Desktop.
Save hSATAC/51a13739c2fc678ed3f4 to your computer and use it in GitHub Desktop.
Set postgresql template1 encoding to UTF8 in Puppet.
exec { "postgresql-template1-utf8":
command => "psql -c \"update pg_database set datistemplate=false where datname='template1';\" &&
psql -c 'drop database Template1;' &&
psql -c \"create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;\"
",
user => "postgres",
path => "/usr/bin",
unless => "/usr/bin/psql -Atc \"select pg_encoding_to_char(encoding) from pg_database where datname='template1'\" | /bin/grep -c UTF8"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment