Skip to content

Commit

Permalink
Adding the ability to load other php5-centric packages, including a d…
Browse files Browse the repository at this point in the history
…efault list with add/remove similar to the apache2 modules.
  • Loading branch information
sharumpe committed Dec 9, 2014
1 parent 6efce7f commit a35bb0d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@

# Default modules for mod.pp
$a2modDefaults = [ 'actions','alias','auth_basic','authn_file','authz_host','authz_groupfile','authz_user','autoindex','dir','env','expires','include','log_config','mime','negotiation','setenvif','reqtimeout','authn_core','authz_core' ]

# Default packages for php5
$phpPackageDefaults = [ 'bz2','calendar','curl','gd','ldap','mbstring','mcrypt','mysql','openssl','pear','phar','zip' ]
}
43 changes: 37 additions & 6 deletions manifests/php.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
class apache2::php
(
$phpMemoryLimit = undef,
$phpErrorLog = "/var/log/apache2/php-error_log",
$phpExposePhp = "off",
$phpTimezone = "America/Los_Angeles",
$appDirs = [],
$appLocs = []
$phpMemoryLimit = undef,
$phpErrorLog = "/var/log/apache2/php-error_log",
$phpExposePhp = "off",
$phpTimezone = "America/Los_Angeles",
$useDefaultPhpPackages = true,
$loadPhpPackages = [],
$unloadPhpPackages = [],
$appDirs = [],
$appLocs = []
)
{
include apache2::params
Expand All @@ -15,6 +18,9 @@
validate_string( $phpErrorLog )
validate_re( $phpExposePhp, "^(on|off)" )
validate_string( $phpTimezone )
validate_bool( $useDefaultPhpPackages )
validate_array( $loadPhpPackages )
validate_array( $unloadPhpPackages )
validate_array( $appDirs )
validate_array( $appLocs )

Expand All @@ -28,6 +34,30 @@
require => Package[ $params::phpPackageName ],
}

# Default PHP-specific packages
# See params::phpPackageDefaults for default package list
if ( is_array( $loadPhpPackages ) ) { $phpPackageLoad = $loadPhpPackages }
else { $phpPackageLoad = [] }

if ( is_array( $unloadPhpPackages ) ) { $phpPackageUnload = $unloadPhpPackages }
else { $phpPackageUnload = [] }

if ( is_bool( $useDefaultPhpPackages ) and $useDefaultPhpPackages ) { $phpPackageDefaultLoad = $params::phpPackageDefaults }
else { $phpPackageDefaultLoad = [] }

# Add whatever extra packages were asked for
apache2::php::package { $phpPackageDefaultLoad :
ensure => latest,
}
apache2::php::package { $phpPackageLoad :
ensure => latest,
}

# Remove whatever packages we were asked to
apache2::php::package { $phpPackageUnload :
ensure => purged,
}

# Pick the template path we're going to use
$mod_path = get_module_path('apache2')
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::phpConfigPath.erb"
Expand All @@ -49,4 +79,5 @@
if ( is_array( $appLocs ) and size( $appLocs ) > 0 ) {
apache2::php::addAppLoc{ $appLocs : }
}

}
25 changes: 25 additions & 0 deletions manifests/php/package.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
define apache2::php::package
(
$packageName = $name,
$ensure = latest
)
{
include apache2::params

validate_string( $packageName )
validate_string( $ensure )

# if the name doesn't already start with php5-, make it so.
if ( $packageName =~ /^php5-/ ) {
$fixedPackageName = $packageName
}
else {
$fixedPackageName = "php5-$packageName"
}

package { $fixedPackageName :
ensure => $ensure,
require => Package[ $params::phpPackageName ],
}

}

0 comments on commit a35bb0d

Please sign in to comment.