From 435443dfe8c30b96c016ab75ce55bb601edb421e Mon Sep 17 00:00:00 2001 From: Phil Fenstermacher Date: Mon, 7 Nov 2016 23:14:46 -0500 Subject: [PATCH] Manage apache/PHP configurations on Debian and RHEL systems --- manifests/apache_config.pp | 29 +++++++++++++++++++++++++++++ manifests/init.pp | 12 ++++++++++++ manifests/params.pp | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 manifests/apache_config.pp diff --git a/manifests/apache_config.pp b/manifests/apache_config.pp new file mode 100644 index 00000000..291c9407 --- /dev/null +++ b/manifests/apache_config.pp @@ -0,0 +1,29 @@ +# Install and configure php apache settings +# +# === Parameters +# +# [*inifile*] +# The path to the ini php-apache ini file +# +# [*settings*] +# Hash with nested hash of key => value to set in inifile +# +class php::apache_config( + $inifile = $::php::params::apache_inifile, + $settings = {} +) inherits ::php::params { + + if $caller_module_name != $module_name { + warning('php::apache_config is private') + } + + validate_absolute_path($inifile) + validate_hash($settings) + + $real_settings = deep_merge($settings, hiera_hash('php::apache::settings', {})) + + ::php::config { 'apache': + file => $inifile, + config => $real_settings, + } +} diff --git a/manifests/init.pp b/manifests/init.pp index d26d2269..9bc9c701 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,6 +54,9 @@ # [*phpunit*] # Install phpunit # +# [*apache_config*] +# Manage apache's mod_php configuration +# # [*environment*] # Environment variables for settings such as http_proxy, https_proxy, or ftp_proxy. # These are passed through to the underlying exec(s), so it follows the same format @@ -119,6 +122,7 @@ $pear = true, $pear_ensure = $::php::params::pear_ensure, $phpunit = false, + $apache_config = false, $environment = undef, $manage_curl = true, $extensions = {}, @@ -142,6 +146,7 @@ validate_bool($ext_tool_enabled) validate_string($pear_ensure) validate_bool($phpunit) + validate_bool($apache_config) validate_bool($manage_curl) validate_hash($extensions) validate_hash($settings) @@ -233,6 +238,13 @@ class { '::php::phpunit': } -> Anchor['php::end'] } + if $apache_config { + Anchor['php::begin'] -> + class { '::php::apache_config': + settings => $real_settings, + } -> + Anchor['php::end'] + } create_resources('::php::extension', $real_extensions, { require => Class['::php::cli'], diff --git a/manifests/params.pp b/manifests/params.pp index dc31c681..df29edd9 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -32,6 +32,7 @@ $fpm_service_name = $php::globals::fpm_service_name $fpm_user = 'www-data' $fpm_group = 'www-data' + $apache_inifile = "${config_root}/apache2/php.ini" $embedded_package_suffix = 'embed' $embedded_inifile = "${config_root}/embed/php.ini" $package_prefix = $php::globals::package_prefix @@ -115,6 +116,7 @@ $fpm_service_name = 'php-fpm' $fpm_user = 'apache' $fpm_group = 'apache' + $apache_inifile = '/etc/php.ini' $embedded_package_suffix = 'embedded' $embedded_inifile = '/etc/php.ini' $package_prefix = 'php-'