Skip to content

Commit

Permalink
pgsql::database::populate: require module `grep'
Browse files Browse the repository at this point in the history
refs #6842
  • Loading branch information
Al2Klimov committed Sep 10, 2014
1 parent 645a2ec commit 9bb68c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .vagrant-puppet/modules/pgsql/manifests/database/populate.pp
Expand Up @@ -11,6 +11,7 @@
# Requires:
#
# pgsql::database::create
# grep
#
# Sample Usage:
#
Expand All @@ -21,6 +22,8 @@
# }
#
define pgsql::database::populate ($username, $password, $schemafile) {
include grep

Exec { path => '/usr/bin' }

pgsql::database::create { $name:
Expand All @@ -31,6 +34,9 @@
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']
],
}
}

0 comments on commit 9bb68c4

Please sign in to comment.