Skip to content

Commit 1e967eb

Browse files
committed
Add support for agent http_proxy_host and http_proxy_port options
Conflicts: manifests/agent.pp
1 parent 2093aa3 commit 1e967eb

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

manifests/agent.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
# ['templatedir'] - Template dir, if unset it will remove the setting.
2828
# ['configtimeout'] - How long the client should wait for the configuration to be retrieved before considering it a failure
2929
# ['stringify_facts'] - Wether puppet transforms structured facts in strings or no. Defaults to true in puppet < 4, deprecated in puppet >=4 (and will default to false)
30+
# ['http_proxy_host'] - The hostname of an HTTP proxy to use for agent -> master connections
31+
# ['http_proxy_port'] - The port to use when puppet uses an HTTP proxy
3032
#
3133
# Actions:
3234
# - Install and configures the puppet agent
@@ -76,6 +78,8 @@
7678
$agent_noop = undef,
7779
$usecacheonfailure = undef,
7880
$certname = undef,
81+
$http_proxy_host = undef,
82+
$http_proxy_port = undef,
7983
) inherits puppet::params {
8084

8185
if ! defined(User[$::puppet::params::puppet_user]) {
@@ -375,4 +379,18 @@
375379
section => 'main',
376380
}
377381
}
382+
if $http_proxy_host != undef {
383+
ini_setting {'puppetagenthttpproxyhost':
384+
ensure => present,
385+
setting => 'http_proxy_host',
386+
value => $http_proxy_host,
387+
}
388+
}
389+
if $http_proxy_port != undef {
390+
ini_setting {'puppetagenthttpproxyport':
391+
ensure => present,
392+
setting => 'http_proxy_port',
393+
value => $http_proxy_port,
394+
}
395+
}
378396
}

spec/classes/puppet_agent_spec.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,4 +575,56 @@
575575
}
576576
end
577577
end
578+
describe 'puppetagenthttpproxyhost' do
579+
let(:facts) do
580+
{
581+
:osfamily => 'RedHat',
582+
:operatingsystem => 'RedHat',
583+
:kernel => 'Linux'
584+
}
585+
end
586+
context 'with http_proxy_host set' do
587+
let(:params) do
588+
{
589+
:http_proxy_host => 'proxy.example.com',
590+
}
591+
end
592+
593+
it{
594+
should contain_ini_setting('puppetagenthttpproxyhost').with(
595+
:ensure => 'present',
596+
:section => 'agent',
597+
:setting => 'http_proxy_host',
598+
:value => 'proxy.example.com',
599+
:path => '/etc/puppet/puppet.conf'
600+
)
601+
}
602+
end
603+
end
604+
describe 'puppetagenthttpproxyport' do
605+
let(:facts) do
606+
{
607+
:osfamily => 'RedHat',
608+
:operatingsystem => 'RedHat',
609+
:kernel => 'Linux'
610+
}
611+
end
612+
context 'with http_proxy_port set' do
613+
let(:params) do
614+
{
615+
:http_proxy_port => '1234',
616+
}
617+
end
618+
619+
it{
620+
should contain_ini_setting('puppetagenthttpproxyport').with(
621+
:ensure => 'present',
622+
:section => 'agent',
623+
:setting => 'http_proxy_port',
624+
:value => '1234',
625+
:path => '/etc/puppet/puppet.conf'
626+
)
627+
}
628+
end
629+
end
578630
end

0 commit comments

Comments
 (0)