pgsql::database::populate: require module `grep'

refs #6842
This commit is contained in:
Alexander Klimov 2014-09-10 10:06:42 +02:00
parent 645a2ec380
commit 9bb68c42a0
1 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,7 @@
# Requires:
#
# pgsql::database::create
# grep
#
# Sample Usage:
#
@ -21,6 +22,8 @@
# }
#
define pgsql::database::populate ($username, $password, $schemafile) {
include grep
Exec { path => '/usr/bin' }
pgsql::database::create { $name:
@ -31,6 +34,9 @@ define pgsql::database::populate ($username, $password, $schemafile) {
exec { "populate-${name}-pgsql-db":
onlyif => "psql -U ${username} -d ${name} -c \"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${name}';\" 2>/dev/null |grep -qEe '^ *0 *$'",
command => "sudo -u postgres psql -U ${username} -d ${name} < ${schemafile}",
require => Pgsql::Database::Create[$name],
require => [
Pgsql::Database::Create[$name],
Class['grep']
],
}
}