Skip to content

Commit 44a63bd

Browse files
author
Stephen
committed
Allow agent to remove templatedir as it's deprecated
1 parent a34a713 commit 44a63bd

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

manifests/agent.pp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# ['listen'] - If puppet agent should listen for connections
2424
# ['reportserver'] - The server to send transaction reports to.
2525
# ['digest_algorithm'] - The algorithm to use for file digests.
26+
# ['templatedir'] - Template dir, if unset it will remove the setting.
2627
#
2728
# Actions:
2829
# - Install and configures the puppet agent
@@ -54,6 +55,7 @@
5455
$use_srv_records = false,
5556
$srv_domain = undef,
5657
$ordering = undef,
58+
$templatedir = '$confdir/templates',
5759
$trusted_node_data = undef,
5860
$listen = false,
5961
$reportserver = '$server',
@@ -284,4 +286,21 @@
284286
setting => 'digest_algorithm',
285287
value => $digest_algorithm,
286288
}
289+
if ($templatedir != undef) and ($templatedir != 'undef')
290+
{
291+
ini_setting {'puppetagenttemplatedir':
292+
ensure => present,
293+
setting => 'templatedir',
294+
section => 'main',
295+
value => $templatedir,
296+
}
297+
}
298+
else
299+
{
300+
ini_setting {'puppetagenttemplatedir':
301+
ensure => absent,
302+
setting => 'templatedir',
303+
section => 'main',
304+
}
305+
}
287306
}

spec/classes/puppet_agent_spec.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,66 @@
444444
}
445445
end
446446
end
447+
describe 'Trusted fact' do
448+
let(:facts) do
449+
{
450+
:osfamily => 'RedHat',
451+
:operatingsystem => 'RedHat',
452+
:kernel => 'Linux'
453+
}
454+
end
455+
context 'with templatedir set' do
456+
let(:params) do
457+
{
458+
:puppet_server => 'test.exaple.com',
459+
:puppet_agent_service => 'puppet',
460+
:puppet_agent_package => 'puppet',
461+
:version => '/etc/puppet/manifests/site.pp',
462+
:puppet_run_style => 'cron',
463+
:splay => 'true',
464+
:environment => 'production',
465+
:puppet_run_interval => 30,
466+
:puppet_server_port => 8140,
467+
:use_srv_records => false,
468+
}
469+
end
470+
471+
it{
472+
should contain_ini_setting('puppetagenttemplatedir').with(
473+
:ensure => 'present',
474+
:section => 'main',
475+
:setting => 'templatedir',
476+
:value => '$confdir/templates',
477+
:path => '/etc/puppet/puppet.conf'
478+
)
479+
}
480+
end
481+
482+
context 'with templatedir not set' do
483+
let(:params) do
484+
{
485+
:puppet_server => 'test.exaple.com',
486+
:puppet_agent_service => 'puppet',
487+
:puppet_agent_package => 'puppet',
488+
:version => '/etc/puppet/manifests/site.pp',
489+
:puppet_run_style => 'cron',
490+
:splay => 'true',
491+
:environment => 'production',
492+
:puppet_run_interval => 30,
493+
:puppet_server_port => 8140,
494+
:use_srv_records => false,
495+
:templatedir => 'undef'
496+
}
497+
end
498+
499+
it{
500+
should contain_ini_setting('puppetagenttemplatedir').with(
501+
:ensure => 'absent',
502+
:section => 'main',
503+
:setting => 'templatedir',
504+
:path => '/etc/puppet/puppet.conf'
505+
)
506+
}
507+
end
508+
end
447509
end

0 commit comments

Comments
 (0)