forked from theforeman/puppet-foreman
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforeman_puppetmaster_spec.rb
More file actions
149 lines (130 loc) · 4.66 KB
/
foreman_puppetmaster_spec.rb
File metadata and controls
149 lines (130 loc) · 4.66 KB
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
require 'spec_helper'
describe 'foreman::puppetmaster' do
on_supported_os.each do |os, facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
context "on #{os}" do
let :facts do
facts = facts.merge({
:concat_basedir => '/tmp',
})
if facts[:osfamily] == 'RedHat' and facts[:operatingsystemmajrelease] == '6'
facts[:rubyversion] = '1.8.7'
end
facts
end
describe 'without custom parameters' do
case facts[:osfamily]
when 'RedHat'
case facts[:operatingsystemmajrelease]
when '6'
site_ruby = '/usr/lib/ruby/site_ruby/1.8'
else
site_ruby = '/usr/share/ruby/vendor_ruby'
end
json_package = 'rubygem-json'
etc_dir = '/etc'
puppet_vardir = '/var/lib/puppet'
when 'Debian'
site_ruby = '/usr/lib/ruby/vendor_ruby'
json_package = 'ruby-json'
etc_dir = '/etc'
puppet_vardir = '/var/lib/puppet'
when 'FreeBSD'
site_ruby = '/usr/local/lib/ruby/site_ruby/2.1'
json_package = 'rubygem-json'
etc_dir = '/usr/local/etc'
puppet_vardir = '/var/puppet'
end
it 'should set up reports' do
should contain_exec('Create Puppet Reports dir').with({
:command => "/bin/mkdir -p #{site_ruby}/puppet/reports",
:creates => "#{site_ruby}/puppet/reports",
})
should contain_file("#{site_ruby}/puppet/reports/foreman.rb").with({
:mode => '0644',
:owner => 'root',
:group => '0',
:source => 'puppet:///modules/foreman/foreman-report_v2.rb',
:require => 'Exec[Create Puppet Reports dir]',
})
end
it 'should set up enc' do
should contain_file("#{etc_dir}/puppet/node.rb").with({
:mode => '0550',
:owner => 'puppet',
:group => 'puppet',
:source => 'puppet:///modules/foreman/external_node_v2.rb',
})
end
it 'should install json package' do
should contain_package(json_package).with_ensure('present')
end
it 'should create puppet.yaml' do
should contain_file("#{etc_dir}/puppet/foreman.yaml").
with_content(%r{^:url: "https://#{facts[:fqdn]}"$}).
with_content(%r{^:ssl_ca: "#{puppet_vardir}/ssl/certs/ca.pem"$}).
with_content(%r{^:ssl_cert: "#{puppet_vardir}/ssl/certs/#{facts[:fqdn]}.pem"$}).
with_content(%r{^:ssl_key: "#{puppet_vardir}/ssl/private_keys/#{facts[:fqdn]}.pem"$}).
with_content(/^:user: ""$/).
with_content(/^:password: ""$/).
with_content(%r{^:puppetdir: "#{puppet_vardir}"$}).
with_content(/^:facts: true$/).
with_content(/^:timeout: 60$/).
with({
:mode => '0640',
:owner => 'root',
:group => 'puppet',
})
end
end
describe 'without reports' do
let :params do
{:reports => false}
end
it 'should not include reports' do
should_not contain_exec('Create Puppet Reports dir')
should_not contain_file('/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb')
end
end
describe 'without enc' do
let :params do
{:enc => false}
end
it 'should not include enc' do
should_not contain_file('/etc/puppet/node.rb')
end
end
end
end
# TODO on_supported_os?
context 'Amazon' do
let :facts do
{
:operatingsystem => 'Amazon',
:rubyversion => '1.8.7',
:osfamily => 'Linux',
:puppetversion => Puppet.version,
:rubysitedir => '/usr/lib/ruby/site_ruby',
}
end
describe 'without custom parameters' do
it 'should set up reports' do
should contain_exec('Create Puppet Reports dir').with({
:command => '/bin/mkdir -p /usr/lib/ruby/site_ruby/1.8/puppet/reports',
:creates => '/usr/lib/ruby/site_ruby/1.8/puppet/reports',
})
should contain_file('/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb').with({
:mode => '0644',
:owner => 'root',
:group => '0',
:source => 'puppet:///modules/foreman/foreman-report_v2.rb',
:require => 'Exec[Create Puppet Reports dir]',
})
end
it 'should install json package' do
should contain_package('rubygem-json').with_ensure('present')
end
end
end
end