Puppet style guide: modified MySQL and PgSQL database creation and population resources to fit autoload module layout

refs #6842
This commit is contained in:
Alexander Klimov 2014-09-02 13:29:43 +02:00
parent 62def403dc
commit d602f82db8
4 changed files with 25 additions and 27 deletions

View File

@ -0,0 +1,11 @@
define mysql::database::create ($username, $password, $privileges) {
include mysql
exec { "create-mysql-${name}-db":
unless => "mysql -u${username} -p${password} ${name}",
command => "mysql -uroot -e \"CREATE DATABASE ${name}; \
GRANT ${privileges} ON ${name}.* TO ${username}@localhost \
IDENTIFIED BY '${password}';\"",
require => Class['mysql']
}
}

View File

@ -1,15 +1,3 @@
define mysql::database::create ($username, $password, $privileges) {
include mysql
exec { "create-mysql-${name}-db":
unless => "mysql -u${username} -p${password} ${name}",
command => "mysql -uroot -e \"CREATE DATABASE ${name}; \
GRANT ${privileges} ON ${name}.* TO ${username}@localhost \
IDENTIFIED BY '${password}';\"",
require => Class['mysql']
}
}
define mysql::database::populate ($username, $password, $privileges, $schemafile) {
Exec { path => '/usr/bin' }

View File

@ -9,18 +9,3 @@ sudo -u postgres createlang plpgsql ${name}",
require => Class['pgsql']
}
}
define pgsql::database::populate ($username, $password, $schemafile) {
Exec { path => '/usr/bin' }
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 => Pgsql::Database::Create[$name],
}
}

View File

@ -0,0 +1,14 @@
define pgsql::database::populate ($username, $password, $schemafile) {
Exec { path => '/usr/bin' }
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 => Pgsql::Database::Create[$name],
}
}