parent
645a2ec380
commit
9bb68c42a0
|
@ -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']
|
||||
],
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue