pgsql::database::populate: populate the DB only if it's empty
refs #6842
This commit is contained in:
parent
4484a3117b
commit
be7bae8cd6
|
@ -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],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue