This repository has been archived by the owner on Feb 13, 2020. It is now read-only.
forked from voxpupuli/puppet-r10k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook_spec.rb
177 lines (164 loc) · 4.72 KB
/
webhook_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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
require 'spec_helper'
describe 'r10k::webhook', type: :class do
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
context 'Puppet Enterprise 3.8 with the mcollective webhook' do
let :params do
{
use_mcollective: true
}
end
let :facts do
facts.merge(
is_pe: true,
pe_version: '3.8.0',
puppetversion: '3.8.0'
)
end
it do
is_expected.to contain_package('sinatra').with(
ensure: 'installed',
provider: 'pe_gem'
)
end
it do
is_expected.to contain_file('peadmin-cert.pem').with(
path: '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem',
ensure: 'file',
owner: 'peadmin',
group: 'peadmin',
mode: '0644'
)
end
end
context 'Puppet Enterprise 3.8 with no Webhook' do
let :params do
{
ensure: false
}
end
let :facts do
facts.merge(
is_pe: 'true',
pe_version: '3.8.0',
puppetversion: '3.8.0'
)
end
it { is_expected.to contain_file('/var/log/webhook/access.log').with(ensure: 'absent') }
it { is_expected.to contain_file('/var/log/webhook').with(ensure: 'absent') }
it { is_expected.to contain_file('/var/run/webhook').with(ensure: 'absent') }
it { is_expected.to contain_file('webhook_init_script').with(ensure: 'absent') }
end
context 'Puppet Enterprise 3.8 with a non-mcollective webhook' do
let :params do
{
use_mcollective: false
}
end
let :facts do
facts.merge(
is_pe: 'true',
pe_version: '3.8.0',
puppetversion: '3.8.0'
)
end
it do
is_expected.to contain_package('sinatra').with(
ensure: 'installed',
provider: 'pe_gem'
)
end
it { is_expected.not_to contain_file('peadmin-cert.pem').with(path: '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem') }
end
context 'Puppet FOSS 4.x with the mcollective webhook' do
let :params do
{
use_mcollective: true
}
end
let :facts do
facts.merge(
puppetversion: '4.8.0'
)
end
it do
is_expected.to contain_package('sinatra').with(
ensure: 'installed',
provider: 'puppet_gem'
)
end
it { is_expected.not_to contain_file('peadmin-cert.pem').with(path: '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem') }
end
context 'Puppet FOSS 3.7.1 with a webhook' do
let :facts do
facts.merge(
puppetversion: '3.7.1'
)
end
it do
is_expected.to contain_package('sinatra').with(
ensure: 'installed',
provider: 'gem'
)
end
it do
is_expected.to contain_package('webrick').with(
ensure: 'installed',
provider: 'gem'
)
end
it do
is_expected.to contain_package('rack').with(
ensure: 'installed',
provider: 'gem'
)
end
it do
is_expected.to contain_package('json').with(
ensure: 'installed',
provider: 'gem'
)
end
it { is_expected.not_to contain_file('peadmin-cert.pem').with(path: '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem') }
end
end
end
# Tests outside of the supported OS loop
context 'Enterprise Linux 7 host with systemd' do
let :facts do
{
osfamily: 'RedHat',
operatingsystemmajrelease: '7',
operatingsystem: 'Centos',
is_pe: 'true',
pe_version: '3.7.0'
}
end
it do
is_expected.to contain_file('webhook_init_script').with(
path: '/usr/lib/systemd/system/webhook.service',
content: %r{\[Unit\]}
)
end
end
context 'Non Enteprise Linux 7 host' do
let :facts do
{
osfamily: 'RedHat',
operatingsystemmajrelease: '6',
operatingsystem: 'Centos',
is_pe: 'true',
pe_version: '3.7.0'
}
end
it do
is_expected.to contain_file('webhook_init_script').with(
path: '/etc/init.d/webhook',
content: %r{#!\/bin\/bash}
)
end
end
end