Added nodepool::mysql class

- Created nodepool::mysql class, which includes mysql stuff from
  init.pp. This allows to host database on separated host than
  the one running nodepool.
- Discarded creation of 'max_connections.cnf' file. Instead,  use
  'max_connections' from '::mysql::server' config_hash/override_options.

Change-Id: Ic745875b69563ed3834e99533227ca3d1150156b
This commit is contained in:
Mateusz Matuszkowiak 2016-05-17 21:58:17 +02:00
parent b72fc61717
commit 780df18752
3 changed files with 62 additions and 33 deletions

View File

@ -38,41 +38,20 @@ class nodepool (
$jenkins_masters = [],
$build_workers = '1',
$upload_workers = '4',
$install_mysql = true,
$mysql_db_name = 'nodepool',
$mysql_host = 'localhost',
$mysql_user_name = 'nodepool',
) {
$mysql_data = load_module_metadata('mysql', true)
if $mysql_data == {} {
class { '::mysql::server':
config_hash => {
'root_password' => $mysql_root_password,
'default_engine' => 'InnoDB',
'bind_address' => '127.0.0.1',
}
if($install_mysql) {
class { '::nodepool::mysql' :
mysql_db_name => $mysql_db_name,
mysql_root_password => $mysql_root_password,
mysql_user_host => $mysql_host,
mysql_user_name => $mysql_user_name,
mysql_password => $mysql_password,
}
} else { # If it has metadata.json, assume it's new enough to use this interface
class { '::mysql::server':
root_password => $mysql_root_password,
override_options => {
'mysqld' => {
'default-storage-engine' => 'InnoDB',
}
},
}
}
include ::mysql::server::account_security
mysql::db { 'nodepool':
user => 'nodepool',
password => $mysql_password,
host => 'localhost',
grant => ['all'],
charset => 'utf8',
require => [
Class['mysql::server'],
Class['mysql::server::account_security'],
],
}
$packages = [

50
manifests/mysql.pp Normal file
View File

@ -0,0 +1,50 @@
# == Class: nodepool::mysql
#
class nodepool::mysql (
$mysql_password,
$mysql_root_password,
$mysql_bind_address = '127.0.0.1',
$mysql_default_engine = 'InnoDB',
$mysql_db_name = 'nodepool',
$mysql_max_connections = 8192,
$mysql_user_host = 'localhost',
$mysql_user_name = 'nodepool',
) {
$mysql_data = load_module_metadata('mysql', true)
if ($mysql_data == {}) {
class { '::mysql::server' :
config_hash => {
'bind_address' => $mysql_bind_address,
'default_engine' => $mysql_default_engine,
'max_connections' => $mysql_max_connections,
'root_password' => $mysql_root_password,
}
}
} else { # If it has metadata.json, assume it's new enough to use this interface
class { '::mysql::server' :
override_options => {
'mysqld' => {
'default-storage-engine' => $mysql_default_engine,
'max_connections' => $mysql_max_connections,
}
},
root_password => $mysql_root_password,
}
}
include ::mysql::server::account_security
mysql::db { $mysql_db_name :
user => $mysql_user_name,
password => $mysql_password,
host => $mysql_user_host,
grant => ['all'],
charset => 'utf8',
require => [
Class['mysql::server'],
Class['mysql::server::account_security'],
],
}
}

View File

@ -1,5 +1,5 @@
[database]
dburi=mysql+pymysql://nodepool:<%= @mysql_password %>@localhost/nodepool
dburi=mysql+pymysql://<%= @mysql_user_name %>:<%= @mysql_password %>@<%= @mysql_host %>/<%= @mysql_db_name %>
<% @jenkins_masters.each do |master| -%>
[jenkins "<%= master['name'] -%>"]