Skip to content

Commit 7c7195b

Browse files
author
Ashley Penney
committed
Refactor MySQL bindings and client packages.
The current MySQL module is hard to modify, test, and drop in replacement components to. This work starts out by refactoring the bindings support in MySQL to a completely seperate bindings class in order to reduce the amount of parameters in the main class for a feature that is infrequently used. In addition to this start the movement of client configuration and packages to the mysql::client::* namespace.
1 parent b629655 commit 7c7195b

16 files changed

+316
-161
lines changed

manifests/bindings.pp

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Class: mysql::bindings
2+
#
3+
# This class installs various bindings for mysql.
4+
#
5+
# Parameters:
6+
#
7+
# [*java_enable*] - Boolean to determine if we should include the java bindings.
8+
#
9+
# [*perl_enable*] - Boolean to determine if we should include the perl bindings.
10+
#
11+
# [*python_enable*] - Boolean to determine if we should include the python bindings.
12+
#
13+
# [*ruby_enable*] - Boolean to determine if we should include the ruby bindings.
14+
#
15+
# [*java_package_name*] - The name of the java package containing the java connector
16+
#
17+
# [*java_package_ensure*] - State of the java binding packages.
18+
#
19+
# [*perl_package_ensure*] - State of the perl binding packages.
20+
#
21+
# [*perl_package_name*] - The name of the perl mysql package to install
22+
#
23+
# [*perl_package_provider*] - The provider to use when installing the perl package.
24+
#
25+
# [*python_package_ensure*] - State of the python binding packages.
26+
#
27+
# [*python_package_name*] - The name of the python mysql package to install
28+
#
29+
# [*ruby_ensure*] - State of the ruby binding packages.
30+
#
31+
# [*ruby_package_name*] - The name of the ruby mysql package to install
32+
#
33+
# [*ruby_package_provider*] - The provider to use when installing the ruby package.
34+
#
35+
class mysql::bindings (
36+
# Boolean to determine if we should include the classes.
37+
$java_enable = false,
38+
$perl_enable = false,
39+
$python_enable = false,
40+
$ruby_enable = false,
41+
# Settings for the various classes.
42+
$java_package_ensure = $mysql::params::java_package_ensure,
43+
$java_package_name = $mysql::params::java_package_name,
44+
$perl_package_ensure = $mysql::params::perl_package_ensure,
45+
$perl_package_name = $mysql::params::perl_package_name,
46+
$perl_package_provider = $mysql::params::perl_package_provider,
47+
$python_package_ensure = $mysql::params::python_package_ensure,
48+
$python_package_name = $mysql::params::python_package_name,
49+
$ruby_package_ensure = $mysql::params::ruby_package_ensure,
50+
$ruby_package_name = $mysql::params::ruby_package_name,
51+
$ruby_package_provider = $mysql::params::ruby_package_provider,
52+
) inherits mysql::params {
53+
54+
if $java_enable { include '::mysql::bindings::java' }
55+
if $perl_enable { include '::mysql::bindings::perl' }
56+
if $python_enable { include '::mysql::bindings::python' }
57+
if $ruby_enable { include '::mysql::bindings::ruby' }
58+
59+
}

