pgsql::database::populate: populate the DB only if it's empty

refs #6842
This commit is contained in:
Alexander Klimov 2014-09-09 12:32:21 +02:00
parent 4484a3117b
commit be7bae8cd6
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@ define pgsql::database::populate ($username, $password, $schemafile) {
}
exec { "populate-${name}-pgsql-db":
unless => "psql -U ${username} -d ${name} -c \"SELECT * FROM icinga_dbversion;\" &> /dev/null",
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],
}