Manage cgitrc config file

In same way as other config files, add a sane
default list, and allow manifest to override that
list, to configure cgitrc from the manifest.

Change-Id: I5c8ef0e7036c4b7a33aa12dc502c048af0499dda
This commit is contained in:
Yolanda Robla 2015-04-30 17:36:19 +02:00
parent f6ec8a3971
commit 2d2408010b
2 changed files with 42 additions and 1 deletions

View File

@ -28,8 +28,10 @@ class cgit(
$ssl_chain_file_contents = '', # If left empty puppet will not create file.
$behind_proxy = false,
$cgit_timeout = false,
$manage_cgitrc = false,
$prefork_settings = {}, # override the prefork worker settings
$mpm_settings = {} # override the mpm worker settings
$mpm_settings = {}, # override the mpm worker settings
$cgitrc_settings = {}
) {
validate_hash($prefork_settings)
validate_hash($mpm_settings)
@ -49,6 +51,27 @@ class cgit(
'ThreadsPerChild' => 25,
'MaxRequestsPerChild' => 0
}
$default_cgitrc_settings = {
'cache-size' => 1000,
'cache-repo-ttl' => 1,
'cache-root-ttl' => 1,
'clone-prefix' => '',
'enable-index-owner' => 0,
'enable-index-links' => 1,
'enable-http-clone' => 0,
'max-stats' => 'quarter',
'side-by-side-diffs' => 1,
'mimetype.gif' => 'image/gif',
'mimetype.html' => 'text/html',
'mimetype.jpg' => 'image/jpeg',
'mimetype.jpeg' => 'image/jpeg',
'mimetype.pdf' => 'application/pdf',
'mimetype.png' => 'image/png',
'mimetype.svg' => 'image/svg+xml',
'source-filter' => '/usr/libexec/cgit/filters/syntax-highlighting.sh',
'max-repo-count' => 600,
'include' => '/etc/cgitrepos'
}
if $behind_proxy == true {
$http_port = 8080
$https_port = 4443
@ -63,6 +86,7 @@ class cgit(
# merge settings with defaults
$final_mpm_settings = merge($default_mpm_settings, $mpm_settings)
$final_prefork_settings = merge($default_prefork_settings, $prefork_settings)
$final_cgitrc_settings = merge($default_cgitrc_settings, $cgitrc_settings)
include apache
@ -196,4 +220,14 @@ class cgit(
before => Apache::Vhost[$vhost_name],
}
}
if $manage_cgitrc {
file { '/etc/cgitrc':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template('cgit/cgitrc.erb')
}
}
}

7
templates/cgitrc.erb Normal file
View File

@ -0,0 +1,7 @@
#
# See cgitrc(5) or /usr/share/doc/cgit-*/cgitrc.5.html for details
#
<% final_cgitrc_settings.keys.sort.each do |setting| -%>
<%= setting -%>=<%= final_cgitrc_settings[setting] %>
<% end -%>