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