Permalink
Browse files

Add php support

PHP libraries are required by many apps. This class assumes 'normal'
names for these packages, but allows other packages names to be passed
for variances such as 'php53-mysql' on RedHat and FreeBSD.
  • Loading branch information...
1 parent af4b8bf commit 02c4da48a577d78937da0c67403f30be41d5d54b @hunner committed Jan 4, 2013
Showing with 78 additions and 0 deletions.
  1. +4 −0 manifests/params.pp
  2. +20 −0 manifests/php.pp
  3. +54 −0 spec/classes/mysql_php_spec.rb
View
@@ -41,6 +41,7 @@
$ruby_package_name = 'ruby-mysql'
$ruby_package_provider = 'gem'
$python_package_name = 'MySQL-python'
+ $php_package_name = 'php-mysql'
$java_package_name = 'mysql-connector-java'
$root_group = 'root'
$ssl_ca = '/etc/mysql/cacert.pem'
@@ -60,6 +61,7 @@
$log_error = '/var/log/mysql/error.log'
$ruby_package_name = 'libmysql-ruby'
$python_package_name = 'python-mysqldb'
+ $php_package_name = 'php5-mysql'
$java_package_name = 'libmysql-java'
$root_group = 'root'
$ssl_ca = '/etc/mysql/cacert.pem'
@@ -80,6 +82,7 @@
$ruby_package_name = 'ruby-mysql'
$ruby_package_provider = 'gem'
$python_package_name = 'databases/py-MySQLdb'
+ $php_package_name = 'php5-mysql'
$java_package_name = 'databases/mysql-connector-java'
$root_group = 'wheel'
$ssl_ca = undef
@@ -101,6 +104,7 @@
$ruby_package_name = 'ruby-mysql'
$ruby_package_provider = 'gem'
$python_package_name = 'MySQL-python'
+ $php_package_name = 'php-mysql'
$java_package_name = 'mysql-connector-java'
$root_group = 'root'
$ssl_ca = '/etc/mysql/cacert.pem'
View
@@ -0,0 +1,20 @@
+# Class: mysql::php
+#
+# This class installs the php libs for mysql.
+#
+# Parameters:
+# [*ensure*] - ensure state for package.
+# can be specified as version.
+# [*packagee*] - name of package
+#
+class mysql::php(
+ $package_name = $mysql::params::php_package_name,
+ $package_ensure = 'present'
+) inherits mysql::params {
+
+ package { 'php-mysql':
+ ensure => $package_ensure,
+ name => $package_name,
+ }
+
+}
@@ -0,0 +1,54 @@
+require 'spec_helper'
+
+describe 'mysql::php' do
+
+ describe 'on a debian based os' do
+ let :facts do
+ { :osfamily => 'Debian'}
+ end
+ it { should contain_package('php-mysql').with(
+ :name => 'php5-mysql',
+ :ensure => 'present'
+ )}
+ end
+
+ describe 'on a freebsd based os' do
+ let :facts do
+ { :osfamily => 'FreeBSD'}
+ end
+ it { should contain_package('php-mysql').with(
+ :name => 'php5-mysql',
+ :ensure => 'present'
+ )}
+ end
+
+ describe 'on a redhat based os' do
+ let :facts do
+ {:osfamily => 'Redhat'}
+ end
+ it { should contain_package('php-mysql').with(
+ :name => 'php-mysql',
+ :ensure => 'present'
+ )}
+ describe 'when parameters are supplied' do
+ let :params do
+ {:package_ensure => 'latest', :package_name => 'php53-mysql'}
+ end
+ it { should contain_package('php-mysql').with(
+ :name => 'php53-mysql',
+ :ensure => 'latest'
+ )}
+ 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

0 comments on commit 02c4da4

Please sign in to comment.