Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 02c4da48a577d78937da0c67403f30be41d5d54b 1 parent af4b8bf
@hunner authored
View
4 manifests/params.pp
@@ -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
20 manifests/php.pp
@@ -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,
+ }
+
+}
View
54 spec/classes/mysql_php_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.