Created
December 16, 2012 12:13
-
-
Save eMerzh/4306706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define postgresql::db ($name, $ensure=present){ | |
case $ensure { | |
present: { | |
exec { "Create $name postgres db": | |
command => "createdb $name", | |
unless => "test \$(psql -tA -c \"SELECT count(*)=1 FROM pg_catalog.pg_database where datname='${name}';\") = t", | |
} | |
} | |
absent: { | |
exec { "Remove $name postgres db": | |
command => "dropdb $name", | |
user => "postgres", | |
onlyif => "test \$(psql -tA -c \"SELECT count(*)=1 FROM pg_catalog.pg_database where datname='${name}';\") = t", | |
} | |
} | |
default: { | |
fail "Invalid 'ensure' value '$ensure' for postgres::database" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lib/store.pp | |
define postgresql::lib::hstore($db_name) { | |
exec {"pg_installlib_hstore_${cluster_name}_${db}": | |
user => "postgres", | |
command => "psql -f /usr/share/postgresql/hstore.sql ${db_name} ", | |
unless => "psql -tA -c \"SELECT ''::hstore;\" ${db_name}", | |
require => Postgresql::Db["${db_name}"], | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lib/trgm.pp | |
define postgresql::lib::trgm($db_name) { | |
exec {"pg_installlib_trgm_${cluster_name}_${db}": | |
user => "postgres", | |
command => "psql -f /usr/share/postgresql/trgm.sql ${db_name} ", | |
unless => "psql -tA -c \"SELECT show_limit();\" ${db_name}", | |
require => Postgresql::Db["${db_name}"], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment