Customize jenkins.default by template

Turn jenkins.default to a template. This enables to customize it
easily. This is useful for downstream projects where it is needed
to tune jenkins.default parameters. Either Pass the required
parameter to jenkins class or pass a customized jenkins.default
template in jenkins_default
For backward compatibility, default values are set in the class
parameters list.

Change-Id: Ice0e4ffa2fffd041d8bcc4a0b323ffae7ba2b0c8
This commit is contained in:
Isaac Beckman 2015-12-31 15:07:40 +02:00
parent 5991ee6a62
commit f20dc945dd
2 changed files with 40 additions and 11 deletions

View File

@ -1,5 +1,12 @@
# == Class: jenkins::master
#
# This class will install and configure Jenkins master
#
# Setting configuration parameters is done by either setting
# $jenkins_default to point to a customized file/template or by
# setting the specific parameters in the class
#
class jenkins::master(
$logo = '',
$vhost_name = $::fqdn,
@ -12,9 +19,13 @@ class jenkins::master(
$ssl_chain_file_contents = '', # If left empty puppet will not create file.
$jenkins_ssh_private_key = '',
$jenkins_ssh_public_key = '',
$jenkins_default = 'puppet:///modules/jenkins/jenkins.default',
$jenkins_default = undef, # Can be a custom template
$jenkins_version = 'present',
$java_args = '"-Xloggc:/var/log/jenkins/gc.log -XX:+PrintGCDetails -Xmx12g -Dorg.kohsuke.stapler.compression.CompressionFilter.disabled=true -Djava.util.logging.config.file=/var/lib/jenkins/logger.conf"',
$jenkins_deb_url_base = 'http://pkg.jenkins.io/debian/binary',
$run_standalone = true,
$max_open_files = 8192,
$http_port = 8080,
) {
include ::pip
include ::apt
@ -156,12 +167,30 @@ class jenkins::master(
command => 'apt-get update',
}
file { '/etc/default/jenkins':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
source => $jenkins_default,
# Template uses:
# - $java_args
# - $run_standalone
# - $max_open_files
# - $http_port
if ! $jenkins_default {
$jenkins_template = 'jenkins/jenkins.default.erb'
file { '/etc/default/jenkins':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template($jenkins_template),
}
}
else {
file { '/etc/default/jenkins':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
source => $jenkins_default
}
}
file { '/var/lib/jenkins':

View File

@ -11,7 +11,7 @@ JAVA=/usr/bin/java
#JAVA_ARGS="-Djava.net.preferIPv4Stack=true" # make jenkins listen on IPv4 address
# Disable compression as zip deflation threads eat CPU time.
# https://issues.jenkins-ci.org/browse/JENKINS-14362
JAVA_ARGS="-Xloggc:/var/log/jenkins/gc.log -XX:+PrintGCDetails -Xmx12g -Dorg.kohsuke.stapler.compression.CompressionFilter.disabled=true -Djava.util.logging.config.file=/var/lib/jenkins/logger.conf"
JAVA_ARGS=<%= @java_args %>
PIDFILE=/var/run/jenkins/jenkins.pid
@ -27,7 +27,7 @@ JENKINS_HOME=/var/lib/jenkins
# set this to false if you don't want Hudson to run by itself
# in this set up, you are expected to provide a servlet container
# to host jenkins.
RUN_STANDALONE=true
RUN_STANDALONE=<%= @run_standalone %>
# log location. this may be a syslog facility.priority
JENKINS_LOG=/var/log/jenkins/$NAME.log
@ -38,10 +38,10 @@ JENKINS_LOG=/var/log/jenkins/$NAME.log
# this is on by default because http://github.com/jenkinsci/jenkins/commit/2fb288474e980d0e7ff9c4a3b768874835a3e92e
# reported that Ubuntu's PAM configuration doesn't include pam_limits.so, and as a result the # of file
# descriptors are forced to 1024 regardless of /etc/security/limits.conf
MAXOPENFILES=8192
MAXOPENFILES=<%= @max_open_files %>
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080
HTTP_PORT=<%= @http_port %>
# port for AJP connector (disabled by default)
AJP_PORT=-1