forked from theforeman/puppet-puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuppet_agent_spec.rb
95 lines (85 loc) · 3.07 KB
/
puppet_agent_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require 'spec_helper'
describe 'puppet::agent' do
on_os_under_test.each do |os, facts|
context "on #{os}" do
if Puppet.version < '4.0'
client_package = 'puppet'
confdir = '/etc/puppet'
case facts[:osfamily]
when 'FreeBSD'
client_package = 'puppet38'
confdir = '/usr/local/etc/puppet'
when 'windows'
client_package = 'puppet'
confdir = 'C:/ProgramData/PuppetLabs/puppet/etc'
end
additional_facts = {}
else
client_package = 'puppet-agent'
confdir = '/etc/puppetlabs/puppet'
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
case facts[:osfamily]
when 'FreeBSD'
if Puppet.version < '5.0'
client_package = 'puppet4'
else
client_package = 'puppet5'
end
confdir = '/usr/local/etc/puppet'
additional_facts = {}
when 'windows'
client_package = 'puppet-agent'
confdir = 'C:/ProgramData/PuppetLabs/puppet/etc'
additional_facts = {}
end
end
let :facts do
facts.merge(additional_facts)
end
describe 'with no custom parameters' do
let :pre_condition do
"class {'puppet': agent => true}"
end
it { should contain_class('puppet::agent::install') }
it { should contain_class('puppet::agent::config') }
it { should contain_class('puppet::agent::service') }
it { should contain_file(confdir).with_ensure('directory') }
it { should contain_concat("#{confdir}/puppet.conf") }
it { should contain_package(client_package).with_ensure('present') }
it do
should contain_concat__fragment('puppet.conf_agent').
with_content(/^\[agent\]/).
with({})
end
it do
should_not contain_puppet__config__agent('prerun_command')
end
it do
should_not contain_puppet__config__agent('postrun_command')
end
end
describe 'set prerun_command will be included in config' do
let(:pre_condition) { "class {'puppet': agent => true, prerun_command => '/my/prerun'}" }
it do
should contain_puppet__config__agent('prerun_command').with({'value' => '/my/prerun'})
end
end
describe 'set postrun_command will be included in config' do
let(:pre_condition) { "class {'puppet': agent => true, postrun_command => '/my/postrun'}" }
it do
should contain_puppet__config__agent('postrun_command').with({'value' => '/my/postrun'})
end
end
describe 'with additional settings' do
let :pre_condition do
"class {'puppet':
agent_additional_settings => {ignoreschedules => true},
}"
end
it 'should configure puppet.conf' do
should contain_puppet__config__agent('ignoreschedules').with({'value' => 'true'})
end
end
end
end
end