manifests/java.pp renamed to manifests/bindings/java.pp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Class: mysql::java
1+
# Class: mysql::bindings::java
22
#
33
# This class installs the mysql-java-connector.
44
#
@@ -11,9 +11,9 @@
1111
#
1212
# Sample Usage:
1313
#
14-
class mysql::java (
15-
$package_ensure = 'present',
16-
$package_name = $mysql::java_package_name
14+
class mysql::bindings::java (
15+
$package_ensure = $mysql::bindings::java_package_ensure,
16+
$package_name = $mysql::bindings::java_package_name
1717
) inherits mysql {
1818

1919
package { 'mysql-connector-java':

manifests/perl.pp renamed to manifests/bindings/perl.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Class: mysql::perl
1+
# Class: mysql::bindings::perl
22
#
33
# installs the perl bindings for mysql
44
#
@@ -13,10 +13,10 @@
1313
#
1414
# Sample Usage:
1515
#
16-
class mysql::perl (
17-
$package_ensure = 'present',
18-
$package_name = $mysql::perl_package_name,
19-
$package_provider = $mysql::perl_package_provider
16+
class mysql::bindings::perl (
17+
$package_ensure = $mysql::bindings::perl_package_ensure,
18+
$package_name = $mysql::bindings::perl_package_name,
19+
$package_provider = $mysql::bindings::perl_package_provider
2020
) inherits mysql {
2121

2222
package{ 'perl_mysql':

manifests/python.pp renamed to manifests/bindings/python.pp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Class: mysql::python
1+
# Class: mysql::bindings::python
22
#
33
# This class installs the python libs for mysql.
44
#
@@ -12,9 +12,9 @@
1212
#
1313
# Sample Usage:
1414
#
15-
class mysql::python(
16-
$package_ensure = 'present',
17-
$package_name = $mysql::python_package_name
15+
class mysql::bindings::python(
16+
$package_ensure = $mysql::bindings::python_package_ensure,
17+
$package_name = $mysql::bindings::python_package_name
1818
) inherits mysql {
1919

2020
package { 'python-mysqldb':

manifests/ruby.pp renamed to manifests/bindings/ruby.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Class: mysql::ruby
1+
# Class: mysql::bindings::ruby
22
#
33
# installs the ruby bindings for mysql
44
#
@@ -13,10 +13,10 @@
1313
#
1414
# Sample Usage:
1515
#
16-
class mysql::ruby (
17-
$package_ensure = 'present',
18-
$package_name = $mysql::ruby_package_name,
19-
$package_provider = $mysql::ruby_package_provider
16+
class mysql::bindings::ruby (
17+
$package_ensure = $mysql::bindings::ruby_package_ensure,
18+
$package_name = $mysql::bindings::ruby_package_name,
19+
$package_provider = $mysql::bindings::ruby_package_provider
2020
) inherits mysql {
2121

2222
package{ 'ruby_mysql':

manifests/client/install.pp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class mysql::client::install(
2+
$package_name = $mysql::client_package_name,
3+
$package_ensure = $mysql::client_package_ensure
4+
) {
5+
6+
package { 'mysql_client':
7+
ensure => $package_ensure,
8+
name => $package_name,
9+
}
10+
11+
}

manifests/init.pp

+6-30
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#
1111
# [*client_package_name*] - The name of the mysql client package.
1212
#
13+
# [*client_package_ensure*] - State of the client package.
14+
#
1315
# [*config_file*] - The location of the server config file
1416
#
1517
# [*config_template*] - The template to use to generate my.cnf.
@@ -22,8 +24,6 @@
2224
#
2325
# [*etc_root_password*] - Whether or not to add the mysql root password to /etc/my.cnf
2426
#
25-
# [*java_package_name*] - The name of the java package containing the java connector
26-
#
2727
# [*log_error*] - Where to log errors
2828
#
2929
# [*manage_config_file*] - if the config file should be managed (default: true)
@@ -38,10 +38,6 @@
3838
#
3939
# [*package_name*] - legacy parameter used to specify the client package. Should not be used going forward
4040
#
41-
# [*perl_package_name*] - The name of the perl mysql package to install
42-
#
43-
# [*perl_package_provider*] - The installation suite to use when installing the perl package.
44-
#
4541
# [*php_package_name*] - The name of the phpmysql package to install
4642
#
4743
# [*pidfile*] - The location mysql will expect the pidfile to be, and will put it when starting the service.
@@ -50,19 +46,12 @@
5046
#
5147
# [*purge_conf_dir*] - Value fed to recurse and purge parameters of the /etc/mysql/conf.d resource
5248
#
53-
# [*python_package_name*] - The name of the python mysql package to install
54-
#
5549
# [*restart*] - Whether to restart mysqld (true/false)
5650
#
5751
# [*root_group*] - Use specified group for root-owned files
5852
#
5953
# [*root_password*] - The root MySQL password to use
6054
#
61-
# [*ruby_package_name*] - The name of the ruby mysql package to install
62-
#
63-
# [*ruby_package_provider*] - The installation suite to use when installing the ruby package.
64-
# FreeBSD Does not use this.
65-
#
6655
# [*server_package_ensure*] - ensure value for server packages.
6756
#
6857
# [*server_package_name*] - The name of the server package to install
@@ -91,33 +80,27 @@
9180
$basedir = $mysql::params::basedir,
9281
$bind_address = $mysql::params::bind_address,
9382
$client_package_name = $mysql::params::client_package_name,
83+
$client_package_ensure = $mysql::params::client_package_ensure,
9484
$config_file = $mysql::params::config_file,
9585
$config_template = $mysql::params::config_template,
9686
$datadir = $mysql::params::datadir,
9787
$tmpdir = $mysql::params::tmpdir,
9888
$default_engine = $mysql::params::default_engine,
9989
$etc_root_password = $mysql::params::etc_root_password,
100-
$java_package_name = $mysql::params::java_package_name,
10190
$log_error = $mysql::params::log_error,
10291
$manage_config_file = true,
10392
$manage_service = $mysql::params::manage_service,
10493
$max_allowed_packet = $mysql::params::max_allowed_packet,
10594
$old_root_password = $mysql::params::old_root_password,
10695
$package_ensure = $mysql::params::package_ensure,
107-
$package_name = undef,
108-
$perl_package_name = $mysql::params::perl_package_name,
109-
$perl_package_provider = $mysql::params::perl_package_provider,
11096
$php_package_name = $mysql::params::php_package_name,
11197
$pidfile = $mysql::params::pidfile,
11298
$port = $mysql::params::port,
11399
$purge_conf_dir = $mysql::params::purge_conf_dir,
114-
$python_package_name = $mysql::params::python_package_name,
115100
$max_connections = $mysql::params::max_connections,
116101
$restart = $mysql::params::restart,
117102
$root_group = $mysql::params::root_group,
118103
$root_password = $mysql::params::root_password,
119-
$ruby_package_name = $mysql::params::ruby_package_name,
120-
$ruby_package_provider = $mysql::params::ruby_package_provider,
121104
$server_package_name = $mysql::params::server_package_name,
122105
$service_name = $mysql::params::service_name,
123106
$service_provider = $mysql::params::service_provider,
@@ -127,16 +110,9 @@
127110
$ssl_cert = $mysql::params::ssl_cert,
128111
$ssl_key = $mysql::params::ssl_key
129112
) inherits mysql::params{
130-
if $package_name {
131-
warning('Using $package_name has been deprecated in favor of $client_package_name and will be removed.')
132-
$client_package_name_real = $package_name
133-
} else {
134-
$client_package_name_real = $client_package_name
135-
}
136-
package { 'mysql_client':
137-
ensure => $package_ensure,
138-
name => $client_package_name_real,
139-
}
113+
114+
include '::mysql::client::install'
115+
include '::mysql::bindings'
140116

141117
Class['mysql::config'] -> Mysql::Db <| |>
142118

0 commit comments

Comments
 (0)