diff --git a/CHANGELOG b/CHANGELOG index 5b2b0bd25f..9b77277e4c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,15 @@ +2013-07-16 Release 0.8.0 +Features: +- Add `servername` parameter to `apache` class +- Add `proxy_set` parameter to `apache::balancer` define + +Bugfixes: +- Fix ordering for multiple `apache::balancer` clusters +- Fix symlinking for sites-available on Debian-based OSs +- Fix dependency ordering for recursive confdir management +- Fix `apache::mod::*` to notify the service on config change +- Documentation updates + 2013-07-09 Release 0.7.0 Changes: - Essentially rewrite the module -- too many to list diff --git a/Modulefile b/Modulefile index 75545bbcc7..4f8a57abf8 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apache' -version '0.7.0' +version '0.8.0' source 'git://github.com/puppetlabs/puppetlabs-apache.git' author 'puppetlabs' license 'Apache 2.0' diff --git a/README.md b/README.md index 4bd149b12a..42305b969a 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,10 @@ Determines whether the 'httpd' service is enabled when the machine is booted, me Sets the server administrator. Defaults to 'root@localhost'. +#####`servername` + +Sets the servername. Defaults to fqdn provided by facter. + #####`sendfile` Makes Apache use the Linux kernel 'sendfile' to serve static files. Defaults to 'false'. @@ -335,11 +339,15 @@ Sets a given `apache::vhost` as the default to serve requests that do not match #####`directories` -Passes a list of hashes to the vhost to create `...` directive blocks as per the [Apache core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#directory). Each hash should be of the form of: +Passes a list of hashes to the vhost to create `...` directive blocks as per the [Apache core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#directory). The `path` key is required in these hashes. Usage will typically look like: -```ruby -directory => [ { path => '/path/to/directory', => } ], -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', => }, + { path => '/path/to/another/directory', => }, + ], + } *Note:* At least one directory should match `docroot` parameter, once you start declaring directories `apache::vhost` assumes that all required `` blocks will be declared. @@ -352,58 +360,65 @@ The directives will be embedded within the `Directory` directive block, missing Sets `AddHandler` directives as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler). Accepts a list of hashes of the form `{ handler => 'handler-name', extensions => ['extension']}`. Note that `extensions` is a list of extenstions being handled by the handler. An example: -```ruby -directory => [ { path => '/path/to/directory', - addhandlers => [ { handler => 'cgi-script', extensions => ['.cgi']} ] -} ] -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', + addhandlers => [ { handler => 'cgi-script', extensions => ['.cgi']} ], + } ], + } ######`allow` Sets an `Allow` directive as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow). An example: -```ruby -directory => [ { path => '/path/to/directory', allow => 'from example.org' } ], -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', allow => 'from example.org' } ], + } ######`allow_override` Sets the usage of `.htaccess` files as per the [Apache core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride). Should accept in the form of a list or a string. An example: -```ruby -directory => [ { path => '/path/to/directory', allow_override => ['AuthConfig', 'Indexes'] } ], -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', allow_override => ['AuthConfig', 'Indexes'] } ], + } ######`deny` Sets an `Deny` directive as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny). An example: -```ruby -directory => [ { path => '/path/to/directory', deny => 'from example.org' } ], -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', deny => 'from example.org' } ], + } ######`options` Lists the options for the given `` block -```ruby - directory => [ { path => '/path/to/directory', options => ['Indexes','FollowSymLinks','MultiViews'] }] -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', options => ['Indexes','FollowSymLinks','MultiViews'] }], + } ######`order` Sets the order of processing `Allow` and `Deny` statements as per [Apache core documentation](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order). An example: -```ruby -directory => [ { path => '/path/to/directory', order => 'Allow, Deny' } ], -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', order => 'Allow, Deny' } ], + } ######`passenger_enabled` Sets the value for the `PassengerEnabled` directory to `on` or `off` as per the [Passenger documentation](http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerEnabled). -```ruby -directory => [ { path => '/path/to/directory', passenger_enabled => 'off' } ], -``` + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', passenger_enabled => 'off' } ], + } **Note:** This directive requires `apache::mod::passenger` to be active, Apache may not start with an unrecognised directive without it. @@ -823,6 +838,12 @@ And on the proxy itself you create the balancer cluster using the defined type a apache::balancer { 'puppet00': } +If you need to use ProxySet in the balncer config you can do as so: + + apache::balancer { 'puppet01': + proxy_set => {'stickysession' => 'JSESSIONID'}, + } + ###Templates The Apache module relies heavily on templates to enable the `vhost` and `apache::mod` defined types. These templates are built based on Facter facts around your operating system. Unless explicitly called out, most templates are not meant for configuration. diff --git a/manifests/balancer.pp b/manifests/balancer.pp index 822e66b4d6..02b06d74ef 100644 --- a/manifests/balancer.pp +++ b/manifests/balancer.pp @@ -19,6 +19,10 @@ # The namevar of the defined resource type is the balancer clusters name. # This name is also used in the name of the conf.d file # +# [*proxy_set*] +# Hash, default empty. If given, each key-value pair will be used as a ProxySet +# line in the configuration. +# # [*collect_exported*] # Boolean, default 'true'. True means 'collect exported @@balancermember # resources' (for the case when every balancermember node exports itself), @@ -35,6 +39,7 @@ # apache::balancer { 'puppet00': } # define apache::balancer ( + $proxy_set = {}, $collect_exported = true, ) { include concat::setup @@ -48,7 +53,7 @@ notify => Service['httpd'], } - concat::fragment { '00-header': + concat::fragment { "00-${name}-header": target => $target, order => '01', content => "\n", @@ -60,7 +65,13 @@ # else: the resources have been created and they introduced their # concat fragments. We don't have to do anything about them. - concat::fragment { '01-footer': + concat::fragment { "01-${name}-proxyset": + target => $target, + order => '19', + content => inline_template("<% proxy_set.each do |key, value| %> Proxyset <%= key %>=<%= value %>\n<% end %>"), + } + + concat::fragment { "01-${name}-footer": target => $target, order => '20', content => "\n", diff --git a/manifests/default_mods.pp b/manifests/default_mods.pp index d5e0de54c7..3d363696ce 100644 --- a/manifests/default_mods.pp +++ b/manifests/default_mods.pp @@ -29,6 +29,7 @@ include apache::mod::proxy include apache::mod::proxy_http include apache::mod::userdir + include apache::mod::vhost_alias apache::mod { 'actions': } apache::mod { 'auth_digest': } apache::mod { 'authn_alias': } @@ -52,7 +53,6 @@ apache::mod { 'suexec': } apache::mod { 'usertrack': } apache::mod { 'version': } - apache::mod { 'vhost_alias': } } default: {} } diff --git a/manifests/init.pp b/manifests/init.pp index e44877740d..5a878fba04 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -30,10 +30,12 @@ $error_documents = false, $confd_dir = $apache::params::confd_dir, $vhost_dir = $apache::params::vhost_dir, + $vhost_enable_dir = $apache::params::vhost_enable_dir, $mod_dir = $apache::params::mod_dir, $mod_enable_dir = $apache::params::mod_enable_dir, $mpm_module = $apache::params::mpm_module, $conf_template = $apache::params::conf_template, + $servername = $apache::params::servername, $user = $apache::params::user, $group = $apache::params::group, ) inherits apache::params { @@ -84,7 +86,15 @@ $purge_confd = $purge_configs } - file { $apache::confd_dir: + Exec { + path => '/bin:/sbin:/usr/bin:/usr/sbin', + } + + exec { "mkdir ${confd_dir}": + creates => $confd_dir, + require => Package['httpd'], + } + file { $confd_dir: ensure => directory, recurse => true, purge => $purge_confd, @@ -92,18 +102,43 @@ require => Package['httpd'], } - if ! defined(File[$apache::mod_dir]) { - file { $apache::mod_dir: + if ! defined(File[$mod_dir]) { + exec { "mkdir ${mod_dir}": + creates => $mod_dir, + require => Package['httpd'], + } + file { $mod_dir: + ensure => directory, + recurse => true, + purge => $purge_configs, + notify => Service['httpd'], + require => Package['httpd'], + } + } + + if $mod_enable_dir and ! defined(File[$mod_enable_dir]) { + $mod_load_dir = $mod_enable_dir + exec { "mkdir ${mod_enable_dir}": + creates => $mod_enable_dir, + require => Package['httpd'], + } + file { $mod_enable_dir: ensure => directory, recurse => true, purge => $purge_configs, notify => Service['httpd'], require => Package['httpd'], } + } else { + $mod_load_dir = $mod_dir } - if $apache::mod_enable_dir and ! defined(File[$apache::mod_enable_dir]) { - file { $apache::mod_enable_dir: + if ! defined(File[$vhost_dir]) { + exec { "mkdir ${vhost_dir}": + creates => $vhost_dir, + require => Package['httpd'], + } + file { $vhost_dir: ensure => directory, recurse => true, purge => $purge_configs, @@ -112,14 +147,21 @@ } } - if ! defined(File[$apache::vhost_dir]) { - file { $apache::vhost_dir: + if $vhost_enable_dir and ! defined(File[$vhost_enable_dir]) { + $vhost_load_dir = $vhost_enable_dir + exec { "mkdir ${vhost_load_dir}": + creates => $vhost_load_dir, + require => Package['httpd'], + } + file { $vhost_enable_dir: ensure => directory, recurse => true, purge => $purge_configs, notify => Service['httpd'], require => Package['httpd'], } + } else { + $vhost_load_dir = $vhost_dir } concat { $ports_file: diff --git a/manifests/mod.pp b/manifests/mod.pp index c9ea48e64b..ea9cc3c878 100644 --- a/manifests/mod.pp +++ b/manifests/mod.pp @@ -46,7 +46,11 @@ group => 'root', mode => '0644', content => "LoadModule ${mod}_module ${lib_path}/${lib_REAL}\n", - require => Package['httpd'], + require => [ + Package['httpd'], + Exec["mkdir ${mod_dir}"], + ], + before => File[$mod_dir], notify => Service['httpd'], } @@ -59,7 +63,11 @@ owner => 'root', group => 'root', mode => '0644', - require => File["${mod}.load"], + require => [ + File["${mod}.load"], + Exec["mkdir ${enable_dir}"], + ], + before => File[$enable_dir], notify => Service['httpd'], } # Each module may have a .conf file as well, which should be @@ -73,7 +81,11 @@ owner => 'root', group => 'root', mode => '0644', - require => File["${mod}.conf"], + require => [ + File["${mod}.conf"], + Exec["mkdir ${enable_dir}"], + ], + before => File[$enable_dir], notify => Service['httpd'], } } diff --git a/manifests/mod/alias.pp b/manifests/mod/alias.pp index e82b696c65..2af73725b0 100644 --- a/manifests/mod/alias.pp +++ b/manifests/mod/alias.pp @@ -9,5 +9,8 @@ ensure => file, path => "${apache::mod_dir}/alias.conf", content => template('apache/mod/alias.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/autoindex.pp b/manifests/mod/autoindex.pp index 7c5acb150f..85b4278ef7 100644 --- a/manifests/mod/autoindex.pp +++ b/manifests/mod/autoindex.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/autoindex.conf", content => template('apache/mod/autoindex.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/cgid.pp b/manifests/mod/cgid.pp index 1f0c33257b..e26ed70406 100644 --- a/manifests/mod/cgid.pp +++ b/manifests/mod/cgid.pp @@ -8,5 +8,8 @@ ensure => file, path => "${apache::mod_dir}/cgid.conf", content => template('apache/mod/cgid.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/dav_fs.pp b/manifests/mod/dav_fs.pp index 96f829717d..ab78408f70 100644 --- a/manifests/mod/dav_fs.pp +++ b/manifests/mod/dav_fs.pp @@ -12,5 +12,8 @@ ensure => file, path => "${apache::mod_dir}/dav_fs.conf", content => template('apache/mod/dav_fs.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/deflate.pp b/manifests/mod/deflate.pp index 800ecd6f0a..97d1fdd8a1 100644 --- a/manifests/mod/deflate.pp +++ b/manifests/mod/deflate.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/deflate.conf", content => template('apache/mod/deflate.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/dir.pp b/manifests/mod/dir.pp index 250a4611f2..39543e1167 100644 --- a/manifests/mod/dir.pp +++ b/manifests/mod/dir.pp @@ -14,5 +14,8 @@ ensure => file, path => "${apache::mod_dir}/dir.conf", content => template('apache/mod/dir.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/disk_cache.pp b/manifests/mod/disk_cache.pp index ca7e2ae172..dd3e0f0938 100644 --- a/manifests/mod/disk_cache.pp +++ b/manifests/mod/disk_cache.pp @@ -12,5 +12,8 @@ ensure => file, path => "${apache::mod_dir}/disk_cache.conf", content => template('apache/mod/disk_cache.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/info.pp b/manifests/mod/info.pp index 3f1cab5cc4..b76e1efb2a 100644 --- a/manifests/mod/info.pp +++ b/manifests/mod/info.pp @@ -7,5 +7,8 @@ ensure => file, path => "${apache::mod_dir}/info.conf", content => template('apache/mod/info.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/ldap.pp b/manifests/mod/ldap.pp index 5c477db1c9..097622c51e 100644 --- a/manifests/mod/ldap.pp +++ b/manifests/mod/ldap.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/ldap.conf", content => template('apache/mod/ldap.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/mime.pp b/manifests/mod/mime.pp index 6d7cd866eb..ba62ebc638 100644 --- a/manifests/mod/mime.pp +++ b/manifests/mod/mime.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/mime.conf", content => template('apache/mod/mime.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/mime_magic.pp b/manifests/mod/mime_magic.pp index 586a563acc..c0ff0a7f67 100644 --- a/manifests/mod/mime_magic.pp +++ b/manifests/mod/mime_magic.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/mime_magic.conf", content => template('apache/mod/mime_magic.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/mpm_event.pp b/manifests/mod/mpm_event.pp index b6682f5287..92e558e17f 100644 --- a/manifests/mod/mpm_event.pp +++ b/manifests/mod/mpm_event.pp @@ -4,5 +4,8 @@ ensure => file, path => "${apache::mod_dir}/mpm_event.conf", content => template('apache/mod/mpm_event.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/negotiation.pp b/manifests/mod/negotiation.pp index 93772419fb..e10c4921de 100644 --- a/manifests/mod/negotiation.pp +++ b/manifests/mod/negotiation.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/negotiation.conf", content => template('apache/mod/negotiation.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/passenger.pp b/manifests/mod/passenger.pp index b4992bc87d..16f596d1a9 100644 --- a/manifests/mod/passenger.pp +++ b/manifests/mod/passenger.pp @@ -9,5 +9,8 @@ ensure => file, path => "${apache::mod_dir}/passenger.conf", content => template('apache/mod/passenger.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index d8156c4c34..f232753aaf 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -3,10 +3,15 @@ fail('apache::mod::php requires apache::mod::prefork; please enable mpm_module => \'prefork\' on Class[\'apache\']') } apache::mod { 'php5': } - file { 'php.conf': + file { 'php5.conf': ensure => file, - path => "${apache::mod_dir}/php.conf", - content => template('apache/mod/php.conf.erb'), - require => Class['apache::mod::prefork'], + path => "${apache::mod_dir}/php5.conf", + content => template('apache/mod/php5.conf.erb'), + require => [ + Class['apache::mod::prefork'], + Exec["mkdir ${apache::mod_dir}"], + ], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/prefork.pp b/manifests/mod/prefork.pp index c63fa49d28..675cbe841d 100644 --- a/manifests/mod/prefork.pp +++ b/manifests/mod/prefork.pp @@ -25,6 +25,9 @@ file { "${apache::mod_dir}/prefork.conf": ensure => file, content => template('apache/mod/prefork.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } case $::osfamily { @@ -40,8 +43,11 @@ } 'debian': { file { "${apache::mod_enable_dir}/prefork.conf": - ensure => link, - target => "${apache::mod_dir}/prefork.conf", + ensure => link, + target => "${apache::mod_dir}/prefork.conf", + require => Exec["mkdir ${apache::mod_enable_dir}"], + before => File[$apache::mod_enable_dir], + notify => Service['httpd'], } package { 'apache2-mpm-prefork': ensure => present, diff --git a/manifests/mod/proxy.pp b/manifests/mod/proxy.pp index e935379051..71b766bcba 100644 --- a/manifests/mod/proxy.pp +++ b/manifests/mod/proxy.pp @@ -8,5 +8,8 @@ ensure => file, path => "${apache::mod_dir}/proxy.conf", content => template('apache/mod/proxy.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/proxy_html.pp b/manifests/mod/proxy_html.pp index e8da759c07..ab2575731a 100644 --- a/manifests/mod/proxy_html.pp +++ b/manifests/mod/proxy_html.pp @@ -18,5 +18,8 @@ ensure => file, path => "${apache::mod_dir}/proxy_html.conf", content => template('apache/mod/proxy_html.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/reqtimeout.pp b/manifests/mod/reqtimeout.pp index d1a947daf8..b763b37850 100644 --- a/manifests/mod/reqtimeout.pp +++ b/manifests/mod/reqtimeout.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/reqtimeout.conf", content => template('apache/mod/reqtimeout.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/setenvif.pp b/manifests/mod/setenvif.pp index ccf6733f11..1b60edde8b 100644 --- a/manifests/mod/setenvif.pp +++ b/manifests/mod/setenvif.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/setenvif.conf", content => template('apache/mod/setenvif.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/ssl.pp b/manifests/mod/ssl.pp index e290d2521c..ba183e1dd8 100644 --- a/manifests/mod/ssl.pp +++ b/manifests/mod/ssl.pp @@ -16,5 +16,8 @@ ensure => file, path => "${apache::mod_dir}/ssl.conf", content => template('apache/mod/ssl.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/status.pp b/manifests/mod/status.pp index e866096081..084d84eeac 100644 --- a/manifests/mod/status.pp +++ b/manifests/mod/status.pp @@ -5,5 +5,8 @@ ensure => file, path => "${apache::mod_dir}/status.conf", content => template('apache/mod/status.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/userdir.pp b/manifests/mod/userdir.pp index 968a9a034c..69f4044fd4 100644 --- a/manifests/mod/userdir.pp +++ b/manifests/mod/userdir.pp @@ -10,5 +10,8 @@ ensure => file, path => "${apache::mod_dir}/userdir.conf", content => template('apache/mod/userdir.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } } diff --git a/manifests/mod/vhost_alias.pp b/manifests/mod/vhost_alias.pp new file mode 100644 index 0000000000..ec40447a35 --- /dev/null +++ b/manifests/mod/vhost_alias.pp @@ -0,0 +1,3 @@ +class apache::mod::vhost_alias { + apache::mod { 'vhost_alias': } +} diff --git a/manifests/mod/worker.pp b/manifests/mod/worker.pp index 671be9d149..71fbcf8c3b 100644 --- a/manifests/mod/worker.pp +++ b/manifests/mod/worker.pp @@ -27,6 +27,9 @@ file { "${apache::mod_dir}/worker.conf": ensure => file, content => template('apache/mod/worker.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], } case $::osfamily { @@ -41,8 +44,11 @@ } 'debian': { file { "${apache::mod_enable_dir}/worker.conf": - ensure => link, - target => "${apache::mod_dir}/worker.conf", + ensure => link, + target => "${apache::mod_dir}/worker.conf", + require => Exec["mkdir ${apache::mod_enable_dir}"], + before => File[$apache::mod_enable_dir], + notify => Service['httpd'], } package { 'apache2-mpm-worker': ensure => present, diff --git a/manifests/params.pp b/manifests/params.pp index a6cbfc0653..230e0a663b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -26,6 +26,8 @@ fail("Class['apache::params']: Unparsable \$::operatingsystemrelease: ${::operatingsystemrelease}") } + $servername = $::fqdn + if $::osfamily == 'RedHat' or $::operatingsystem == 'amazon' { $user = 'apache' $group = 'apache' @@ -79,7 +81,8 @@ $confd_dir = "${httpd_dir}/conf.d" $mod_dir = "${httpd_dir}/mods-available" $mod_enable_dir = "${httpd_dir}/mods-enabled" - $vhost_dir = "${httpd_dir}/sites-enabled" + $vhost_dir = "${httpd_dir}/sites-available" + $vhost_enable_dir = "${httpd_dir}/sites-enabled" $conf_file = 'apache2.conf' $ports_file = "${conf_dir}/ports.conf" $logroot = '/var/log/apache2' diff --git a/manifests/vhost.pp b/manifests/vhost.pp index b0e8300409..9176abbf08 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -137,6 +137,10 @@ include apache::mod::ssl } + if $virtual_docroot { + include apache::mod::vhost_alias + } + # This ensures that the docroot exists # But enables it to be specified across multiple vhost resources if ! defined(File[$docroot]) { @@ -357,5 +361,18 @@ ], notify => Service['httpd'], } + if $::osfamily == 'Debian' { + $vhost_enable_dir = $apache::vhost_enable_dir + file{ "${priority_real}-${filename}.conf symlink": + ensure => link, + path => "${vhost_enable_dir}/${priority_real}-${filename}.conf", + target => "${apache::vhost_dir}/${priority_real}-${filename}.conf", + owner => 'root', + group => 'root', + mode => '0644', + require => File["${priority_real}-${filename}.conf"], + notify => Service['httpd'], + } + } } diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index aea21cd22b..f1778f4184 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -39,6 +39,15 @@ 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 => '/etc/apache2/sites-available/25-rspec.example.com.conf' + ) } + it { should contain_file("25-rspec.example.com.conf symlink").with( + :ensure => 'link', + :path => '/etc/apache2/sites-enabled/25-rspec.example.com.conf', + :target => '/etc/apache2/sites-available/25-rspec.example.com.conf' + ) } end end describe 'os-independent items' do diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb index e83affd591..60b8374b4f 100644 --- a/spec/system/basic_spec.rb +++ b/spec/system/basic_spec.rb @@ -7,19 +7,5 @@ its(:stderr) { should be_empty } its(:exit_code) { should be_zero } end - - # Using puppet_apply as a helper - it 'my class should work with no errors' do - pp = <<-EOS - class { 'apache': } - EOS - - # Run it twice and test for idempotency - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - r.refresh - r.exit_code.should be_zero - end - end end diff --git a/spec/system/class_spec.rb b/spec/system/class_spec.rb index 20f83934e7..1f00f42abb 100644 --- a/spec/system/class_spec.rb +++ b/spec/system/class_spec.rb @@ -8,19 +8,63 @@ node.facts['osfamily'] } - it 'should install apache' do - if distro_commands.has_key?(os) - shell(distro_commands[os]["package_check"]["command"]) do |r| - r.stdout.should =~ distro_commands[os]['package_check']['stdout'] - r.exit_code.should == 0 + context 'default parameters' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + + it 'should install apache' do + if distro_commands.has_key?(os) + shell(distro_commands[os]["package_check"]["command"]) do |r| + r.stdout.should =~ distro_commands[os]['package_check']['stdout'] + r.exit_code.should == 0 + end + end + end + + it 'should start the apache service' do + if distro_commands.has_key?(os) + shell(distro_commands[os]["service_check"]["command"]) do |r| + r.exit_code.should == 0 + end end end end - it 'should start the apache service' do - if distro_commands.has_key?(os) - shell(distro_commands[os]["service_check"]["command"]) do |r| - r.exit_code.should == 0 + context 'custom site/mod dir parameters' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + file { '/apache': ensure => directory, } + class { 'apache': + mod_dir => '/apache/mods', + vhost_dir => '/apache/vhosts', + } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + + it 'should start the apache service' do + if distro_commands.has_key?(os) + shell(distro_commands[os]["service_check"]["command"]) do |r| + r.exit_code.should == 0 + end end end end diff --git a/spec/system/mod_php_spec.rb b/spec/system/mod_php_spec.rb index e007d8e797..04f48846d5 100644 --- a/spec/system/mod_php_spec.rb +++ b/spec/system/mod_php_spec.rb @@ -50,7 +50,7 @@ class { 'apache::mod::php': } end it 'should have a default config file' do - shell("/bin/cat #{mod_dir}/php.conf") do |r| + shell("/bin/cat #{mod_dir}/php5.conf") do |r| r.stdout.should =~ /^DirectoryIndex index\.php$/ r.exit_code.should == 0 end diff --git a/templates/httpd.conf.erb b/templates/httpd.conf.erb index 0146e76241..4a45fa6c4c 100644 --- a/templates/httpd.conf.erb +++ b/templates/httpd.conf.erb @@ -3,6 +3,7 @@ ServerTokens OS ServerSignature On TraceEnable Off +ServerName "<%= @servername %>" ServerRoot "<%= @httpd_dir %>" PidFile <%= @pidfile %> Timeout 120 @@ -34,9 +35,9 @@ EnableSendfile <%= @sendfile %> <% end %> #Listen 80 -Include <%= @mod_dir %>/*.load -<% if @mod_dir != @confd_dir and @mod_dir != @vhost_dir -%> -Include <%= @mod_dir %>/*.conf +Include <%= @mod_load_dir %>/*.load +<% if @mod_load_dir != @confd_dir and @mod_load_dir != @vhost_load_dir -%> +Include <%= @mod_load_dir %>/*.conf <% end -%> Include <%= @ports_file %> @@ -46,8 +47,8 @@ LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent Include <%= @confd_dir %>/*.conf -<% if @vhost_dir != @confd_dir -%> -Include <%= @vhost_dir %>/*.conf +<% if @vhost_load_dir != @confd_dir -%> +Include <%= @vhost_load_dir %>/*.conf <% end -%> <% if @error_documents -%> diff --git a/templates/mod/php.conf.erb b/templates/mod/php5.conf.erb similarity index 100% rename from templates/mod/php.conf.erb rename to templates/mod/php5.conf.erb