diff --git a/manifests/init.pp b/manifests/init.pp
index 13f77b4..b40dfb5 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -29,6 +29,10 @@ class nodepool (
$image_log_document_root = '/var/log/nodepool/image',
$image_log_periodic_cleanup = false,
$enable_image_log_via_http = false,
+ $upload_log_document_root = '/var/log/nodepool/upload',
+ $upload_log_periodic_cleanup = false,
+ # note : not currently supported
+ $enable_upload_log_via_http = false,
$environment = {},
# enable sudo for nodepool user. Useful for using dib with nodepool
$sudo = true,
@@ -342,8 +346,24 @@ class nodepool (
require => File['/etc/init.d/nodepool'],
}
- if $enable_image_log_via_http == true {
- # Setup apache for image log access
+ if $image_log_document_root == $upload_log_document_root {
+ # It makes no sense to ask to not export build or upload logs, but
+ # then have them log to the same directory that will be exported.
+ if (($enable_image_log_via_http and !$enable_upload_log_via_http) or
+ ($enable_upload_log_via_http and !$enable_image_log_via_http)
+ ) {
+ fail('Unexported logs in same directory as exported logs!')
+ }
+ }
+
+ # we only need to create the upload log dir if it is separate to the
+ # image log.
+ $separate_upload_log_dir =
+ $image_log_document_root != $upload_log_document_root
+
+ if $enable_image_log_via_http == true or
+ $enable_upload_log_via_http == true {
+ # Setup apache for log access
include ::httpd
::httpd::vhost { $vhost_name:
@@ -376,6 +396,21 @@ class nodepool (
}
}
+ # we only need this if it is different to the image_log
+ if $separate_upload_log_dir
+ {
+ file { $upload_log_document_root:
+ ensure => directory,
+ mode => '0755',
+ owner => 'nodepool',
+ group => 'nodepool',
+ require => [
+ User['nodepool'],
+ File['/var/log/nodepool'],
+ ],
+ }
+ }
+
# run a cleanup on the image log directory to cleanup logs for
# images that are no longer being built
if $image_log_periodic_cleanup == true {
@@ -388,6 +423,18 @@ class nodepool (
}
}
+ # run a cleanup on the upload log directory to cleanup logs for
+ # providers that are no long uploading
+ if $upload_log_periodic_cleanup == true {
+ cron { 'upload_log_cleanup':
+ user => 'nodepool',
+ hour => '1',
+ minute => '0',
+ command => "find ${upload_log_document_root} \\( -name '*.log' -o -name '*.log.*' \\) -mtime +7 -execdir rm {} \\;",
+ environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
+ }
+ }
+
if $sudo == true {
$sudo_file_ensure = present
}
diff --git a/templates/nodepool-log.vhost.erb b/templates/nodepool-log.vhost.erb
index 63bad6c..108d050 100644
--- a/templates/nodepool-log.vhost.erb
+++ b/templates/nodepool-log.vhost.erb
@@ -2,11 +2,23 @@
ServerName <%= scope.lookupvar("nodepool::vhost_name") %>
DocumentRoot <%= scope.lookupvar("nodepool::image_log_document_root") %>
+
+ <% if scope.lookupvar("nodepool::enable_image_log_via_http") -%>
>
Options <%= scope.lookupvar("httpd::params::options") %>
AllowOverride None
Require all granted
-
+
+ <% end -%>
+
+ <% if scope.lookupvar("nodepool::enable_upload_log_via_http") and scope.lookupvar("nodepool::separate_upload_log_dir") -%>
+ Alias "/upload" <%= scope.lookupvar("nodepool::upload_log_document_root") %>
+ >
+ Options <%= scope.lookupvar("httpd::params::options") %>
+ AllowOverride None
+ Require all granted
+
+ <% end -%>
ErrorLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/nodepool_error.log
LogLevel warn