Skip to content

Commit

Permalink
Merge pull request voxpupuli#15 from dcrissman/merged
Browse files Browse the repository at this point in the history
On slave, add labels and ability to control java version. On master node, add ability to disable the configuration of the firewall.
  • Loading branch information
matthewbarr committed Aug 8, 2013
2 parents a9dc677 + b25679c commit 5f6409e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 4 additions & 2 deletions manifests/firewall.pp
Expand Up @@ -2,13 +2,15 @@
# jenkins::firewall class integrates with the puppetlabs-firewall module for
# opening the port to Jenkins automatically
#
class jenkins::firewall {
class jenkins::firewall(
$port = 8080
) {
if defined('::firewall') {
firewall {
'500 allow Jenkins inbound traffic':
action => 'accept',
state => 'NEW',
dport => [8080],
dport => [$port],
proto => 'tcp',
}
}
Expand Down
6 changes: 5 additions & 1 deletion manifests/init.pp
Expand Up @@ -55,6 +55,7 @@
$repo = 1,
$config_hash = undef,
$plugin_hash = undef,
$configure_firewall = true
) {

class {
Expand All @@ -75,7 +76,10 @@
}

include jenkins::service
include jenkins::firewall

if($configure_firewall){
include jenkins::firewall
}

Class['jenkins::repo'] ->
Class['jenkins::package'] ->
Expand Down
14 changes: 11 additions & 3 deletions manifests/slave.pp
Expand Up @@ -14,18 +14,20 @@
$manage_slave_user = 1,
$slave_user = 'jenkins-slave',
$slave_uid = undef,
$slave_home = '/home/jenkins-slave'
$slave_home = '/home/jenkins-slave',
$labels = undef,
$java_version = '1.6.0'
) {

$client_jar = "swarm-client-${version}-jar-with-dependencies.jar"
$client_url = "http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/${version}/"

case $::osfamily {
'RedHat': {
$java_package = 'java-1.6.0-openjdk'
$java_package = "java-${$java_version}-openjdk"
}
'Linux': {
$java_package = 'java-1.6.0-openjdk'
$java_package = "java-${$java_version}-openjdk"
}
'Debian': {
#needs java package for debian.
Expand Down Expand Up @@ -93,6 +95,12 @@
$masterurl_flag = ''
}

if $labels {
$labels_flag = "-labels \"${labels}\""
} else {
$labels_flag = ''
}

file { '/etc/init.d/jenkins-slave':
ensure => 'file',
mode => '0700',
Expand Down
2 changes: 1 addition & 1 deletion templates/jenkins-slave.erb
Expand Up @@ -15,7 +15,7 @@ LOCK_FILE=/var/lock/jenkins-slave

slave_start() {
echo Starting Jenkins Slave...
runuser - <%= slave_user -%> -c 'java -jar <%= slave_home -%>/<%= client_jar -%> <%= ui_user_flag -%> <%= ui_pass_flag -%> -name <%= fqdn -%> -executors <%= executors -%> <%= masterurl_flag -%> &'
runuser - <%= slave_user -%> -c 'java -jar <%= slave_home -%>/<%= client_jar -%> <%= ui_user_flag -%> <%= ui_pass_flag -%> -name <%= fqdn -%> -executors <%= executors -%> <%= masterurl_flag -%> <%= labels_flag -%> &'
pgrep -f -u <%= slave_user -%> <%= client_jar -%> > $PID_FILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
Expand Down

0 comments on commit 5f6409e

Please sign in to comment.