diff options
Diffstat (limited to 'manifests/vhost')
-rw-r--r-- | manifests/vhost/file.pp | 85 | ||||
-rw-r--r-- | manifests/vhost/file/documentrootdir.pp | 24 | ||||
-rw-r--r-- | manifests/vhost/file/documentrootfile.pp | 25 | ||||
-rw-r--r-- | manifests/vhost/modperl.pp | 94 | ||||
-rw-r--r-- | manifests/vhost/php/drupal.pp | 86 | ||||
-rw-r--r-- | manifests/vhost/php/joomla.pp | 100 | ||||
-rw-r--r-- | manifests/vhost/php/simplemachine.pp | 90 | ||||
-rw-r--r-- | manifests/vhost/php/standard.pp | 88 | ||||
-rw-r--r-- | manifests/vhost/php/webapp.pp | 103 | ||||
-rw-r--r-- | manifests/vhost/php/wordpress.pp | 85 | ||||
-rw-r--r-- | manifests/vhost/phpdirs.pp | 49 | ||||
-rw-r--r-- | manifests/vhost/static.pp | 61 | ||||
-rw-r--r-- | manifests/vhost/template.pp | 107 | ||||
-rw-r--r-- | manifests/vhost/webdav.pp | 75 | ||||
-rw-r--r-- | manifests/vhost/webdir.pp | 106 |
15 files changed, 1178 insertions, 0 deletions
diff --git a/manifests/vhost/file.pp b/manifests/vhost/file.pp new file mode 100644 index 0000000..c31420e --- /dev/null +++ b/manifests/vhost/file.pp @@ -0,0 +1,85 @@ +# htpasswd_file: wether to deploy a passwd for this vhost or not +# - absent: ignore (default) +# - nodeploy: htpasswd file isn't deployed by this mechanism +# - else: try to deploy the file +# +# htpasswd_path: where to deploy the passwd file +# - absent: standardpath (default) +# - else: path to deploy +# +define apache::vhost::file( + $ensure = present, + $vhost_source = 'absent', + $vhost_destination = 'absent', + $content = 'absent', + $do_includes = false, + $htpasswd_file = 'absent', + $htpasswd_path = 'absent' +){ + $vhosts_dir = $operatingsystem ? { + centos => "$apache::centos::config_dir/vhosts.d/", + gentoo => "$apache::gentoo::config_dir/vhosts.d/", + debian => "$apache::debian::config_dir/vhosts.d/", + ubuntu => "$apache::ubuntu::config_dir/vhosts.d/", + openbsd => "$apache::openbsd::config_dir/vhosts.d/", + default => '/etc/apache2/vhosts.d/', + } + $real_vhost_destination = $vhost_destination ? { + 'absent' => "$vhosts_dir/$name.conf", + default => $vhost_destination, + } + file{"${name}.conf": + ensure => $ensure, + path => $real_vhost_destination, + require => File[vhosts_dir], + notify => Service[apache], + owner => root, group => 0, mode => 0644; + } + if $do_includes { + include apache::includes + } + case $content { + 'absent': { + $real_vhost_source = $vhost_source ? { + 'absent' => [ + "puppet://$server/files/apache/vhosts.d/$fqdn/$name.conf", + "puppet://$server/files/apache/vhosts.d/$apache_cluster_node/$name.conf", + "puppet://$server/files/apache/vhosts.d/$operatingsystem.$lsbdistcodename/$name.conf", + "puppet://$server/files/apache/vhosts.d/$operatingsystem/$name.conf", + "puppet://$server/files/apache/vhosts.d/$name.conf", + "puppet://$server/apache/vhosts.d/$name.conf", + "puppet://$server/apache/vhosts.d/$operatingsystem.$lsbdistcodename/$name.conf", + "puppet://$server/apache/vhosts.d/$operatingsystem/$name.conf", + "puppet://$server/apache/vhosts.d/$name.conf" + ], + default => "puppet://$server/$vhost_source", + } + File["${name}.conf"]{ + source => $real_vhost_source, + } + } + default: { + File["${name}.conf"]{ + content => $content, + } + } + } + case $htpasswd_file { + 'absent','nodeploy': { info("don't deploy a htpasswd file for ${name") } + default: { + if $htpasswd_path == 'absent' { + $real_htpasswd_path = "/var/www/htpasswds/$name" + } else { + $real_htpasswd_path = $htpasswd_path + } + file{$real_htpasswd_path: + ensure => $ensure, + source => [ "puppet://$server/files/apache/htpasswds/$fqdn/$name", + "puppet://$server/files/apache/htpasswds/$apache_cluster_node/$name", + "puppet://$server/files/apache/htpasswds/$name" ], + owner => root, group => 0, mode => 0644; + } + } + } +} + diff --git a/manifests/vhost/file/documentrootdir.pp b/manifests/vhost/file/documentrootdir.pp new file mode 100644 index 0000000..425406a --- /dev/null +++ b/manifests/vhost/file/documentrootdir.pp @@ -0,0 +1,24 @@ +define apache::vhost::file::documentrootdir( + $ensure = directory, + $documentroot, + $filename, + $thedomain, + $owner = 'root', + $group = '0', + $mode = 440 +){ + file{"$documentroot/$filename": + require => Apache::Vhost::Webdir["$thedomain"], + owner => $owner, group => $group, mode => $mode; + } + if $ensure != 'absent' { + File["$documentroot/$filename"]{ + ensure => directory, + } + } else { + File["$documentroot/$filename"]{ + ensure => $ensure, + } + } +} + diff --git a/manifests/vhost/file/documentrootfile.pp b/manifests/vhost/file/documentrootfile.pp new file mode 100644 index 0000000..c9daf9c --- /dev/null +++ b/manifests/vhost/file/documentrootfile.pp @@ -0,0 +1,25 @@ +define apache::vhost::file::documentrootfile( + $documentroot, + $filename, + $thedomain, + $owner='root', + $group='0', + $mode=440 +){ + file{"$documentroot/$filename": + source => [ "puppet://$server/files/apache/vhost_varieties/$fqdn/$thedomain/$filename", + "puppet://$server/files/apache/vhost_varieties/$apache_cluster_node/$thedomain/$filename", + "puppet://$server/files/apache/vhost_varieties/$operatingsystem.$lsbdistcodename/$thedomain/$filename", + "puppet://$server/files/apache/vhost_varieties/$operatingsystem/$thedomain/$filename", + "puppet://$server/files/apache/vhost_varieties/$thedomain/$filename", + "puppet://$server/apache/vhost_varieties/$thedomain/$filename", + "puppet://$server/apache/vhost_varieties/$operatingsystem.$lsbdistcodename/$thedomain/$filename", + "puppet://$server/apache/vhost_varieties/$operatingsystem/$thedomain/$filename", + "puppet://$server/apache/vhost_varieties/$thedomain/$filename" + ], + ensure => file, + require => Apache::Vhost::Webdir["$thedomain"], + owner => $owner, group => $group, mode => $mode; + } +} + diff --git a/manifests/vhost/modperl.pp b/manifests/vhost/modperl.pp new file mode 100644 index 0000000..35e1f93 --- /dev/null +++ b/manifests/vhost/modperl.pp @@ -0,0 +1,94 @@ +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::modperl( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'None', + $cgi_binpath = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent' +){ + # cgi_bin path + case $cgi_binpath { + 'absent': { + $real_path = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/${name}", + default => "/var/www/vhosts/${name}" + }, + default => "${path}" + } + $real_cgi_binpath = "${real_path}/cgi-bin" + } + default: { $real_cgi_binpath = $cgi_binpath } + } + file{$real_cgi_binpath: + ensure => directory, + owner => $documentroot_owner, + group => $documentroot_group, + mode => $documentroot_mode; + } + + # create webdir + ::apache::vhost::webdir{$name: + ensure => $ensure, + path => $path, + owner => $owner, + group => $group, + run_mode => $run_mode, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + } + + # create vhost configuration file + ::apache::vhost{$name: + ensure => $ensure, + path => $path, + template_mode => 'perl', + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + cgi_binpath => $real_cgi_binpath, + ssl_mode => $ssl_mode, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + mod_security => $mod_security, + } +} + diff --git a/manifests/vhost/php/drupal.pp b/manifests/vhost/php/drupal.pp new file mode 100644 index 0000000..ea0d031 --- /dev/null +++ b/manifests/vhost/php/drupal.pp @@ -0,0 +1,86 @@ +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::php::drupal( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $manage_cron = true +){ + $documentroot = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/${name}/www", + default => "/var/www/vhosts/${name}/www" + }, + default => "${path}/www" + } + + if $manage_cron { + file{"/etc/cron.d/drupal_cron_${name}": + content => "0 * * * * apache wget -O - -q -t 1 http://${doamin}/cron.php\n", + owner => root, group => 0, mode => 0644; + } + } + + # create vhost configuration file + ::apache::vhost::php::webapp{$name: + ensure => $ensure, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + path => $path, + template_mode => 'php_drupal', + owner => $owner, + group => $group, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + mod_security => $mod_security, + ssl_mode => $ssl_mode, + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + manage_directories => false, + manage_config => false, + } +} + diff --git a/manifests/vhost/php/joomla.pp b/manifests/vhost/php/joomla.pp new file mode 100644 index 0000000..1294b52 --- /dev/null +++ b/manifests/vhost/php/joomla.pp @@ -0,0 +1,100 @@ + +rmal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::php::joomla( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $manage_config = true, + $config_webwriteable = false, + $manage_directories = true +){ + include ::apache::joomla + + $documentroot = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/${name}/www", + default => "/var/www/vhosts/${name}/www" + }, + default => "${path}/www" + } + + # create vhost configuration file + ::apache::vhost::php::webapp{$name: + ensure => $ensure, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + path => $path, + template_mode => 'php_joomla', + owner => $owner, + group => $group, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + mod_security => $mod_security, + ssl_mode => $ssl_mode, + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + manage_directories => $manage_directories, + managed_directories => [ "$documentroot/administrator/backups", + "$documentroot/administrator/components", + "$documentroot/administrator/language", + "$documentroot/administrator/modules", + "$documentroot/administrator/templates", + "$documentroot/components", + "$documentroot/images", + "$documentroot/language", + "$documentroot/media", + "$documentroot/modules", + "$documentroot/plugins", + "$documentroot/templates", + "$documentroot/cache", + "$documentroot/administrator/cache" ], + manage_config => $manage_config, + config_webwriteable => $config_webwriteable, + config_file => 'configuration.php', + } + +} + diff --git a/manifests/vhost/php/simplemachine.pp b/manifests/vhost/php/simplemachine.pp new file mode 100644 index 0000000..2c50a6e --- /dev/null +++ b/manifests/vhost/php/simplemachine.pp @@ -0,0 +1,90 @@ +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::php::simplemachine( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $manage_config = true, + $config_webwriteable = false, + $manage_directories = true +){ + $documentroot = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/${name}/www", + default => "/var/www/vhosts/${name}/www" + }, + default => "${path}/www" + } + + # create vhost configuration file + ::apache::vhost::php::webapp{$name: + ensure => $ensure, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + path => $path, + template_mode => 'php_simplemachine', + owner => $owner, + group => $group, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + mod_security => $mod_security, + ssl_mode => $ssl_mode, + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + manage_directories => $manage_directories, + managed_directories => [ + "$documentroot/attachments", + "$documentroot/Packages", + "$documentroot/Themes", + "$documentroot/agreement.txt", + "$documentroot/Packages/installed.list", + "$documentroot/avatars" ], + manage_config => $manage_config, + config_webwriteable => $config_webwriteable, + config_file => 'Settings.php', + } +} + diff --git a/manifests/vhost/php/standard.pp b/manifests/vhost/php/standard.pp new file mode 100644 index 0000000..4e5873f --- /dev/null +++ b/manifests/vhost/php/standard.pp @@ -0,0 +1,88 @@ +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::php::standard( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $template_mode = 'php', + $owner = root, + $group = apache, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent' +){ + + ::apache::vhost::phpdirs{"${name}": + ensure => $ensure, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, + } + + # create webdir + ::apache::vhost::webdir{$name: + ensure => $ensure, + path => $path, + owner => $owner, + group => $group, + run_mode => $run_mode, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + } + + # create vhost configuration file + ::apache::vhost{$name: + ensure => $ensure, + path => $path, + template_mode => $template_mode, + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + ssl_mode => $ssl_mode, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + mod_security => $mod_security, + } +} + diff --git a/manifests/vhost/php/webapp.pp b/manifests/vhost/php/webapp.pp new file mode 100644 index 0000000..04fd29c --- /dev/null +++ b/manifests/vhost/php/webapp.pp @@ -0,0 +1,103 @@ +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::php::webapp( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $template_mode, + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $manage_config = true, + $config_file = 'absent', + $config_webwriteable = false, + $manage_directories = true, + $managed_directories +){ + if ($ensure != 'absent') { + if $manage_directories { + ::apache::file::rw{ $managed_directories : + owner => $documentroot_owner, + group => $documentroot_group, + } + } + + if $manage_config { + if $config_file == 'absent' { fail("No config file defined for ${name} on ${fqdn}, if you'd like to manage the config, you have to add one!") } + ::apache::vhost::file::documentrootfile{"configurationfile_${name}": + documentroot => $documentroot, + filename => $config_file, + thedomain => $name, + owner => $documentroot_owner, + group => $documentroot_group, + } + if $config_webwriteable { + Apache::Vhost::File::Documentrootfile["configurationfile_${name}"]{ + mode => 0660, + } + } else { + Apache::Vhost::File::Documentrootfile["configurationfile_${name}"]{ + mode => 0440, + } + } + } + } + + # create vhost configuration file + ::apache::vhost::php::standard{$name: + ensure => $ensure, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + path => $path, + template_mode => $template_mode, + owner => $owner, + group => $group, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + mod_security => $mod_security, + ssl_mode => $ssl_mode, + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + } +} + diff --git a/manifests/vhost/php/wordpress.pp b/manifests/vhost/php/wordpress.pp new file mode 100644 index 0000000..09d38e0 --- /dev/null +++ b/manifests/vhost/php/wordpress.pp @@ -0,0 +1,85 @@ +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::php::wordpress( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $allow_override = 'FileInfo', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = true, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $manage_config = true, + $config_webwriteable = false, + $manage_directories = true +){ + + $documentroot = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/${name}/www", + default => "/var/www/vhosts/${name}/www" + }, + default => "${path}/www" + } + + # create vhost configuration file + ::apache::vhost::php::webapp{$name: + ensure => $ensure, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + path => $path, + template_mode => 'php_wordpress', + owner => $owner, + group => $group, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, + run_gid => $run_gid, + allow_override => $allow_override, + php_upload_tmp_dir => $php_upload_tmp_dir, + php_session_save_path => $php_session_save_path, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + mod_security => $mod_security, + ssl_mode => $ssl_mode, + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + manage_directories => $manage_directories, + managed_directories => "$documentroot/wp-content", + manage_config => $manage_config, + config_webwriteable => $config_webwriteable, + config_file => 'wp-config.php', + } +} + diff --git a/manifests/vhost/phpdirs.pp b/manifests/vhost/phpdirs.pp new file mode 100644 index 0000000..24413d0 --- /dev/null +++ b/manifests/vhost/phpdirs.pp @@ -0,0 +1,49 @@ +define apache::vhost::phpdirs( + $ensure = present, + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0750, + $run_mode = 'normal', + $run_uid = 'absent' +){ + # php upload_tmp_dir + case $php_upload_tmp_dir { + 'absent': { + include apache::defaultphpdirs + $real_php_upload_tmp_dir = "/var/www/upload_tmp_dir/$name" + } + default: { $real_php_upload_tmp_dir = $php_upload_tmp_dir } + } + # php session_save_path + case $php_session_save_path { + 'absent': { + include apache::defaultphpdirs + $real_php_session_save_path = "/var/www/session.save_path/$name" + } + default: { $real_php_session_save_path = $php_session_save_path } + } + + case $ensure { + absent: { + file{[$real_php_upload_tmp_dir, $real_php_session_save_path ]: + ensure => absent, + purge => true, + force => true, + recurse => true, + } + } + default: { + file{[$real_php_upload_tmp_dir, $real_php_session_save_path ]: + ensure => directory, + owner => $run_mode ? { + 'itk' => $run_uid, + default => $documentroot_owner + }, + group => $documentroot_group, mode => $documentroot_mode; + } + } + } +} + diff --git a/manifests/vhost/static.pp b/manifests/vhost/static.pp new file mode 100644 index 0000000..3c8d313 --- /dev/null +++ b/manifests/vhost/static.pp @@ -0,0 +1,61 @@ +# vhost_mode: which option is chosen to deploy the vhost +# - template: generate it from a template (default) +# - file: deploy a vhost file (apache::vhost::file will be called directly) +define apache::vhost::static( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $allow_override = 'None', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent' +){ + # create webdir + ::apache::vhost::webdir{$name: + ensure => $ensure, + path => $path, + owner => $owner, + group => $group, + run_mode => 'normal', + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + } + + # create vhost configuration file + ::apache::vhost{$name: + ensure => $ensure, + path => $path, + template_mode => 'static', + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + allow_override => $allow_override, + do_includes => $do_includes, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + ssl_mode => $ssl_mode, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + mod_security => false, + } +} + diff --git a/manifests/vhost/template.pp b/manifests/vhost/template.pp new file mode 100644 index 0000000..07429a2 --- /dev/null +++ b/manifests/vhost/template.pp @@ -0,0 +1,107 @@ +# template_mode: +# - php: for a default php application +# - static: for a static application (default) +# - perl: for a mod_perl application +# - php_joomla: for a joomla application +# +# domainalias: +# - absent: no domainalias is set (*default*) +# - www: domainalias is set to www.$domain +# - else: domainalias is set to that +# +# ssl_mode: wether this vhost supports ssl or not +# - false: don't enable ssl for this vhost (default) +# - true: enable ssl for this vhost +# - force: enable ssl and redirect non-ssl to ssl +# +define apache::vhost::template( + $ensure = present, + $path = 'absent', + $path_is_webdir = false, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $allow_override = 'None', + $php_upload_tmp_dir = 'absent', + $php_session_save_path = 'absent', + $cgi_binpath = 'absent', + $do_includes = false, + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $template_mode = 'static', + $ssl_mode = false, + $mod_security = true, + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $ldap_auth = false, + $ldap_user = 'any' +){ + $real_path = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/$name", + default => "/var/www/vhosts/$name" + }, + default => $path + } + + if $path_is_webdir { + $documentroot = "$real_path" + } else { + $documentroot = "$real_path/www" + } + $logdir = "$real_path/logs" + + $servername = $domain ? { + 'absent' => $name, + default => $domain + } + $serveralias = $domainalias ? { + 'absent' => '', + 'www' => "www.${servername}", + default => $domainalias + } + if $htpasswd_path == 'absent' { + $real_htpasswd_path = "/var/www/htpasswds/$name" + } else { + $real_htpasswd_path = $htpasswd_path + } + case $run_mode { + 'itk': { + case $run_uid { + 'absent': { fail("you have to define run_uid for $name on $fqdn") } + } + case $run_gid { + 'absent': { fail("you have to define run_gid for $name on $fqdn") } + } + } + } + + # set default dirs for templates + # php upload_tmp_dir + case $php_upload_tmp_dir { + 'absent': { + $real_php_upload_tmp_dir = "/var/www/upload_tmp_dir/$name" + } + default: { $real_php_upload_tmp_dir = $php_upload_tmp_dir } + } + # php session_save_path + case $php_session_save_path { + 'absent': { + $real_php_session_save_path = "/var/www/session.save_path/$name" + } + default: { $real_php_session_save_path = $php_session_save_path } + } + + apache::vhost::file{$name: + ensure => $ensure, + content => template("apache/vhosts/$template_mode/$operatingsystem.erb"), + do_includes => $do_includes, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + } +} + diff --git a/manifests/vhost/webdav.pp b/manifests/vhost/webdav.pp new file mode 100644 index 0000000..6eaa7cd --- /dev/null +++ b/manifests/vhost/webdav.pp @@ -0,0 +1,75 @@ +# Webdav vhost: to manage webdav accessible targets +# run_mode: +# - normal: nothing special (*default*) +# - itk: apache is running with the itk module +# and run_uid and run_gid are used as vhost users +# run_uid: the uid the vhost should run as with the itk module +# run_gid: the gid the vhost should run as with the itk module +define apache::vhost::webdav( + $ensure = present, + $domain = 'absent', + $domainalias = 'absent', + $server_admin = 'absent', + $path = 'absent', + $owner = root, + $group = 0, + $manage_webdir = true, + $path_is_webdir = false, + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0640, + $run_mode = 'normal', + $run_uid = 'absent', + $run_gid = 'absent', + $options = 'absent', + $additional_options = 'absent', + $default_charset = 'absent', + $mod_security = false, + $ssl_mode = false, + $vhost_mode = 'template', + $vhost_source = 'absent', + $vhost_destination = 'absent', + $htpasswd_file = 'absent', + $htpasswd_path = 'absent', + $ldap_auth = false, + $ldap_user = 'any' +){ + if $manage_webdir { + # create webdir + ::apache::vhost::webdir{$name: + ensure => $ensure, + path => $path, + owner => $owner, + group => $group, + run_mode => $run_mode, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + } + } + # create vhost configuration file + ::apache::vhost{$name: + ensure => $ensure, + path => $path, + path_is_webdir => $path_is_webdir, + template_mode => 'webdav', + vhost_mode => $vhost_mode, + vhost_source => $vhost_source, + vhost_destination => $vhost_destination, + domain => $domain, + domainalias => $domainalias, + server_admin => $server_admin, + run_mode => $run_mode, + run_uid => $run_uid, + options => $options, + additional_options => $additional_options, + default_charset => $default_charset, + ssl_mode => $ssl_mode, + htpasswd_file => $htpasswd_file, + htpasswd_path => $htpasswd_path, + ldap_auth => $ldap_auth, + ldap_user => $ldap_user, + mod_security => $mod_security, + } +} + diff --git a/manifests/vhost/webdir.pp b/manifests/vhost/webdir.pp new file mode 100644 index 0000000..b3b53f9 --- /dev/null +++ b/manifests/vhost/webdir.pp @@ -0,0 +1,106 @@ +# create webdir +define apache::vhost::webdir( + $ensure = present, + $path = 'absent', + $owner = root, + $group = apache, + $mode = 0640, + $run_mode = 'normal', + $documentroot_owner = root, + $documentroot_group = apache, + $documentroot_mode = 0640, + $documentroot_recurse = false +){ + $real_path = $path ? { + 'absent' => $operatingsystem ? { + openbsd => "/var/www/htdocs/${name}", + default => "/var/www/vhosts/${name}" + }, + default => "${path}" + } + + if ($run_mode == 'itk') and ($mode == '0640'){ + $real_mode = 0644 + } else { + $real_mode = $mode + } + + $documentroot = "${real_path}/www" + $logdir = "${real_path}/logs" + + if $owner == 'apache' { + if $apache_default_user == '' { + $real_owner = $operatingsystem ? { + openbsd => 'www', + default => $owner + } + } else { + $real_owner = $apache_default_user + } + } else { + $real_owner = $owner + } + if $group == 'apache' { + if $apache_default_group == '' { + $real_group = $operatingsystem ? { + openbsd => 'www', + default => $group + } + } else { + $real_group = $apache_default_group + } + } else { + $real_group = $group + } + + if $documentroot_owner == 'apache' { + if $apache_default_user == '' { + $real_documentroot_owner = $operatingsystem ? { + openbsd => 'www', + default => $documentroot_owner + } + } else { + $real_documentroot_owner = $apache_default_user + } + } else { + $real_documentroot_owner = $documentroot_owner + } + if $documentroot_group == 'apache' { + if $apache_default_group == '' { + $real_documentroot_group = $operatingsystem ? { + openbsd => 'www', + default => $documentroot_group + } + } else { + $real_documentroot_group = $apache_default_group + } + } else { + $real_documentroot_group = $documentroot_group + } + case $ensure { + absent: { + file{[ "$real_path", "$documentroot", "$logdir" ]: + ensure => absent, + purge => true, + recurse => true, + force => true, + } + } + default: { + file{"$real_path": + ensure => directory, + owner => $real_owner, group => $real_group, mode => $real_mode; + } + file{"$documentroot": + ensure => directory, + recurse => $documentroot_recurse, + owner => $real_documentroot_owner, group => $real_documentroot_group, mode => $documentroot_mode; + } + file{"$logdir": + ensure => directory, + owner => $real_documentroot_owner, group => $real_documentroot_group, mode => 770; + } + } + } +} + |