Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add access_log parameter to apache::vhost::proxy also

The vhosts should really be condensed into one template with multiple
options and/or subclasses, but until that happens we just have to repeat
code and tests.
  • Loading branch information...
commit da8ce0e1cfa9b6473c780b8d7e9d254be7130e87 1 parent 3b694f2
@hunner authored
View
13 manifests/vhost/proxy.pp
@@ -27,6 +27,7 @@
$serveraliases = '',
$ssl = false,
$vhost_name = '*',
+ $access_log = true,
$no_proxy_uris = []
) {
@@ -45,6 +46,18 @@
include apache::mod::ssl
}
+ # Template uses:
+ # - $vhost_name
+ # - $port
+ # - $ssl
+ # - $ssl_path
+ # - $srvname
+ # - $serveraliases
+ # - $no_proxy_uris
+ # - $dest
+ # - $apache::params::apache_name
+ # - $access_log
+ # - $name
file { "${priority}-${name}.conf":
path => "${apache::params::vdir}/${priority}-${name}.conf",
content => template($template),
View
16 spec/defines/vhost/proxy_spec.rb
@@ -30,7 +30,8 @@
:dest => 'example2.com',
:servername => 'example3.com',
:port => '80',
- :ssl => true
+ :ssl => true,
+ :access_log => false,
},
].each do |param_set|
@@ -70,5 +71,18 @@
] )
end
end
+
+ [true,false].each do |value|
+ describe "when access_log is #{value}" do
+ let :params do
+ default_params.merge({:access_log => value})
+ end
+
+ it "#{value ? "should" : "should not"} contain access logs" do
+ lines = subject.resource('file', "#{params[:priority]}-#{title}.conf").send(:parameters)[:content].split("\n")
+ !!lines.grep('_access.log combined').should == value
+ end
+ end
+ end
end
end
View
2  templates/vhost-proxy.conf.erb
@@ -26,6 +26,8 @@ NameVirtualHost <%= vhost_name %>:<%= port %>
ErrorLog /var/log/<%= scope.lookupvar("apache::params::apache_name") %>/<%= name %>_error.log
LogLevel warn
+<% if access_log -%>
CustomLog /var/log/<%= scope.lookupvar("apache::params::apache_name") %>/<%= name %>_access.log combined
+<% end -%>
</VirtualHost>
Please sign in to comment.
Something went wrong with that request. Please try again.