Skip to content

Commit

Permalink
Merge pull request #187 from RsrchBoy/topic/perl
Browse files Browse the repository at this point in the history
add mysql::perl helper class
  • Loading branch information
apenney committed Jul 2, 2013
2 parents 1b5dc3c + beeb261 commit f3e5c89
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This module is based on work by David Schmitt. The following contributor have co
* Matthias Pigulla
* William Van Hevelingen
* Michael Arnold
* Chris Weyl

## Usage

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

class { 'mysql::java': }


### mysql::perl
Installs mysql bindings for perl

class { 'mysql::perl': }

### mysql::php
Installs mysql bindings for php

Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#
# [*package_name*] - legacy parameter used to specify the client package. Should not be used going forward
#
# [*perl_package_name*] - The name of the perl mysql package to install
#
# [*perl_package_provider*] - The installation suite to use when installing the perl package.
#
# [*php_package_name*] - The name of the phpmysql package to install
#
# [*pidfile*] - The location mysql will expect the pidfile to be, and will put it when starting the service.
Expand Down Expand Up @@ -101,6 +105,8 @@
$old_root_password = $mysql::params::old_root_password,
$package_ensure = $mysql::params::package_ensure,
$package_name = undef,
$perl_package_name = $mysql::params::perl_package_name,
$perl_package_provider = $mysql::params::perl_package_provider,
$php_package_name = $mysql::params::php_package_name,
$pidfile = $mysql::params::pidfile,
$port = $mysql::params::port,
Expand Down
6 changes: 6 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
$tmpdir = '/tmp'
$java_package_name = 'mysql-connector-java'
$log_error = '/var/log/mysqld.log'
$perl_package_name = 'perl-DBD-MySQL'
$php_package_name = 'php-mysql'
$pidfile = '/var/run/mysqld/mysqld.pid'
$python_package_name = 'MySQL-python'
Expand Down Expand Up @@ -86,6 +87,7 @@
/(SLES|SLED)/ => 'ruby-mysql',
}
$python_package_name = 'python-mysql'
$perl_package_name = 'perl-DBD-mysql'
$java_package_name = 'mysql-connector-java'
$root_group = 'root'
$ssl_ca = '/etc/mysql/cacert.pem'
Expand All @@ -104,6 +106,7 @@
$pidfile = '/var/run/mysqld/mysqld.pid'
$config_file = '/etc/mysql/my.cnf'
$log_error = '/var/log/mysql/error.log'
$perl_package_name = 'libdbd-mysql-perl'
$ruby_package_name = 'libmysql-ruby'
$python_package_name = 'python-mysqldb'
$php_package_name = 'php5-mysql'
Expand All @@ -125,6 +128,7 @@
$pidfile = '/var/db/mysql/mysql.pid'
$config_file = '/var/db/mysql/my.cnf'
$log_error = "/var/db/mysql/${::hostname}.err"
$perl_package_name = 'p5-DBD-mysql'
$ruby_package_name = 'ruby-mysql'
$ruby_package_provider = 'gem'
$python_package_name = 'databases/py-MySQLdb'
Expand All @@ -148,6 +152,8 @@
$socket = '/var/lib/mysql/mysql.sock'
$config_file = '/etc/my.cnf'
$log_error = '/var/log/mysqld.log'
# XXX validate...
$perl_package_name = 'perl-DBD-MySQL'
$ruby_package_name = 'ruby-mysql'
$ruby_package_provider = 'gem'
$python_package_name = 'MySQL-python'
Expand Down
28 changes: 28 additions & 0 deletions manifests/perl.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Class: mysql::perl
#
# installs the perl bindings for mysql
#
# Parameters:
# [*package_ensure*] - Ensure state for package. Can be specified as version.
# [*package_name*] - name of package
# [*package_provider*] - The provider to use to install the package
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
class mysql::perl (
$package_ensure = 'present',
$package_name = $mysql::perl_package_name,
$package_provider = $mysql::perl_package_provider
) inherits mysql {

package{ 'perl_mysql':
ensure => $package_ensure,
name => $package_name,
provider => $package_provider,
}

}
62 changes: 62 additions & 0 deletions spec/classes/mysql_perl_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
require 'spec_helper'

describe 'mysql::perl' do

describe 'on a debian based os' do
let :facts do
{ :osfamily => 'Debian'}
end
it { should contain_package('perl_mysql').with(
:name => 'libdbd-mysql-perl',
:ensure => 'present',
# TODO is this what we want? does this actually work
# if the provider is blank
:provider => ''
)}
end

describe 'on a freebsd based os' do
let :facts do
{ :osfamily => 'FreeBSD'}
end
it { should contain_package('perl_mysql').with(
:name => 'p5-DBD-mysql',
:ensure => 'present',
:provider => ''
)}
end

describe 'on a redhat based os' do
let :facts do
{:osfamily => 'Redhat'}
end
it { should contain_package('perl_mysql').with(
:name => 'perl-DBD-MySQL',
:ensure => 'present',
:provider => ''
)}
describe 'when parameters are supplied' do
let :params do
{:package_ensure => 'latest',
:package_provider => 'zypper',
:package_name => 'mysql_perl'}
end
it { should contain_package('perl_mysql').with(
:name => 'mysql_perl',
:ensure => 'latest',
:provider => 'zypper'
)}
end
end

describe 'on any other os' do
let :facts do
{:osfamily => 'foo'}
end

it 'should fail' do
expect { subject }.to raise_error(/Unsupported osfamily: foo/)
end
end

end
1 change: 1 addition & 0 deletions tests/perl.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include mysql::perl

0 comments on commit f3e5c89

Please sign in to comment.