Skip to content

Commit 6158b93

Browse files
author
Stephen
committed
Add spec test for ordering and trusted facts
1 parent 4990859 commit 6158b93

File tree

2 files changed

+146
-10
lines changed

2 files changed

+146
-10
lines changed

manifests/agent.pp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# ['use_srv_records'] - Whethere to use srv records
2020
# ['srv_domain'] - Domain to request the srv records
2121
# ['ordering'] - The way the agent processes resources. New feature in puppet 3.3.0
22+
# ['trusted_node_data'] - Enable the trusted facts hash
2223
#
2324
# Actions:
2425
# - Install and configures the puppet agent
@@ -49,7 +50,8 @@
4950
$pluginsync = true,
5051
$use_srv_records = false,
5152
$srv_domain = undef,
52-
$ordering = undef
53+
$ordering = undef,
54+
$trusted_node_data = undef,
5355
) inherits puppet::params {
5456

5557
if ! defined(User[$::puppet::params::puppet_user]) {
@@ -188,17 +190,27 @@
188190
}
189191
}
190192

191-
if (($ordering) and ($::puppetversion < '3.3.0'))
193+
if $ordering != undef
192194
{
193-
fail('ordering requires puppet verions 3.3.0 or greater')
195+
$orderign_ensure = 'present'
196+
}else {
197+
$orderign_ensure = 'absent'
194198
}
195-
elsif (($ordering) and ($::puppetversion >= '3.3.0'))
199+
ini_setting {'puppetagentordering':
200+
ensure => $orderign_ensure,
201+
setting => 'ordering',
202+
value => $ordering,
203+
}
204+
if $trusted_node_data != undef
196205
{
197-
ini_setting {'puppetagentordering':
198-
ensure => present,
199-
setting => 'ordering',
200-
value => $ordering,
201-
}
206+
$trusted_node_data_ensure = 'present'
207+
}else {
208+
$trusted_node_data_ensure = 'absent'
209+
}
210+
ini_setting {'puppetagenttrusted_node_data':
211+
ensure => $trusted_node_data_ensure,
212+
setting => 'trusted_node_data',
213+
value => $trusted_node_data,
202214
}
203215

204216
ini_setting {'puppetagentenvironment':

spec/classes/puppet_agent_spec.rb

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
end
161161
end
162162
end
163-
164163
context 'on RedHat operatingsystems' do
165164
let(:facts) do
166165
{
@@ -320,4 +319,129 @@
320319
end
321320
end
322321
end
322+
323+
describe 'Ordering' do
324+
let(:facts) do
325+
{
326+
:osfamily => 'RedHat',
327+
:operatingsystem => 'RedHat',
328+
:kernel => 'Linux'
329+
}
330+
end
331+
context 'with ordering set' do
332+
let(:params) do
333+
{
334+
:puppet_server => 'test.exaple.com',
335+
:puppet_agent_service => 'puppet',
336+
:puppet_agent_package => 'puppet',
337+
:version => '/etc/puppet/manifests/site.pp',
338+
:puppet_run_style => 'cron',
339+
:splay => 'true',
340+
:environment => 'production',
341+
:ordering => 'manifest',
342+
:puppet_run_interval => 30,
343+
:puppet_server_port => 8140,
344+
:use_srv_records => false,
345+
}
346+
end
347+
348+
it{
349+
should contain_ini_setting('puppetagentordering').with(
350+
:ensure => 'present',
351+
:section => 'agent',
352+
:setting => 'ordering',
353+
:value => 'manifest',
354+
:path => '/etc/puppet/puppet.conf'
355+
)
356+
}
357+
end
358+
359+
context 'with ordering not set' do
360+
let(:params) do
361+
{
362+
:puppet_server => 'test.exaple.com',
363+
:puppet_agent_service => 'puppet',
364+
:puppet_agent_package => 'puppet',
365+
:version => '/etc/puppet/manifests/site.pp',
366+
:puppet_run_style => 'cron',
367+
:splay => 'true',
368+
:environment => 'production',
369+
:puppet_run_interval => 30,
370+
:puppet_server_port => 8140,
371+
:use_srv_records => false,
372+
}
373+
end
374+
375+
it{
376+
should contain_ini_setting('puppetagentordering').with(
377+
:ensure => 'absent',
378+
:section => 'agent',
379+
:setting => 'ordering',
380+
:path => '/etc/puppet/puppet.conf'
381+
)
382+
}
383+
end
384+
end
385+
describe 'Trusted fact' do
386+
let(:facts) do
387+
{
388+
:osfamily => 'RedHat',
389+
:operatingsystem => 'RedHat',
390+
:kernel => 'Linux'
391+
}
392+
end
393+
context 'with trusted set' do
394+
let(:params) do
395+
{
396+
:puppet_server => 'test.exaple.com',
397+
:puppet_agent_service => 'puppet',
398+
:puppet_agent_package => 'puppet',
399+
:version => '/etc/puppet/manifests/site.pp',
400+
:puppet_run_style => 'cron',
401+
:splay => 'true',
402+
:environment => 'production',
403+
:trusted_node_data => 'true',
404+
:puppet_run_interval => 30,
405+
:puppet_server_port => 8140,
406+
:use_srv_records => false,
407+
}
408+
end
409+
410+
it{
411+
should contain_ini_setting('puppetagenttrusted_node_data').with(
412+
:ensure => 'present',
413+
:section => 'agent',
414+
:setting => 'trusted_node_data',
415+
:value => 'true',
416+
:path => '/etc/puppet/puppet.conf'
417+
)
418+
}
419+
end
420+
421+
context 'with trusted not set' do
422+
let(:params) do
423+
{
424+
:puppet_server => 'test.exaple.com',
425+
:puppet_agent_service => 'puppet',
426+
:puppet_agent_package => 'puppet',
427+
:version => '/etc/puppet/manifests/site.pp',
428+
:puppet_run_style => 'cron',
429+
:splay => 'true',
430+
:environment => 'production',
431+
:puppet_run_interval => 30,
432+
:puppet_server_port => 8140,
433+
:use_srv_records => false,
434+
}
435+
end
436+
437+
it{
438+
should contain_ini_setting('puppetagenttrusted_node_data').with(
439+
:ensure => 'absent',
440+
:section => 'agent',
441+
:setting => 'trusted_node_data',
442+
:path => '/etc/puppet/puppet.conf'
443+
)
444+
}
445+
end
446+
end
323447
end

0 commit comments

Comments
 (0)