From 112437730f70e18daf3aed9cedffd0c46348204d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Thu, 5 Sep 2013 14:44:09 +0200 Subject: [PATCH] Support for FreeBSD and few other features Summary of the changes: Overview: * added support for FreeBSD * added MPMs: event, peruser, itk (PR #304 + FreeBSD support) * added `apache::package` to choose and install apache package, * allow apache::mod to specify mod identifier and module path (#271) * revisited specs for apache::dev and apache::mod::dev Details: * "${apache::params::conf_dir}/Includes" as $apache::confd_dir for FreeBSD, * "${apache::params::conf_dir}/Modules" as $apache::mod_dir FreeBSD, * "${apache::params::conf_dir}/Vhosts" as $apache::vhost_dir FreeBSD, * added to apache::params: $root_group, $apache_package, $service_name, $server_root, $mime_support_package, $mime_types_config * httpd.erb now uses $server_root (instead of $httpd_dir) as ServerRoot * added $mime_support_package parameter to apache::mod::mime class, * apache::mod::mime installs $mime_support_package package if needed, * added $magic_file parameter to apache::mod::mime_magic class, * added 'default_confd_files.pp', and confd template infrastructure to allow putting some files under conf.d/ (Includes/ under FreeBSD) by default (FreeBSD's apache22 installs Includes/no-accf.conf for example but puppet normally would purge it afterward), * adjusted documentation (README.md), * apache::dev requires apache::package on FreeBSD * other (minor or forgotten) changes and additions, --- README.md | 34 +++++++++++--- manifests/confd/no_accf.pp | 10 ++++ manifests/default_confd_files.pp | 12 +++++ manifests/default_mods.pp | 36 ++++++++++++++- manifests/dev.pp | 3 ++ manifests/init.pp | 49 ++++++++++++++++---- manifests/mod.pp | 13 +++++- manifests/mod/alias.pp | 5 +- manifests/mod/cgid.pp | 5 +- manifests/mod/dav_fs.pp | 5 +- manifests/mod/dav_svn.pp | 1 + manifests/mod/disk_cache.pp | 11 +++-- manifests/mod/itk.pp | 5 ++ manifests/mod/passenger.pp | 8 +++- manifests/mod/prefork.pp | 5 ++ manifests/mod/proxy_html.pp | 3 ++ manifests/mod/ssl.pp | 10 ++-- manifests/package.pp | 48 +++++++++++++++++++ manifests/params.pp | 55 ++++++++++++++++++++++ manifests/peruser/multiplexer.pp | 17 +++++++ manifests/peruser/processor.pp | 17 +++++++ manifests/vhost.pp | 5 +- spec/classes/apache_spec.rb | 72 +++++++++++++++++++++++++++++ spec/classes/dev_spec.rb | 12 +++++ spec/classes/mod/auth_kerb_spec.rb | 12 +++++ spec/classes/mod/dav_svn_spec.rb | 12 +++++ spec/classes/mod/dev_spec.rb | 42 ++++++++--------- spec/classes/mod/dir_spec.rb | 29 +++++++++++- spec/classes/mod/event_spec.rb | 13 +++++- spec/classes/mod/fcgid_spec.rb | 12 +++++ spec/classes/mod/info_spec.rb | 18 ++++++++ spec/classes/mod/itk_spec.rb | 12 +++++ spec/classes/mod/passenger_spec.rb | 12 +++++ spec/classes/mod/perl_spec.rb | 12 +++++ spec/classes/mod/peruser_spec.rb | 13 +++++- spec/classes/mod/php_spec.rb | 27 +++++++++++ spec/classes/mod/prefork_spec.rb | 12 +++++ spec/classes/mod/proxy_html_spec.rb | 12 +++++ spec/classes/mod/python_spec.rb | 12 +++++ spec/classes/mod/ssl_spec.rb | 12 +++++ spec/classes/mod/worker_spec.rb | 12 +++++ spec/classes/mod/wsgi_spec.rb | 12 +++++ spec/classes/service_spec.rb | 16 +++++++ spec/defines/mod_spec.rb | 26 +++++++++++ spec/defines/vhost_spec.rb | 17 +++++++ spec/system/class_spec.rb | 3 ++ spec/system/default_mods_spec.rb | 2 + spec/system/itk_spec.rb | 2 + spec/system/mod_php_spec.rb | 7 ++- spec/system/prefork_worker_spec.rb | 2 + spec/system/vhost_spec.rb | 4 ++ templates/confd/no-accf.conf.erb | 4 ++ tests/mod_load_params.pp | 11 +++++ 53 files changed, 757 insertions(+), 64 deletions(-) create mode 100644 manifests/confd/no_accf.pp create mode 100644 manifests/default_confd_files.pp create mode 100644 manifests/package.pp create mode 100644 manifests/peruser/multiplexer.pp create mode 100644 manifests/peruser/processor.pp create mode 100644 templates/confd/no-accf.conf.erb create mode 100644 tests/mod_load_params.pp diff --git a/README.md b/README.md index 1765c41ffe..a13b7c8f0f 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Apache is a widely-used web server, and this module provides a simplified way of * Apache modules * virtual hosts * listened-to ports +* `/etc/make.conf` on FreeBSD ###Beginning with Apache @@ -53,7 +54,8 @@ The defaults are determined by your operating system (e.g. Debian systems have o ```puppet class { 'apache': - default_mods => false, + default_mods => false, + default_confd_files => false, } ``` @@ -186,6 +188,10 @@ Sets up Apache with default settings based on your OS. Defaults to 'true', set t Sets up a default virtual host. Defaults to 'true', set to 'false' to set up [customized virtual hosts](#configure-a-virtual-host). +#####`default_confd_files` + +Generates default set of include-able apache configuration files under `${apache::confd_dir}` directory. These configuration files correspond to what is usually installed with apache package on given platform. + #####`default_ssl_vhost` Sets up a default SSL virtual host. Defaults to 'false'. @@ -205,11 +211,11 @@ SSL vhosts only respond to HTTPS queries. #####`default_ssl_cert` -The default SSL certification, which is automatically set based on your operating system (`/etc/pki/tls/certs/localhost.crt` for RedHat, `/etc/ssl/certs/ssl-cert-snakeoil.pem` for Debian). This default will work out of the box but must be updated with your specific certificate information before being used in production. +The default SSL certification, which is automatically set based on your operating system (`/etc/pki/tls/certs/localhost.crt` for RedHat, `/etc/ssl/certs/ssl-cert-snakeoil.pem` for Debian, `/usr/local/etc/apache22/server.crt` for FreeBSD). This default will work out of the box but must be updated with your specific certificate information before being used in production. #####`default_ssl_key` -The default SSL key, which is automatically set based on your operating system (`/etc/pki/tls/private/localhost.key` for RedHat, `/etc/ssl/private/ssl-cert-snakeoil.key` for Debian). This default will work out of the box but must be updated with your specific certificate information before being used in production. +The default SSL key, which is automatically set based on your operating system (`/etc/pki/tls/private/localhost.key` for RedHat, `/etc/ssl/private/ssl-cert-snakeoil.key` for Debian, `/usr/local/etc/apache22/server.key` for FreeBSD). This default will work out of the box but must be updated with your specific certificate information before being used in production. #####`default_ssl_chain` @@ -229,7 +235,7 @@ The default certificate revocation list to use, which is automatically set to 'u #####`service_name` -Name of apache service to run. Defaults to: `'httpd'` on RedHat and `'apache2'` on Debian. +Name of apache service to run. Defaults to: `'httpd'` on RedHat, `'apache2'` on Debian, and `'apache22'` on FreeBSD. #####`service_enable` @@ -251,6 +257,10 @@ Sets the server administrator. Defaults to 'root@localhost'. Sets the servername. Defaults to fqdn provided by facter. +#####`server_root` + +A value to be set as `ServerRoot` in main configuration file (`httpd.conf`). Defaults to `/etc/httpd` on RedHat, `/etc/apache2` on Debian and `/usr/local` on FreeBSD. + #####`sendfile` Makes Apache use the Linux kernel 'sendfile' to serve static files. Defaults to 'On'. @@ -281,7 +291,7 @@ Changes the location of the configuration directory your Apache modules configur #####`mpm_module` -Configures which mpm module is loaded and configured for the httpd process by the `apache::mod::prefork`, `apache::mod::worker` and `apache::mod::itk` classes. Must be set to `false` to explicitly declare `apache::mod::worker`, `apache::mod::worker` or `apache::mod::itk` classes with parameters. Valid values are `worker`, `prefork`, `itk` (Debian), or the boolean `false`. Defaults to `prefork` on RedHat and `worker` on Debian. +Configures which mpm module is loaded and configured for the httpd process by the `apache::mod::event`, `apache::mod::itk`, `apache::mod::peruser`, `apache::mod::prefork` and `apache::mod::worker` classes. Must be set to `false` to explicitly declare `apache::mod::event`, `apache::mod::itk`, `apache::mod::peruser`, `apache::mod::prefork` or `apache::mod::worker` classes with parameters. All possible values are `event`, `itk`, `peruser`, `prefork`, `worker` (valid values depend on agent's OS), or the boolean `false`. Defaults to `prefork` on RedHat and FreeBSD and `worker` on Debian. Note: on FreeBSD switching between different mpm modules is quite difficult (but possible). Before changing `$mpm_module` one has to deinstall all packages that depend on currently installed `apache`. #####`conf_template` @@ -353,12 +363,17 @@ There are many `apache::mod::[name]` classes within this module that can be decl * `cgid` * `dav` * `dav_fs` +* `dav_svn` * `deflate` +* `dev` * `dir`* * `disk_cache` -* `fcgid` +* `event` * `fastcgi` +* `fcgid` +* `headers` * `info` +* `itk` * `ldap` * `mime` * `mime_magic`* @@ -367,6 +382,7 @@ There are many `apache::mod::[name]` classes within this module that can be decl * `nss`* * `passenger`* * `perl` +* `peruser` * `php` (requires [`mpm_module`](#mpm_module) set to `prefork`) * `prefork`* * `proxy`* @@ -375,11 +391,13 @@ There are many `apache::mod::[name]` classes within this module that can be decl * `proxy_http` * `python` * `reqtimeout` +* `rewrite` * `setenvif` * `ssl`* (see [apache::mod::ssl](#class-apachemodssl) below) * `status` * `suphp` * `userdir`* +* `vhost_alias` * `worker`* * `wsgi` (see [apache::mod::wsgi](#class-apachemodwsgi) below) * `xsendfile` @@ -1228,6 +1246,8 @@ Installs Apache development libraries class { 'apache::dev': } ``` +On FreeBSD you're required to define `apache::package` or `apache` class before `apache::dev`. + ####Defined Type: `apache::listen` Controls which ports Apache binds to for listening based on the title: @@ -1285,7 +1305,7 @@ The Apache module relies heavily on templates to enable the `vhost` and `apache: ##Limitations -This has been tested on Ubuntu Precise, Debian Wheezy, and CentOS 5.8. +This has been tested on Ubuntu Precise, Debian Wheezy, CentOS 5.8, and FreeBSD 9.1. ##Development diff --git a/manifests/confd/no_accf.pp b/manifests/confd/no_accf.pp new file mode 100644 index 0000000000..5f86eab107 --- /dev/null +++ b/manifests/confd/no_accf.pp @@ -0,0 +1,10 @@ +class apache::confd::no_accf { + # Template uses no variables + file { 'no-accf.conf': + ensure => 'file', + path => "${apache::confd_dir}/no-accf.conf", + content => template('apache/confd/no-accf.conf.erb'), + require => Exec["mkdir ${apache::confd_dir}"], + before => File[$apache::confd_dir], + } +} diff --git a/manifests/default_confd_files.pp b/manifests/default_confd_files.pp new file mode 100644 index 0000000000..b45de86653 --- /dev/null +++ b/manifests/default_confd_files.pp @@ -0,0 +1,12 @@ +class apache::default_confd_files ( + $all = true, +) { + # The rest of the conf.d/* files only get loaded if we want them + if $all { + case $::osfamily { + 'freebsd': { + include apache::confd::no_accf + } + } + } +} diff --git a/manifests/default_mods.pp b/manifests/default_mods.pp index 02d3bd156a..536cd7e334 100644 --- a/manifests/default_mods.pp +++ b/manifests/default_mods.pp @@ -6,7 +6,7 @@ # They are not configurable at this time, so we just include # them to make sure it works. case $::osfamily { - 'redhat': { + 'redhat', 'freebsd': { apache::mod { 'log_config': } } default: {} @@ -43,6 +43,40 @@ apache::mod { 'usertrack': } apache::mod { 'version': } } + 'freebsd': { + include apache::mod::cache + include apache::mod::disk_cache + include apache::mod::headers + include apache::mod::info + include apache::mod::mime_magic + include apache::mod::reqtimeout + include apache::mod::rewrite + include apache::mod::userdir + include apache::mod::vhost_alias + + apache::mod { 'actions': } + apache::mod { 'asis': } + apache::mod { 'auth_digest': } + apache::mod { 'authn_alias': } + apache::mod { 'authn_anon': } + apache::mod { 'authn_dbm': } + apache::mod { 'authn_default': } + apache::mod { 'authz_dbm': } + apache::mod { 'authz_owner': } + apache::mod { 'cern_meta': } + apache::mod { 'charset_lite': } + apache::mod { 'dumpio': } + apache::mod { 'expires': } + apache::mod { 'file_cache': } + apache::mod { 'filter':} + apache::mod { 'imagemap':} + apache::mod { 'include': } + apache::mod { 'logio': } + apache::mod { 'speling': } + apache::mod { 'unique_id': } + apache::mod { 'usertrack': } + apache::mod { 'version': } + } default: {} } case $apache::mpm_module { diff --git a/manifests/dev.pp b/manifests/dev.pp index ea86adae44..057475b159 100644 --- a/manifests/dev.pp +++ b/manifests/dev.pp @@ -1,4 +1,7 @@ class apache::dev { + if $::osfamily == 'FreeBSD' and !defined(Class['apache::package']) { + fail('apache::dev requires apache::package; please include apache or apache::package class first') + } include apache::params $packages = $apache::params::dev_packages package { $packages: diff --git a/manifests/init.pp b/manifests/init.pp index 484e927c35..57ea183841 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,6 +16,7 @@ $service_name = $apache::params::service_name, $default_mods = true, $default_vhost = true, + $default_confd_files = true, $default_ssl_vhost = false, $default_ssl_cert = $apache::params::default_ssl_cert, $default_ssl_key = $apache::params::default_ssl_key, @@ -54,18 +55,32 @@ $package_ensure = 'installed', ) inherits apache::params { - package { 'httpd': - ensure => $package_ensure, - name => $apache::params::apache_name, - notify => Class['Apache::Service'], - } - validate_bool($default_vhost) - validate_bool($default_ssl_vhost) + validate_bool($default_confd_files) # true/false is sufficient for both ensure and enable validate_bool($service_enable) + + $valid_mpms_re = $::osfamily ? { + 'FreeBSD' => '(event|itk|peruser|prefork|worker)', + default => '(itk|prefork|worker)' + } + if $mpm_module { - validate_re($mpm_module, '(prefork|worker|itk|event)') + validate_re($mpm_module, $valid_mpms_re) + } + + # NOTE: on FreeBSD it's mpm module's responsibility to install httpd package. + # NOTE: the same strategy may be introduced for other OSes. For this, you + # should delete the 'if' block below and modify all MPM modules' manifests + # such that they include apache::package class (currently event.pp, itk.pp, + # peruser.pp, prefork.pp, worker.pp). + if $::osfamily != 'FreeBSD' { + package { 'httpd': + ensure => $package_ensure, + name => $apache::params::apache_name, + notify => Class['Apache::Service'], + } + validate_bool($default_ssl_vhost) } validate_re($sendfile, [ '^[oO]n$' , '^[oO]ff$' ]) @@ -209,6 +224,14 @@ $scriptalias = '/var/www/cgi-bin' $access_log_file = 'access_log' } + 'freebsd': { + $docroot = '/usr/local/www/apache22/data' + $pidfile = '/var/run/httpd.pid' + $error_log = 'httpd-error.log' + $error_documents_path = '/usr/local/www/apache22/error' + $scriptalias = '/usr/local/www/apache22/cgi-bin' + $access_log_file = 'httpd-access.log' + } default: { fail("Unsupported osfamily ${::osfamily}") } @@ -220,7 +243,6 @@ } # Template uses: - # - $httpd_dir # - $pidfile # - $user # - $group @@ -256,6 +278,9 @@ all => $default_mods, } } + class { 'apache::default_confd_files': + all => $default_confd_files + } if $mpm_module { class { "apache::mod::${mpm_module}": } } @@ -278,6 +303,10 @@ access_log_file => $access_log_file, priority => '15', } + $ssl_access_log_file = $::osfamily ? { + 'freebsd' => $access_log_file, + default => "ssl_${access_log_file}", + } apache::vhost { 'default-ssl': ensure => $default_ssl_vhost_ensure, port => 443, @@ -285,7 +314,7 @@ docroot => $docroot, scriptalias => $scriptalias, serveradmin => $serveradmin, - access_log_file => "ssl_${access_log_file}", + access_log_file => $ssl_access_log_file, priority => '15', } } diff --git a/manifests/mod.pp b/manifests/mod.pp index 7cb62e5977..f11efc53b8 100644 --- a/manifests/mod.pp +++ b/manifests/mod.pp @@ -47,11 +47,22 @@ $_package = $mod_package } if $_package and ! defined(Package[$_package]) { + # note: FreeBSD/ports uses apxs tool to activate modules; apxs clutters + # httpd.conf with 'LoadModule' directives; here, by proper resource + # ordering, we ensure that our version of httpd.conf is reverted after + # the module gets installed. + $package_before = $::osfamily ? { + 'freebsd' => [ + File["${mod_dir}/${mod}.load"], + File["${apache::params::conf_dir}/${apache::params::conf_file}"] + ], + default => File["${mod_dir}/${mod}.load"], + } # $_package may be an array package { $_package: ensure => $package_ensure, require => Package['httpd'], - before => File["${mod_dir}/${mod}.load"], + before => $package_before, } } diff --git a/manifests/mod/alias.pp b/manifests/mod/alias.pp index 2af73725b0..2880697236 100644 --- a/manifests/mod/alias.pp +++ b/manifests/mod/alias.pp @@ -1,7 +1,8 @@ class apache::mod::alias { $icons_path = $::osfamily ? { - 'debian' => '/usr/share/apache2/icons', - 'redhat' => '/var/www/icons', + 'debian' => '/usr/share/apache2/icons', + 'redhat' => '/var/www/icons', + 'freebsd' => '/usr/local/www/apache22/icons', } apache::mod { 'alias': } # Template uses $icons_path diff --git a/manifests/mod/cgid.pp b/manifests/mod/cgid.pp index 1a0a082494..c932ae2bec 100644 --- a/manifests/mod/cgid.pp +++ b/manifests/mod/cgid.pp @@ -4,8 +4,9 @@ # Debian specifies it's cgid sock path, but RedHat uses the default value # with no config file $cgisock_path = $::osfamily ? { - 'debian' => '${APACHE_RUN_DIR}/cgisock', - default => undef, + 'debian' => '${APACHE_RUN_DIR}/cgisock', + 'freebsd' => 'cgisock', + default => undef, } apache::mod { 'cgid': } if $cgisock_path { diff --git a/manifests/mod/dav_fs.pp b/manifests/mod/dav_fs.pp index ab78408f70..53219be793 100644 --- a/manifests/mod/dav_fs.pp +++ b/manifests/mod/dav_fs.pp @@ -1,7 +1,8 @@ class apache::mod::dav_fs { $dav_lock = $::osfamily ? { - 'debian' => '${APACHE_LOCK_DIR}/DAVLock', - default => '/var/lib/dav/lockdb', + 'debian' => '${APACHE_LOCK_DIR}/DAVLock', + 'freebsd' => '/usr/local/var/DavLock', + default => '/var/lib/dav/lockdb', } Class['apache::mod::dav'] -> Class['apache::mod::dav_fs'] diff --git a/manifests/mod/dav_svn.pp b/manifests/mod/dav_svn.pp index 76e0d885ea..4f34bd6954 100644 --- a/manifests/mod/dav_svn.pp +++ b/manifests/mod/dav_svn.pp @@ -1,4 +1,5 @@ class apache::mod::dav_svn { + Class['apache::mod::dav'] -> Class['apache::mod::dav_svn'] include apache::mod::dav apache::mod { 'dav_svn': } } diff --git a/manifests/mod/disk_cache.pp b/manifests/mod/disk_cache.pp index dd3e0f0938..d28196768f 100644 --- a/manifests/mod/disk_cache.pp +++ b/manifests/mod/disk_cache.pp @@ -1,9 +1,14 @@ class apache::mod::disk_cache { $cache_root = $::osfamily ? { - 'debian' => '/var/cache/apache2/mod_disk_cache', - 'redhat' => '/var/cache/mod_proxy', + 'debian' => '/var/cache/apache2/mod_disk_cache', + 'redhat' => '/var/cache/mod_proxy', + 'freebsd' => '/var/cache/mod_disk_cache', + } + if $::osfamily != 'FreeBSD' { + # FIXME: investigate why disk_cache was dependent on proxy + # NOTE: on FreeBSD disk_cache is compiled by default but proxy is not + Class['apache::mod::proxy'] -> Class['apache::mod::disk_cache'] } - Class['apache::mod::proxy'] -> Class['apache::mod::disk_cache'] Class['apache::mod::cache'] -> Class['apache::mod::disk_cache'] apache::mod { 'disk_cache': } diff --git a/manifests/mod/itk.pp b/manifests/mod/itk.pp index 8abbb1c18a..68ece8681a 100644 --- a/manifests/mod/itk.pp +++ b/manifests/mod/itk.pp @@ -52,6 +52,11 @@ ensure => present, } } + 'freebsd' : { + class { 'apache::package': + mpm_module => 'itk' + } + } default: { fail("Unsupported osfamily ${::osfamily}") } diff --git a/manifests/mod/passenger.pp b/manifests/mod/passenger.pp index 004f128fd7..d4aba84907 100644 --- a/manifests/mod/passenger.pp +++ b/manifests/mod/passenger.pp @@ -10,7 +10,13 @@ $passenger_max_pool_size = undef, $passenger_use_global_queue = undef, ) { - apache::mod { 'passenger': } + if $::osfamily == 'FreeBSD' { + apache::mod { 'passenger': + lib_path => "${passenger_root}/buildout/apache2" + } + } else { + apache::mod { 'passenger': } + } # Template uses: # - $passenger_root # - $passenger_ruby diff --git a/manifests/mod/prefork.pp b/manifests/mod/prefork.pp index 91f0f1c30b..ecbf809a20 100644 --- a/manifests/mod/prefork.pp +++ b/manifests/mod/prefork.pp @@ -62,6 +62,11 @@ ensure => present, } } + 'freebsd' : { + class { 'apache::package': + mpm_module => 'prefork' + } + } default: { fail("Unsupported osfamily ${::osfamily}") } diff --git a/manifests/mod/proxy_html.pp b/manifests/mod/proxy_html.pp index ab2575731a..050b65d4fc 100644 --- a/manifests/mod/proxy_html.pp +++ b/manifests/mod/proxy_html.pp @@ -12,6 +12,9 @@ default => "/usr/lib/${::hardwaremodel}-linux-gnu/libxml2.so.2", } } + 'FreeBSD': { + apache::mod { 'xml2enc': } + } } # Template uses $icons_path file { 'proxy_html.conf': diff --git a/manifests/mod/ssl.pp b/manifests/mod/ssl.pp index ba183e1dd8..ea1e119750 100644 --- a/manifests/mod/ssl.pp +++ b/manifests/mod/ssl.pp @@ -2,12 +2,14 @@ $ssl_compression = false, ) { $session_cache = $::osfamily ? { - 'debian' => '${APACHE_RUN_DIR}/ssl_scache(512000)', - 'redhat' => '/var/cache/mod_ssl/scache(512000)', + 'debian' => '${APACHE_RUN_DIR}/ssl_scache(512000)', + 'redhat' => '/var/cache/mod_ssl/scache(512000)', + 'freebsd' => '/var/run/ssl_scache(512000)', } $ssl_mutex = $::osfamily ? { - 'debian' => 'file:${APACHE_RUN_DIR}/ssl_mutex', - 'redhat' => 'default', + 'debian' => 'file:${APACHE_RUN_DIR}/ssl_mutex', + 'redhat' => 'default', + 'freebsd' => 'default', } apache::mod { 'ssl': } diff --git a/manifests/package.pp b/manifests/package.pp new file mode 100644 index 0000000000..31bd311982 --- /dev/null +++ b/manifests/package.pp @@ -0,0 +1,48 @@ +class apache::package ( + $ensure = 'present', + $mpm_module = $apache::params::mpm_module, +) { + case $::osfamily { + 'freebsd' : { + $all_mpms = [ + 'www/apache22', + 'www/apache22-worker-mpm', + 'www/apache22-event-mpm', + 'www/apache22-itk-mpm', + 'www/apache22-peruser-mpm', + ] + if $mpm_module { + $apache_package = $mpm_module ? { + 'prefork' => 'www/apache22', + default => "www/apache22-${mpm_module}-mpm" + } + } else { + $apache_package = 'www/apache22' + } + $other_mpms = delete($all_mpms, $apache_package) + # Configure ports to have apache module packages dependent on correct + # version of apache package (apache22, apache22-worker-mpm, ...) + file_line { 'APACHE_PORT in /etc/make.conf': + ensure => $ensure, + path => '/etc/make.conf', + line => "APACHE_PORT=${apache_package}", + match => "^\\s*#?\\s*APACHE_PORT\\s*=\\s*", + before => Package['httpd'], + } + # remove other packages + ensure_resource('package', $other_mpms, { + ensure => absent, + before => Package['httpd'], + require => File_line['APACHE_PORT in /etc/make.conf'], + }) + } + default: { + $apache_package = $apache::params::apache_name + } + } + package { 'httpd': + ensure => $ensure, + name => $apache_package, + notify => Class['Apache::Service'], + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 8a00856214..dc26d6d225 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -142,6 +142,61 @@ $fastcgi_lib_path = '/var/lib/apache2/fastcgi' $mime_support_package = 'mime-support' $mime_types_config = '/etc/mime.types' + } elsif $::osfamily == 'FreeBSD' { + $user = 'www' + $group = 'www' + $root_group = 'wheel' + $apache_name = 'apache22' + $service_name = 'apache22' + $httpd_dir = '/usr/local/etc/apache22' + $server_root = '/usr/local' + $conf_dir = $httpd_dir + $confd_dir = "${httpd_dir}/Includes" + $mod_dir = "${httpd_dir}/Modules" + $mod_enable_dir = undef + $vhost_dir = "${httpd_dir}/Vhosts" + $vhost_enable_dir = undef + $conf_file = 'httpd.conf' + $ports_file = "${conf_dir}/ports.conf" + $logroot = '/var/log/apache22' + $lib_path = '/usr/local/libexec/apache22' + $mpm_module = 'prefork' + $dev_packages = undef + $default_ssl_cert = '/usr/local/etc/apache22/server.crt' + $default_ssl_key = '/usr/local/etc/apache22/server.key' + $ssl_certs_dir = '/usr/local/etc/apache22' + $passenger_root = '/usr/local/lib/ruby/gems/1.9/gems/passenger-4.0.10' + $passenger_ruby = '/usr/bin/ruby' + $suphp_addhandler = 'php5-script' + $suphp_engine = 'off' + $suphp_configpath = undef + $mod_packages = { + # NOTE: I list here only modules that are not included in www/apache22 + # NOTE: 'passenger' needs to enable APACHE_SUPPORT in make config + # NOTE: 'php' needs to enable APACHE option in make config + # NOTE: 'dav_svn' needs to enable MOD_DAV_SVN make config + # NOTE: not sure where the shibboleth should come from + # NOTE: don't know where the shibboleth module should come from + 'auth_kerb' => 'www/mod_auth_kerb2', + 'fcgid' => 'www/mod_fcgid', + 'passenger' => 'www/rubygem-passenger', + 'perl' => 'www/mod_perl2', + 'php5' => 'lang/php5', + 'proxy_html' => 'www/mod_proxy_html', + 'python' => 'www/mod_python3', + 'wsgi' => 'www/mod_wsgi', + 'dav_svn' => 'devel/subversion', + 'xsendfile' => 'www/mod_xsendfile', + } + $mod_libs = { + 'php5' => 'libphp5.so', + } + $conf_template = 'apache/httpd.conf.erb' + $keepalive = 'Off' + $keepalive_timeout = 15 + $fastcgi_lib_path = undef # TODO: revisit + $mime_support_package = 'misc/mime-support' + $mime_types_config = '/usr/local/etc/mime.types' } else { fail("Class['apache::params']: Unsupported osfamily: ${::osfamily}") } diff --git a/manifests/peruser/multiplexer.pp b/manifests/peruser/multiplexer.pp new file mode 100644 index 0000000000..260f1b5a3d --- /dev/null +++ b/manifests/peruser/multiplexer.pp @@ -0,0 +1,17 @@ +define apache::peruser::multiplexer ( + $user = $apache::user, + $group = $apache::group, + $file = undef, +) { + if ! $file { + $filename = "${name}.conf" + } else { + $filename = $file + } + file { "${apache::mod_dir}/peruser/multiplexers/${filename}": + ensure => file, + content => "Multiplexer ${user} ${group}\n", + require => File["${apache::mod_dir}/peruser/multiplexers"], + notify => Service['httpd'], + } +} diff --git a/manifests/peruser/processor.pp b/manifests/peruser/processor.pp new file mode 100644 index 0000000000..c677cd6ca1 --- /dev/null +++ b/manifests/peruser/processor.pp @@ -0,0 +1,17 @@ +define apache::peruser::processor ( + $user, + $group, + $file = undef, +) { + if ! $file { + $filename = "${name}.conf" + } else { + $filename = $file + } + file { "${apache::mod_dir}/peruser/processors/${filename}": + ensure => file, + content => "Processor ${user} ${group}\n", + require => File["${apache::mod_dir}/peruser/processors"], + notify => Service['httpd'], + } +} diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 7f0d91c881..a7717f38f6 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -211,7 +211,7 @@ } elsif $access_log_pipe { $access_log_destination = "\"${access_log_pipe}\"" } elsif $access_log_syslog { - $access_log_destination = "${access_log_syslog}" + $access_log_destination = $access_log_syslog } else { if $ssl { $access_log_destination = "${logroot}/${servername}_access_ssl.log" @@ -225,7 +225,7 @@ } elsif $error_log_pipe { $error_log_destination = "\"${error_log_pipe}\"" } elsif $error_log_syslog { - $error_log_destination = "${error_log_syslog}" + $error_log_destination = $error_log_syslog } else { if $ssl { $error_log_destination = "${logroot}/${servername}_error_ssl.log" @@ -449,4 +449,3 @@ } } } - diff --git a/spec/classes/apache_spec.rb b/spec/classes/apache_spec.rb index 919b4ec0c5..a174c108d2 100644 --- a/spec/classes/apache_spec.rb +++ b/spec/classes/apache_spec.rb @@ -362,6 +362,78 @@ end end end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_class("apache::package").with({'ensure' => 'present'}) } + it { should contain_user("www") } + it { should contain_group("www") } + it { should contain_class("apache::service") } + it { should contain_file("/usr/local/etc/apache22/Vhosts").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + it { should contain_file("/usr/local/etc/apache22/Modules").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + it { should contain_concat("/usr/local/etc/apache22/ports.conf").with( + 'owner' => 'root', + 'group' => 'wheel', + 'mode' => '0644', + 'notify' => 'Class[Apache::Service]' + ) } + # Assert that load files are placed for these mods, but no conf file. + [ + 'auth_basic', + 'authn_file', + 'authz_default', + 'authz_groupfile', + 'authz_host', + 'authz_user', + 'dav', + 'env' + ].each do |modname| + it { should contain_file("#{modname}.load").with( + 'path' => "/usr/local/etc/apache22/Modules/#{modname}.load", + 'ensure' => 'file' + ) } + it { should_not contain_file("#{modname}.conf") } + end + + # Assert that both load files and conf files are placed for these mods + [ + 'alias', + 'autoindex', + 'dav_fs', + 'deflate', + 'dir', + 'mime', + 'negotiation', + 'setenvif', + ].each do |modname| + it { should contain_file("#{modname}.load").with( + 'path' => "/usr/local/etc/apache22/Modules/#{modname}.load", + 'ensure' => 'file' + ) } + it { should contain_file("#{modname}.conf").with( + 'path' => "/usr/local/etc/apache22/Modules/#{modname}.conf", + 'ensure' => 'file' + ) } + end + end context 'on all OSes' do let :facts do { diff --git a/spec/classes/dev_spec.rb b/spec/classes/dev_spec.rb index 8bdf1200b8..3a094df480 100644 --- a/spec/classes/dev_spec.rb +++ b/spec/classes/dev_spec.rb @@ -23,4 +23,16 @@ it { should include_class("apache::params") } it { should contain_package("httpd-devel") } end + context "on a FreeBSD OS" do + let :pre_condition do + 'include apache::package' + end + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + } + end + it { should include_class("apache::params") } + end end diff --git a/spec/classes/mod/auth_kerb_spec.rb b/spec/classes/mod/auth_kerb_spec.rb index c4aa8a67f6..955be8da47 100644 --- a/spec/classes/mod/auth_kerb_spec.rb +++ b/spec/classes/mod/auth_kerb_spec.rb @@ -26,4 +26,16 @@ it { should contain_apache__mod("auth_kerb") } it { should contain_package("mod_auth_kerb") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod("auth_kerb") } + it { should contain_package("www/mod_auth_kerb2") } + end end diff --git a/spec/classes/mod/dav_svn_spec.rb b/spec/classes/mod/dav_svn_spec.rb index 4d293b37d7..c0e25312ea 100644 --- a/spec/classes/mod/dav_svn_spec.rb +++ b/spec/classes/mod/dav_svn_spec.rb @@ -26,4 +26,16 @@ it { should contain_apache__mod('dav_svn') } it { should contain_package("mod_dav_svn") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod('dav_svn') } + it { should contain_package("devel/subversion") } + end end diff --git a/spec/classes/mod/dev_spec.rb b/spec/classes/mod/dev_spec.rb index 4d88768531..eee0bb1fa6 100644 --- a/spec/classes/mod/dev_spec.rb +++ b/spec/classes/mod/dev_spec.rb @@ -1,27 +1,23 @@ -describe 'apache::dev', :type => :class do - let :pre_condition do - 'include apache' - end - context "on a Debian OS" do - let :facts do - { - :osfamily => 'Debian', - :operatingsystemrelease => '6', - :concat_basedir => '/dne', - } +require 'spec_helper' +describe 'apache::mod::dev', :type => :class do + [ + ['RedHat', '6'], + ['Debian', '6'], + ['FreeBSD', '9'], + ].each do |osfamily, operatingsystemrelease| + if osfamily == 'FreeBSD' + let :pre_condition do + 'include apache::package' + end end - it { should contain_package("libaprutil1-dev") } - it { should contain_package("libapr1-dev") } - it { should contain_package("apache2-prefork-dev") } - end - context "on a RedHat OS" do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystemrelease => '6', - :concat_basedir => '/dne', - } + context "on a #{osfamily} OS" do + let :facts do + { + :osfamily => osfamily, + :operatingsystemrelease => operatingsystemrelease, + } + end + it { should include_class('apache::dev') } end - it { should contain_package("httpd-devel") } end end diff --git a/spec/classes/mod/dir_spec.rb b/spec/classes/mod/dir_spec.rb index ec94b2899f..28aaf5c71a 100644 --- a/spec/classes/mod/dir_spec.rb +++ b/spec/classes/mod/dir_spec.rb @@ -58,4 +58,31 @@ it { should contain_file('dir.conf').with_content(/ fearsome\.aspx$/) } end end -end \ No newline at end of file + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + context "passing no parameters" do + it { should include_class("apache::params") } + it { should contain_apache__mod('dir') } + it { should contain_file('dir.conf').with_content(/^DirectoryIndex /) } + it { should contain_file('dir.conf').with_content(/ index\.html /) } + it { should contain_file('dir.conf').with_content(/ index\.html\.var /) } + it { should contain_file('dir.conf').with_content(/ index\.cgi /) } + it { should contain_file('dir.conf').with_content(/ index\.pl /) } + it { should contain_file('dir.conf').with_content(/ index\.php /) } + it { should contain_file('dir.conf').with_content(/ index\.xhtml$/) } + end + context "passing indexes => ['example.txt','fearsome.aspx']" do + let :params do + {:indexes => ['example.txt','fearsome.aspx']} + end + it { should contain_file('dir.conf').with_content(/ example\.txt /) } + it { should contain_file('dir.conf').with_content(/ fearsome\.aspx$/) } + end + end +end diff --git a/spec/classes/mod/event_spec.rb b/spec/classes/mod/event_spec.rb index 75c0e70b4c..f695d1d526 100644 --- a/spec/classes/mod/event_spec.rb +++ b/spec/classes/mod/event_spec.rb @@ -2,5 +2,16 @@ let :pre_condition do 'class { "apache": mpm_module => false, }' end - # TBD + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should_not contain_apache__mod('event') } + it { should contain_file("/usr/local/etc/apache22/Modules/event.conf").with_ensure('file') } + end end diff --git a/spec/classes/mod/fcgid_spec.rb b/spec/classes/mod/fcgid_spec.rb index be444c8496..d356a839d5 100644 --- a/spec/classes/mod/fcgid_spec.rb +++ b/spec/classes/mod/fcgid_spec.rb @@ -26,4 +26,16 @@ it { should contain_apache__mod('fcgid') } it { should contain_package("mod_fcgid") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod('fcgid') } + it { should contain_package("www/mod_fcgid") } + end end diff --git a/spec/classes/mod/info_spec.rb b/spec/classes/mod/info_spec.rb index a057bf1dd8..21d253e98a 100644 --- a/spec/classes/mod/info_spec.rb +++ b/spec/classes/mod/info_spec.rb @@ -56,6 +56,24 @@ def general_info_specs it { should contain_file("info.conf").with_path("/etc/httpd/conf.d/info.conf") } end + context "On a FreeBSD OS with default params" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + + # Load the more generic tests for this context + general_info_specs() + + it { should contain_file("info.conf").with({ + :ensure => 'file', + :path => '/usr/local/etc/apache22/Modules/info.conf', + } ) } + end + context "with $allow_from => ['10.10.10.10','11.11.11.11']" do let :facts do { diff --git a/spec/classes/mod/itk_spec.rb b/spec/classes/mod/itk_spec.rb index 7a0f7615ca..b531e942d8 100644 --- a/spec/classes/mod/itk_spec.rb +++ b/spec/classes/mod/itk_spec.rb @@ -16,4 +16,16 @@ it { should contain_file("/etc/apache2/mods-enabled/itk.conf").with_ensure('link') } it { should contain_package("apache2-mpm-itk") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should_not contain_apache__mod('itk') } + it { should contain_file("/usr/local/etc/apache22/Modules/itk.conf").with_ensure('file') } + end end diff --git a/spec/classes/mod/passenger_spec.rb b/spec/classes/mod/passenger_spec.rb index 3995dc9ddc..1d148b60c9 100644 --- a/spec/classes/mod/passenger_spec.rb +++ b/spec/classes/mod/passenger_spec.rb @@ -97,4 +97,16 @@ it { should contain_file('passenger.conf').with_content(/^ PassengerRoot \/usr\/share\/rubygems\/gems\/passenger-3.0.17$/) } it { should contain_file('passenger.conf').with_content(/^ PassengerRuby \/usr\/bin\/ruby$/) } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod('passenger') } + it { should contain_package("www/rubygem-passenger") } + end end diff --git a/spec/classes/mod/perl_spec.rb b/spec/classes/mod/perl_spec.rb index 0f76abbd90..27690e2a0f 100644 --- a/spec/classes/mod/perl_spec.rb +++ b/spec/classes/mod/perl_spec.rb @@ -26,4 +26,16 @@ it { should contain_apache__mod('perl') } it { should contain_package("mod_perl") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod('perl') } + it { should contain_package("www/mod_perl2") } + end end diff --git a/spec/classes/mod/peruser_spec.rb b/spec/classes/mod/peruser_spec.rb index 370d0fd2ba..3d4a608461 100644 --- a/spec/classes/mod/peruser_spec.rb +++ b/spec/classes/mod/peruser_spec.rb @@ -2,5 +2,16 @@ let :pre_condition do 'class { "apache": mpm_module => false, }' end - # TBD + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should_not contain_apache__mod('peruser') } + it { should contain_file("/usr/local/etc/apache22/Modules/peruser.conf").with_ensure('file') } + end end diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 69617fb03c..31a85a7bfc 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -69,4 +69,31 @@ ) } end end + describe "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + context "with mpm_module => prefork" do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + it { should include_class('apache::params') } + it { should contain_apache__mod('php5') } + it { should contain_package("lang/php5") } + it { should contain_file('php5.load') } + end + # FIXME: not sure about the following context + context 'with mpm_module => worker' do + let :pre_condition do + 'class { "apache": mpm_module => worker, }' + end + it 'should raise an error' do + expect { subject.should contain_apache__mod('php5') }.to raise_error Puppet::Error, /mpm_module => 'prefork'/ + end + end + end end diff --git a/spec/classes/mod/prefork_spec.rb b/spec/classes/mod/prefork_spec.rb index fa34a20c84..7148f787a7 100644 --- a/spec/classes/mod/prefork_spec.rb +++ b/spec/classes/mod/prefork_spec.rb @@ -32,4 +32,16 @@ }) } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should_not contain_apache__mod('prefork') } + it { should contain_file("/usr/local/etc/apache22/Modules/prefork.conf").with_ensure('file') } + end end diff --git a/spec/classes/mod/proxy_html_spec.rb b/spec/classes/mod/proxy_html_spec.rb index c257fe7461..10547d8330 100644 --- a/spec/classes/mod/proxy_html_spec.rb +++ b/spec/classes/mod/proxy_html_spec.rb @@ -30,4 +30,16 @@ it { should contain_apache__mod('proxy_html') } it { should contain_package("mod_proxy_html") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod('proxy_html') } + it { should contain_package("www/mod_proxy_html") } + end end diff --git a/spec/classes/mod/python_spec.rb b/spec/classes/mod/python_spec.rb index 09e8cc2f94..b29e4b5f89 100644 --- a/spec/classes/mod/python_spec.rb +++ b/spec/classes/mod/python_spec.rb @@ -26,4 +26,16 @@ it { should contain_apache__mod("python") } it { should contain_package("mod_python") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod("python") } + it { should contain_package("www/mod_python3") } + end end diff --git a/spec/classes/mod/ssl_spec.rb b/spec/classes/mod/ssl_spec.rb index f58dde265c..b4e9255f05 100644 --- a/spec/classes/mod/ssl_spec.rb +++ b/spec/classes/mod/ssl_spec.rb @@ -38,4 +38,16 @@ it { should contain_apache__mod('ssl') } it { should_not contain_package('libapache2-mod-ssl') } end + + context 'on a FreeBSD OS' do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class('apache::params') } + it { should contain_apache__mod('ssl') } + end end diff --git a/spec/classes/mod/worker_spec.rb b/spec/classes/mod/worker_spec.rb index 7d55432753..4c504c01fb 100644 --- a/spec/classes/mod/worker_spec.rb +++ b/spec/classes/mod/worker_spec.rb @@ -29,4 +29,16 @@ it { should contain_file("/etc/httpd/conf.d/worker.conf").with_ensure('file') } it { should contain_file_line("/etc/sysconfig/httpd worker enable") } end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should_not contain_apache__mod('worker') } + it { should contain_file("/usr/local/etc/apache22/Modules/worker.conf").with_ensure('file') } + end end diff --git a/spec/classes/mod/wsgi_spec.rb b/spec/classes/mod/wsgi_spec.rb index 30ef523e41..9549b1df7b 100644 --- a/spec/classes/mod/wsgi_spec.rb +++ b/spec/classes/mod/wsgi_spec.rb @@ -39,4 +39,16 @@ it {should contain_file('wsgi.conf').with_content(/^ WSGIPythonHome \/path\/to\/virtenv$/)} end end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should include_class("apache::params") } + it { should contain_apache__mod('wsgi') } + it { should contain_package("www/mod_wsgi") } + end end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index 836ac27b79..accc549462 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -90,4 +90,20 @@ ) } end + + context "on a FreeBSD 5 OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + it { should contain_service("httpd").with( + 'name' => 'apache22', + 'ensure' => 'running', + 'enable' => 'true' + ) + } + end end diff --git a/spec/defines/mod_spec.rb b/spec/defines/mod_spec.rb index 77c8dfd918..0bb5bf6b75 100644 --- a/spec/defines/mod_spec.rb +++ b/spec/defines/mod_spec.rb @@ -76,4 +76,30 @@ end end end + + context "on a FreeBSD osfamily" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + + describe "for non-special modules" do + let :title do + 'spec_m' + end + it { should include_class("apache::params") } + it "should manage the module load file" do + should contain_file('spec_m.load').with({ + :path => '/usr/local/etc/apache22/Modules/spec_m.load', + :content => "LoadModule spec_m_module /usr/local/libexec/apache22/mod_spec_m.so\n", + :owner => 'root', + :group => 'wheel', + :mode => '0644', + } ) + end + end + end end diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 988b7f1f07..2e43a47540 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -49,6 +49,23 @@ :target => '/etc/apache2/sites-available/25-rspec.example.com.conf' ) } end + context "on FreeBSD systems" do + let :default_facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + } + end + let :params do default_params end + let :facts do default_facts end + it { should include_class("apache") } + it { should include_class("apache::params") } + it { should contain_file("25-rspec.example.com.conf").with( + :ensure => 'present', + :path => '/usr/local/etc/apache22/Vhosts/25-rspec.example.com.conf' + ) } + end end describe 'os-independent items' do let :facts do diff --git a/spec/system/class_spec.rb b/spec/system/class_spec.rb index 441331658c..0e9afe543c 100644 --- a/spec/system/class_spec.rb +++ b/spec/system/class_spec.rb @@ -8,6 +8,9 @@ when 'Debian' package_name = 'apache2' service_name = 'apache2' + when 'FreeBSD' + package_name = 'apache22' + service_name = 'apache22' end context 'default parameters' do diff --git a/spec/system/default_mods_spec.rb b/spec/system/default_mods_spec.rb index 95e57e844a..9134fbb92f 100644 --- a/spec/system/default_mods_spec.rb +++ b/spec/system/default_mods_spec.rb @@ -5,6 +5,8 @@ servicename = 'httpd' when 'Debian' servicename = 'apache2' +when 'FreeBSD' + servicename = 'apache22' else raise "Unconfigured OS for apache service on #{node.facts['osfamily']}" end diff --git a/spec/system/itk_spec.rb b/spec/system/itk_spec.rb index fdbabb9fe6..2d8765cf0a 100644 --- a/spec/system/itk_spec.rb +++ b/spec/system/itk_spec.rb @@ -3,6 +3,8 @@ case node.facts['osfamily'] when 'Debian' service_name = 'apache2' +when 'FreeBSD' + service_name = 'apache22' else # Not implemented yet service_name = :skip diff --git a/spec/system/mod_php_spec.rb b/spec/system/mod_php_spec.rb index 71a806b6b9..9fad7c1487 100644 --- a/spec/system/mod_php_spec.rb +++ b/spec/system/mod_php_spec.rb @@ -3,11 +3,14 @@ describe 'apache::mod::php class' do case node.facts['osfamily'] when 'Debian' - mod_dir = '/etc/apache2/mods-available' + mod_dir = '/etc/apache2/mods-available' service_name = 'apache2' when 'RedHat' - mod_dir = '/etc/httpd/conf.d' + mod_dir = '/etc/httpd/conf.d' service_name = 'httpd' + when 'FreeBSD' + mod_dir = '/usr/local/etc/apache22/Modules' + service_name = 'apache22' end context "default php config" do diff --git a/spec/system/prefork_worker_spec.rb b/spec/system/prefork_worker_spec.rb index b455d748fa..033e716197 100644 --- a/spec/system/prefork_worker_spec.rb +++ b/spec/system/prefork_worker_spec.rb @@ -5,6 +5,8 @@ servicename = 'httpd' when 'Debian' servicename = 'apache2' +when 'FreeBSD' + servicename = 'apache22' else raise "Unconfigured OS for apache service on #{node.facts['osfamily']}" end diff --git a/spec/system/vhost_spec.rb b/spec/system/vhost_spec.rb index 72427a0176..f5fdd2fe34 100644 --- a/spec/system/vhost_spec.rb +++ b/spec/system/vhost_spec.rb @@ -6,6 +6,10 @@ vhost_dir = '/etc/httpd/conf.d' package_name = 'httpd' service_name = 'httpd' + when 'FreeBSD' + vhost_dir = '/usr/local/etc/apache22/Vhosts' + package_name = 'apache22' + service_name = 'apache22' when 'Debian' vhost_dir = '/etc/apache2/sites-enabled' package_name = 'apache2' diff --git a/templates/confd/no-accf.conf.erb b/templates/confd/no-accf.conf.erb new file mode 100644 index 0000000000..10e51644ce --- /dev/null +++ b/templates/confd/no-accf.conf.erb @@ -0,0 +1,4 @@ + + AcceptFilter http none + AcceptFilter https none + diff --git a/tests/mod_load_params.pp b/tests/mod_load_params.pp new file mode 100644 index 0000000000..0e84c5efbf --- /dev/null +++ b/tests/mod_load_params.pp @@ -0,0 +1,11 @@ +# Tests the path and identifier parameters for the apache::mod class + +# Base class for clarity: +class { 'apache': } + + +# Exaple parameter usage: +apache::mod { 'testmod': + path => '/usr/some/path/mod_testmod.so', + id => 'testmod_custom_name', +}