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: # Requires:
# #
# pgsql::database::create # pgsql::database::create
# grep
# #
# Sample Usage: # Sample Usage:
# #
@ -21,6 +22,8 @@
# } # }
# #
define pgsql::database::populate ($username, $password, $schemafile) { define pgsql::database::populate ($username, $password, $schemafile) {
include grep
Exec { path => '/usr/bin' } Exec { path => '/usr/bin' }
pgsql::database::create { $name: pgsql::database::create { $name:
@ -31,6 +34,9 @@ define pgsql::database::populate ($username, $password, $schemafile) {
exec { "populate-${name}-pgsql-db": 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 *$'", 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}", command => "sudo -u postgres psql -U ${username} -d ${name} < ${schemafile}",
require => Pgsql::Database::Create[$name], require => [
Pgsql::Database::Create[$name],
Class['grep']
],
} }
} }