Skip to content

Commit 6cef2e8

Browse files
committed
2 parents ead86b5 + f3e5c89 commit 6cef2e8

File tree

6 files changed

+112
-1
lines changed

6 files changed

+112
-1
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ This module is based on work by David Schmitt. The following contributor have co
4444
* Matthias Pigulla
4545
* William Van Hevelingen
4646
* Michael Arnold
47+
* Chris Weyl
4748

4849
## Usage
4950

@@ -56,7 +57,12 @@ Installs the mysql-client package.
5657
Installs mysql bindings for java.
5758

5859
class { 'mysql::java': }
59-
60+
61+
### mysql::perl
62+
Installs mysql bindings for perl
63+
64+
class { 'mysql::perl': }
65+
6066
### mysql::php
6167
Installs mysql bindings for php
6268

manifests/init.pp

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
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+
#
4145
# [*php_package_name*] - The name of the phpmysql package to install
4246
#
4347
# [*pidfile*] - The location mysql will expect the pidfile to be, and will put it when starting the service.
@@ -101,6 +105,8 @@
101105
$old_root_password = $mysql::params::old_root_password,
102106
$package_ensure = $mysql::params::package_ensure,
103107
$package_name = undef,
108+
$perl_package_name = $mysql::params::perl_package_name,
109+
$perl_package_provider = $mysql::params::perl_package_provider,
104110
$php_package_name = $mysql::params::php_package_name,
105111
$pidfile = $mysql::params::pidfile,
106112
$port = $mysql::params::port,
@@ -131,4 +137,6 @@
131137
name => $client_package_name_real,
132138
}
133139

140+
Class['mysql::config'] -> Mysql::Db <| |>
141+
134142
}

manifests/params.pp

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
$tmpdir = '/tmp'
5353
$java_package_name = 'mysql-connector-java'
5454
$log_error = '/var/log/mysqld.log'
55+
$perl_package_name = 'perl-DBD-MySQL'
5556
$php_package_name = 'php-mysql'
5657
$pidfile = '/var/run/mysqld/mysqld.pid'
5758
$python_package_name = 'MySQL-python'
@@ -94,6 +95,7 @@
9495
/(SLES|SLED)/ => 'ruby-mysql',
9596
}
9697
$python_package_name = 'python-mysql'
98+
$perl_package_name = 'perl-DBD-mysql'
9799
$java_package_name = 'mysql-connector-java'
98100
$root_group = 'root'
99101
$ssl_ca = '/etc/mysql/cacert.pem'
@@ -112,6 +114,7 @@
112114
$pidfile = '/var/run/mysqld/mysqld.pid'
113115
$config_file = '/etc/mysql/my.cnf'
114116
$log_error = '/var/log/mysql/error.log'
117+
$perl_package_name = 'libdbd-mysql-perl'
115118
$ruby_package_name = 'libmysql-ruby'
116119
$python_package_name = 'python-mysqldb'
117120
$php_package_name = 'php5-mysql'
@@ -133,6 +136,7 @@
133136
$pidfile = '/var/db/mysql/mysql.pid'
134137
$config_file = '/var/db/mysql/my.cnf'
135138
$log_error = "/var/db/mysql/${::hostname}.err"
139+
$perl_package_name = 'p5-DBD-mysql'
136140
$ruby_package_name = 'ruby-mysql'
137141
$ruby_package_provider = 'gem'
138142
$python_package_name = 'databases/py-MySQLdb'
@@ -156,6 +160,8 @@
156160
$socket = '/var/lib/mysql/mysql.sock'
157161
$config_file = '/etc/my.cnf'
158162
$log_error = '/var/log/mysqld.log'
163+
# XXX validate...
164+
$perl_package_name = 'perl-DBD-MySQL'
159165
$ruby_package_name = 'ruby-mysql'
160166
$ruby_package_provider = 'gem'
161167
$python_package_name = 'MySQL-python'

manifests/perl.pp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Class: mysql::perl
2+
#
3+
# installs the perl bindings for mysql
4+
#
5+
# Parameters:
6+
# [*package_ensure*] - Ensure state for package. Can be specified as version.
7+
# [*package_name*] - name of package
8+
# [*package_provider*] - The provider to use to install the package
9+
#
10+
# Actions:
11+
#
12+
# Requires:
13+
#
14+
# Sample Usage:
15+
#
16+
class mysql::perl (
17+
$package_ensure = 'present',
18+
$package_name = $mysql::perl_package_name,
19+
$package_provider = $mysql::perl_package_provider
20+
) inherits mysql {
21+
22+
package{ 'perl_mysql':
23+
ensure => $package_ensure,
24+
name => $package_name,
25+
provider => $package_provider,
26+
}
27+
28+
}

spec/classes/mysql_perl_spec.rb

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
require 'spec_helper'
2+
3+
describe 'mysql::perl' do
4+
5+
describe 'on a debian based os' do
6+
let :facts do
7+
{ :osfamily => 'Debian'}
8+
end
9+
it { should contain_package('perl_mysql').with(
10+
:name => 'libdbd-mysql-perl',
11+
:ensure => 'present',
12+
# TODO is this what we want? does this actually work
13+
# if the provider is blank
14+
:provider => ''
15+
)}
16+
end
17+
18+
describe 'on a freebsd based os' do
19+
let :facts do
20+
{ :osfamily => 'FreeBSD'}
21+
end
22+
it { should contain_package('perl_mysql').with(
23+
:name => 'p5-DBD-mysql',
24+
:ensure => 'present',
25+
:provider => ''
26+
)}
27+
end
28+
29+
describe 'on a redhat based os' do
30+
let :facts do
31+
{:osfamily => 'Redhat'}
32+
end
33+
it { should contain_package('perl_mysql').with(
34+
:name => 'perl-DBD-MySQL',
35+
:ensure => 'present',
36+
:provider => ''
37+
)}
38+
describe 'when parameters are supplied' do
39+
let :params do
40+
{:package_ensure => 'latest',
41+
:package_provider => 'zypper',
42+
:package_name => 'mysql_perl'}
43+
end
44+
it { should contain_package('perl_mysql').with(
45+
:name => 'mysql_perl',
46+
:ensure => 'latest',
47+
:provider => 'zypper'
48+
)}
49+
end
50+
end
51+
52+
describe 'on any other os' do
53+
let :facts do
54+
{:osfamily => 'foo'}
55+
end
56+
57+
it 'should fail' do
58+
expect { subject }.to raise_error(/Unsupported osfamily: foo/)
59+
end
60+
end
61+
62+
end

tests/perl.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include mysql::perl

0 commit comments

Comments
 (0)