Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mysql::perl helper class #187

Merged
merged 5 commits into from
Jul 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -32,6 +32,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 @@ -92,6 +96,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 @@ -42,6 +42,7 @@
$datadir = '/var/lib/mysql'
$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 @@ -83,6 +84,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 @@ -100,6 +102,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 @@ -120,6 +123,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 @@ -142,6 +146,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