Add mysql class to manage db, and configure db name

When using local mysql, this class is useful to automate
database creation. Also add the ability to configure database
name, so it can match the name created on mysql class.

Change-Id: I9c97b4a6355816b931e93d053f4748ef88f0a823
This commit is contained in:
Yolanda Robla 2015-10-15 11:27:56 +02:00
parent 7a03ae7eb1
commit b1cb51e864
3 changed files with 32 additions and 1 deletions

30
manifests/mysql.pp Normal file
View File

@ -0,0 +1,30 @@
# == Class: puppet-lodgeit::mysql
#
class lodgeit::mysql(
$mysql_root_password,
$database_name = $name,
$database_user = $name,
$database_password,
) {
class { '::mysql::server':
config_hash => {
'root_password' => $mysql_root_password,
'default_engine' => 'InnoDB',
'bind_address' => '127.0.0.1',
}
}
include ::mysql::server::account_security
mysql::db { $database_name:
user => $database_user,
password => $database_password,
host => 'localhost',
grant => ['all'],
charset => 'utf8',
require => [
Class['mysql::server'],
Class['mysql::server::account_security'],
],
}
}

View File

@ -5,6 +5,7 @@ define lodgeit::site(
$port,
$db_password,
$db_host='localhost',
$db_name=$name,
$db_user=$name,
$vhost_name="paste.${name}.org",
$image=undef,

View File

@ -7,7 +7,7 @@ from lodgeit import local
from lodgeit.application import make_app
from lodgeit.database import session
dburi = 'mysql://<%= @db_user %>:<%= @db_password %>@<%= @db_host %>:3306/<%= @name %>'
dburi = 'mysql://<%= @db_user %>:<%= @db_password %>@<%= @db_host %>:3306/<%= @db_name %>'
SECRET_KEY = 'no secret key'