forked from theforeman/puppet-puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuppet_init_spec.rb
150 lines (122 loc) · 4.43 KB
/
puppet_init_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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
require 'spec_helper'
describe 'puppet' do
on_supported_os.each do |os, facts|
context "on #{os}" do
case facts[:osfamily]
when 'FreeBSD'
puppet_major = facts[:puppetversion].to_i
puppet_concat = '/usr/local/etc/puppet/puppet.conf'
puppet_directory = '/usr/local/etc/puppet'
puppet_package = "puppet#{puppet_major}"
puppetconf_mode = '0644'
when 'windows'
puppet_concat = 'C:/ProgramData/PuppetLabs/puppet/etc/puppet.conf'
puppet_directory = 'C:/ProgramData/PuppetLabs/puppet/etc'
puppet_package = 'puppet-agent'
puppetconf_mode = '0674'
when 'Archlinux'
puppet_concat = '/etc/puppetlabs/puppet/puppet.conf'
puppet_directory = '/etc/puppetlabs/puppet'
puppet_package = 'puppet'
puppetconf_mode = '0644'
else
puppet_concat = '/etc/puppetlabs/puppet/puppet.conf'
puppet_directory = '/etc/puppetlabs/puppet'
puppet_package = 'puppet-agent'
puppetconf_mode = '0644'
end
let :facts do
facts
end
describe 'with no custom parameters' do
it { is_expected.to compile.with_all_deps unless facts[:osfamily] == 'windows' }
it { should contain_class('puppet::agent') }
it { should contain_class('puppet::config') }
it { should_not contain_class('puppet::server') }
it { should contain_file(puppet_directory).with_ensure('directory') }
it { should contain_concat(puppet_concat).with_mode(puppetconf_mode) }
it { should contain_package(puppet_package)
.with_ensure('present')
.with_install_options(nil)
}
end
describe 'with server => true', :unless => unsupported_puppetserver_osfamily(facts[:osfamily]) do
let :params do {
:server => true,
} end
it { is_expected.to compile.with_all_deps }
it { should contain_class('puppet::server') }
it { should contain_class('puppet::agent::service').that_requires('Class[puppet::server]') }
end
describe 'with empty ca_server' do
let :params do {
:ca_server => '',
} end
it { should_not contain_puppet__config__main('ca_server') }
end
describe 'with ca_server' do
let :params do {
:ca_server => 'ca.example.org',
} end
it { should contain_puppet__config__main('ca_server').with_value('ca.example.org') }
end
describe 'with undef ca_port' do
let :params do {
:ca_port => :undef,
} end
it { should_not contain_puppet__config__main('ca_port') }
end
describe 'with ca_port' do
let :params do {
:ca_port => 8140,
} end
it { should contain_puppet__config__main('ca_port').with_value(8140) }
end
describe 'with undef certificate_revocation' do
let :params do {
:certificate_revocation => :undef,
} end
it { should_not contain_puppet__config__main('certificate_revocation') }
end
describe 'with certificate_revocation' do
let :params do {
:certificate_revocation => 'leaf',
} end
it { should contain_puppet__config__main('certificate_revocation').with_value('leaf') }
end
describe 'with puppetconf_mode' do
let :params do {
:puppetconf_mode => '0640',
} end
it { should contain_concat(puppet_concat).with_mode('0640') }
end
# compilation is broken due to paths
context 'on non-windows', unless: facts[:osfamily] == 'windows' do
describe 'with package_source => Httpurl' do
let :params do {
:package_source => 'https://example.com:123/test'
} end
it { is_expected.to compile }
end
describe 'with package_source => Unixpath' do
let :params do {
:package_source => '/test/folder/path/source.rpm'
} end
it { is_expected.to compile }
end
describe 'with package_source => Windowspath' do
let :params do {
:package_source => 'C:\test\folder\path\source.exe'
} end
it { is_expected.to compile }
end
describe 'with package_source => foo' do
let :params do {
:package_source => 'foo'
} end
it { is_expected.not_to compile }
end
end
end
end
end