Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to disable SSL verification on Swarm clients #117

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions manifests/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# [*masterurl*]
# Specify the URL of the master server. Not required, the plugin will do a UDP autodiscovery. If specified, the autodiscovery will be skipped.
#
# [*disable_ssl_verification*]
# Disable SSL certificate verification on Swarm clients. Not required, but is necessary if you're using a self-signed SSL cert. Defaults to false.
#
# [*ui_user*] & [*ui_pass*]
# User name & password for the Jenkins UI. Not required, but may be ncessary for your config, depending on your security model.
#
Expand Down Expand Up @@ -59,19 +62,20 @@
#
# Copyright 2013 Matthew Barr , but can be used for anything by anyone..
class jenkins::slave (
$masterurl = undef,
$ui_user = undef,
$ui_pass = undef,
$version = $jenkins::params::swarm_version,
$executors = 2,
$manage_slave_user = true,
$slave_user = 'jenkins-slave',
$slave_uid = undef,
$slave_home = '/home/jenkins-slave',
$slave_mode = 'normal',
$labels = undef,
$install_java = $jenkins::params::install_java,
$enable = true
$masterurl = undef,
$ui_user = undef,
$ui_pass = undef,
$version = $jenkins::params::swarm_version,
$executors = 2,
$manage_slave_user = true,
$slave_user = 'jenkins-slave',
$slave_uid = undef,
$slave_home = '/home/jenkins-slave',
$slave_mode = 'normal',
$labels = undef,
$disable_ssl_verification = false,
$install_java = $jenkins::params::install_java,
$enable = true
) inherits jenkins::params {

$client_jar = "swarm-client-${version}-jar-with-dependencies.jar"
Expand Down Expand Up @@ -138,6 +142,14 @@
$labels_flag = ''
}

#If disable_ssl_verification is set to true...
if $disable_ssl_verification {
#...add the flag to disable SSL verification to the start command line of the init script:
$disable_ssl_verification_flag = "-disableSslVerification"
} else { #...else, don't insert the flag:
$disable_ssl_verification_flag = ''
}

file { '/etc/init.d/jenkins-slave':
ensure => 'file',
mode => '0700',
Expand Down
2 changes: 1 addition & 1 deletion templates/jenkins-slave.erb
Original file line number Diff line number Diff line change
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 -%> -mode <%= @slave_mode -%> -name <%= @fqdn -%> -executors <%= @executors -%> <%= @masterurl_flag -%> <%= @labels_flag -%> &'
runuser - <%= @slave_user -%> -c 'java -jar <%= @slave_home -%>/<%= @client_jar -%> <%= @ui_user_flag -%> <%= @ui_pass_flag -%> -mode <%= @slave_mode -%> -name <%= @fqdn -%> -executors <%= @executors -%> <%= @masterurl_flag -%> <%= @labels_flag -%> <%= @disable_ssl_verification_flag -%> &'
pgrep -f -u <%= @slave_user -%> <%= @client_jar -%> > $PID_FILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
Expand Down