From c0f0e7c2bf4b54142c51906f9af75fd178185e20 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 7 Nov 2008 15:01:54 +0000 Subject: merged with puzzle --- files/conf.d/CentOS/ssl_defaults.inc | 2 - manifests/defaultphpdirs.pp | 14 +++++++ manifests/defines.pp | 73 ++++++++++++++++++++++++++++++++++++ templates/vhosts/php/CentOS.erb | 30 +++++++++++++++ 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 manifests/defaultphpdirs.pp create mode 100644 templates/vhosts/php/CentOS.erb diff --git a/files/conf.d/CentOS/ssl_defaults.inc b/files/conf.d/CentOS/ssl_defaults.inc index 6b22d57..5cc663f 100644 --- a/files/conf.d/CentOS/ssl_defaults.inc +++ b/files/conf.d/CentOS/ssl_defaults.inc @@ -26,7 +26,6 @@ SSLCipherSuite HIGH:MEDIUM:!ADH:-SSLv2 # certificate can be generated using the genkey(1) command. #SSLCertificateFile /etc/pki/tls/certs/localhost.crt - # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if @@ -34,7 +33,6 @@ SSLCipherSuite HIGH:MEDIUM:!ADH:-SSLv2 # both in parallel (to also allow the use of DSA ciphers, etc.) #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key - # Server Certificate Chain: # Point SSLCertificateChainFile at a file containing the # concatenation of PEM encoded CA certificates which form the diff --git a/manifests/defaultphpdirs.pp b/manifests/defaultphpdirs.pp new file mode 100644 index 0000000..fdbe8a5 --- /dev/null +++ b/manifests/defaultphpdirs.pp @@ -0,0 +1,14 @@ +# manifests/defaultphpdirs.pp + +class apache::defaultphpdirs { + file{'/var/www/upload_tmp_dir': + ensure => directory, + require => Package['apache'], + owner => root, group => 0, mode => 0755; + } + file{'/var/www/session.save_path': + ensure => directory, + require => Package['apache'], + owner => root, group => 0, mode => 0755; + } +} diff --git a/manifests/defines.pp b/manifests/defines.pp index d6d1ec0..1cff93c 100644 --- a/manifests/defines.pp +++ b/manifests/defines.pp @@ -137,3 +137,76 @@ define apache::gentoo::module( owner => root, group => 0, mode => 0644; } } + +define apache::vhost::php::standard( + $domain = 'absent', + $domainalias = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $mode = 0644, + $apache_user = apache, + $apache_group = 0, + $apache_mode = 0640, + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $additional_options = 'absent', + $mod_security = 'true' +){ + $servername = $domain ? { + 'absent' => $name, + default => $domain + } + $serveralias = $domainalias ? { + 'absent' => '', + default => $domainalias + } + $real_path = $path ? { + 'absent' => "/var/www/${name}", + default => "${path}" + } + $documentroot = "${real_path}/www" + $logdir = "${real_path}/logs" + + file{ [ "$real_path", "$documentroot", "$logdir" ] : + ensure => directory, + owner => $owner, group => $group, mode => $mode; + } + + case $php_upload_tmp_dir { + 'absent': { + include apache::defaultphpdirs + $upload_tmp_dir = "/var/www/upload_tmp_dir/${name}" + } + default: { + $upload_tmp_dir = $php_upload_tmp_dir + } + } + file{"$upload_tmp_dir": + ensure => directory, + owner => $apache_user, group => $apache_group, mode => $apache_mode; + } + + case $php_session_save_path { + 'absent': { + include apache::defaultphpdirs + $session_save_path = "/var/www/session.save_path/${name}" + } + default: { + $session_save_path = $php_session_save_path + } + } + file{"$session_save_path": + ensure => directory, + owner => $apache_user, group => $apache_group, mode => $apache_mode; + } + + + file{"/etc/httpd/vhosts.d/${servername}.conf": + content => template("apache/vhosts/php/${operatingsystem}.erb"), + notify => Service['apache'], + owner => root, group => 0, mode => 0644; + } +} + diff --git a/templates/vhosts/php/CentOS.erb b/templates/vhosts/php/CentOS.erb new file mode 100644 index 0000000..a7f21b6 --- /dev/null +++ b/templates/vhosts/php/CentOS.erb @@ -0,0 +1,30 @@ + + Include conf.d/defaults.inc + + ServerName <%= servername %> + <%- unless serveralias.to_s.empty? then -%> + ServerAlias <%= serveralias %> + <%- end -%> + DocumentRoot <%= documentroot %> + + ErrorLog <%= logdir %>/error_log + CustomLog <%= logdir %>/access_log combined + + "> + AllowOverride <%= allow_override %> + + php_admin_flag engine on + php_admin_value open_basedir <%= documentroot %>:<%= upload_tmp_dir %>:<%=session_save_path %> + php_admin_value upload_tmp_dir <%= upload_tmp_dir %> + php_admin_value session.save_path <%=session_save_path %> + + + + SecRuleEngine <%= if mod_security.to_s == 'true' then "On" else "Off" end %> + + + + <%- unless additional_options == 'absent' then -%> + <%= additional_options %> + <%- end -%> + -- cgit v1.2.3