Alexander Klimov 67efe52141 Revert "Put always a ',' after a parameter because explicit is better than implicit"
This reverts commit 26205a76b3c9a937a62f4c221b03c2d4309d4c90.
2014-08-18 11:00:30 +02:00

27 lines
983 B
Puppet

define pgsql::database::create ($username, $password) {
include pgsql
exec { "create-pgsql-${name}-db":
unless => "sudo -u postgres psql -tAc \"SELECT 1 FROM pg_roles WHERE rolname='${username}'\" | grep -q 1",
command => "sudo -u postgres psql -c \"CREATE ROLE ${username} WITH LOGIN PASSWORD '${password}';\" && \
sudo -u postgres createdb -O ${username} -E UTF8 -T template0 ${name} && \
sudo -u postgres createlang plpgsql ${name}",
require => Service['postgresql']
}
}
define pgsql::database::populate ($username, $password, $schemafile, $requirement) {
include pgsql
pgsql::database::create { $name:
username => $username,
password => $password,
}
exec { "populate-${name}-pgsql-db":
unless => "psql -U ${username} -d ${name} -c \"SELECT * FROM icinga_dbversion;\" &> /dev/null",
command => "sudo -u postgres psql -U ${username} -d ${name} < ${schemafile}",
require => [ $requirement, Exec["create-pgsql-${name}-db"] ]
}
}