Puppet style guide: modified MySQL and PgSQL database creation and population resources to fit autoload module layout
refs #6842
This commit is contained in:
parent
62def403dc
commit
d602f82db8
|
@ -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']
|
||||
}
|
||||
}
|
|
@ -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' }
|
||||
|
|
@ -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],
|
||||
}
|
||||
}
|
|
@ -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],
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue