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

Proxy work #202

Merged
merged 4 commits into from
Oct 15, 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
12 changes: 12 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
# proxy_port = undef (default)
# If your environment requires a proxy host to download plugins it can be configured here
#
#
# no_proxy_list = undef (default)
# List of hostname patterns to skip using the proxy.
# - Accepts input as array only.
# - Only effective if "proxy_host" and "proxy_port" are set.
#
#
class jenkins(
$version = $jenkins::params::version,
$lts = $jenkins::params::lts,
Expand All @@ -100,6 +107,7 @@
$install_java = $jenkins::params::install_java,
$proxy_host = undef,
$proxy_port = undef,
$no_proxy_list = undef,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you add some PuppetDoc above for this parameter?

$cli = undef,
$libdir = $jenkins::params::libdir,
) inherits jenkins::params {
Expand All @@ -111,6 +119,10 @@
validate_bool($configure_firewall)
}

if $no_proxy_list {
validate_array($no_proxy_list)
}

anchor {'jenkins::begin':}
anchor {'jenkins::end':}

Expand Down
5 changes: 5 additions & 0 deletions manifests/proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

# Bring variables from Class['::jenkins'] into local scope.
$proxy_host = $::jenkins::proxy_host
$proxy_port = $::jenkins::proxy_port
$no_proxy_list = $::jenkins::no_proxy_list

file { '/var/lib/jenkins/proxy.xml':
content => template('jenkins/proxy.xml.erb'),
owner => 'jenkins',
Expand Down
12 changes: 11 additions & 1 deletion spec/classes/jenkins_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@
it { should_not contain_class('jenkins::proxy') }
end

context 'with proxy config' do
context 'with basic proxy config' do
let(:params) { { :proxy_host => 'myhost', :proxy_port => 1234 } }
it { should create_class('jenkins::proxy') }
it { should contain_file('/var/lib/jenkins/proxy.xml') }
it { should contain_file('/var/lib/jenkins/proxy.xml').with(:content => /<name>myhost<\/name>/) }
it { should contain_file('/var/lib/jenkins/proxy.xml').with(:content => /<port>1234<\/port>/) }
it { should contain_file('/var/lib/jenkins/proxy.xml').without(:content => /<noProxyHost>/) }
end

context 'with "no_proxy_list" proxy config' do
let(:params) { { :proxy_host => 'myhost', :proxy_port => 1234, :no_proxy_list => ['example.com','test.host.net'] } }
it { should create_class('jenkins::proxy') }
it { should contain_file('/var/lib/jenkins/proxy.xml') }
it { should contain_file('/var/lib/jenkins/proxy.xml').with(:content => /<name>myhost<\/name>/) }
it { should contain_file('/var/lib/jenkins/proxy.xml').with(:content => /<port>1234<\/port>/) }
it { should contain_file('/var/lib/jenkins/proxy.xml').with(:content => /<noProxyHost>example\.com\ntest\.host\.net<\/noProxyHost>/) }
end
end

Expand Down
7 changes: 5 additions & 2 deletions templates/proxy.xml.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<proxy>
<name><%= scope.lookupvar('::jenkins::proxy_host') %></name>
<port><%= scope.lookupvar('::jenkins::proxy_port') %></port>
<name><%= @proxy_host %></name>
<port><%= @proxy_port %></port>
<% if @no_proxy_list -%>
<noProxyHost><%= @no_proxy_list.join("\n") %></noProxyHost>
<% end -%>
</proxy>