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

Allow setting the slave name, default to the fqdn at runtime #185

Merged
merged 1 commit into from
Sep 23, 2014
Merged
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
4 changes: 4 additions & 0 deletions manifests/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#
# === Parameters
#
# [*slave_name*]
# Specify the name of the slave. Not required, by default it will use the fqdn.
#
# [*masterurl*]
# Specify the URL of the master server. Not required, the plugin will do a UDP autodiscovery. If specified, the autodiscovery will be skipped.
#
Expand Down Expand Up @@ -62,6 +65,7 @@
#
# Copyright 2013 Matthew Barr , but can be used for anything by anyone..
class jenkins::slave (
$slave_name = undef,
$masterurl = undef,
$ui_user = undef,
$ui_pass = undef,
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/jenkins_slave_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
it { should contain_user('jenkins-slave_user').with_uid(nil) }
# Let the different platform blocks define `slave_runtime_file` separately below
it { should contain_file(slave_runtime_file).with_content(/^FSROOT="\/home\/jenkins-slave"$/) }
it { should contain_file(slave_runtime_file).without_content(/ -name /) }

describe 'with ssl verification disabled' do
let(:params) { { :disable_ssl_verification => true } }
Expand All @@ -32,18 +33,32 @@
end
end

shared_examples 'using slave_name' do
it { should contain_file(slave_runtime_file).with_content(/^CLIENT_NAME="jenkins-slave"$/) }
end

describe 'RedHat' do
let(:facts) { { :osfamily => 'RedHat', :operatingsystem => 'CentOS' } }
let(:slave_runtime_file) { '/etc/sysconfig/jenkins-slave' }

it_behaves_like 'a jenkins::slave catalog'

describe 'with slave_name' do
let(:params) { { :slave_name => 'jenkins-slave' } }
it_behaves_like 'using slave_name'
end
end

describe 'Debian' do
let(:facts) { { :osfamily => 'Debian', :lsbdistid => 'debian', :lsbdistcodename => 'natty', :operatingsystem => 'Debian' } }
let(:slave_runtime_file) { '/etc/default/jenkins-slave' }

it_behaves_like 'a jenkins::slave catalog'

describe 'with slave_name' do
let(:params) { { :slave_name => 'jenkins-slave' } }
it_behaves_like 'using slave_name'
end
end

describe 'Unknown' do
Expand Down
2 changes: 1 addition & 1 deletion templates/jenkins-slave-defaults.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LABELS="<%= @labels -%>"

EXECUTORS=<%= @executors -%>

CLIENT_NAME="<%= @fqdn -%>"
CLIENT_NAME="<%= @slave_name -%>"

FSROOT="<%= @slave_home -%>"

Expand Down