Skip to content

Commit

Permalink
add _additional_includes.erb
Browse files Browse the repository at this point in the history
  • Loading branch information
cristifalcas committed Feb 9, 2015
1 parent df3f136 commit 5bc940d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,10 @@ Determines whether the vhost creates a Listen statement. The default value is 't

Setting `add_listen` to 'false' stops the vhost from creating a Listen statement, and this is important when you combine vhosts that are not passed an `ip` parameter with vhosts that *are* passed the `ip` parameter.

#####`use_optional_includes`

Specifies if for apache > 2.4 it should use IncludeOptional instead of Include.

#####`additional_includes`

Specifies paths to additional static, vhost-specific Apache configuration files. Useful for implementing a unique, custom configuration not supported by this module. Can be an array. Defaults to '[]'.
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
$trace_enable = 'On',
$allow_encoded_slashes = undef,
$package_ensure = 'installed',
$use_optional_includes = $::apache::params::use_optional_includes,
) inherits ::apache::params {
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)
validate_bool($service_manage)
validate_bool($use_optional_includes)

$valid_mpms_re = $apache_version ? {
'2.4' => '(event|itk|peruser|prefork|worker)',
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

# The default error log level
$log_level = 'warn'
$use_optional_includes = false

if $::operatingsystem == 'Ubuntu' and $::lsbdistrelease == '10.04' {
$verify_command = '/usr/sbin/apache2ctl -t'
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/apache_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class { 'apache': httpd_dir => '/tmp', service_ensure => stopped }
describe 'confd_dir' do
describe 'setup' do
it 'applies cleanly' do
pp = "class { 'apache': confd_dir => '/tmp/root', service_ensure => stopped }"
pp = "class { 'apache': confd_dir => '/tmp/root', service_ensure => stopped, use_optional_includes => true }"
apply_manifest(pp, :catch_failures => true)
end
end
Expand Down
10 changes: 8 additions & 2 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@

context "with Apache version >= 2.4" do
let :params do
{ :apache_version => '2.4' }
{
:apache_version => '2.4',
:use_optional_includes => true
}
end

it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^IncludeOptional "/etc/apache2/conf\.d/\*\.conf"$} }
Expand Down Expand Up @@ -315,7 +318,10 @@

context "with Apache version >= 2.4" do
let :params do
{ :apache_version => '2.4' }
{
:apache_version => '2.4',
:use_optional_includes => true
}
end

it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} }
Expand Down
2 changes: 1 addition & 1 deletion templates/httpd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ LogFormat "<%= format -%>" <%= nickname %>
<%- end -%>
<% end -%>

<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 && @use_optional_includes -%>
IncludeOptional "<%= @confd_dir %>/*.conf"
<%- else -%>
Include "<%= @confd_dir %>/*.conf"
Expand Down
9 changes: 7 additions & 2 deletions templates/vhost/_additional_includes.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<% Array(@additional_includes).each do |include| -%>

## Load additional static includes
Include "<%= include %>"
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 && @use_optional_includes -%>
IncludeOptional "<%= include %>"
<%- else -%>
Include "<%= include %>"
<%- end -%>

<% end -%>

0 comments on commit 5bc940d

Please sign in to comment.