beaker 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.travis.yml +8 -0
- data/README.md +6 -6
- data/beaker.gemspec +6 -2
- data/lib/beaker.rb +1 -1
- data/lib/beaker/answers.rb +34 -7
- data/lib/beaker/answers/version20.rb +124 -0
- data/lib/beaker/answers/version28.rb +21 -0
- data/lib/beaker/answers/version30.rb +24 -5
- data/lib/beaker/cli.rb +55 -41
- data/lib/beaker/command.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +320 -106
- data/lib/beaker/dsl/install_utils.rb +202 -81
- data/lib/beaker/dsl/roles.rb +40 -0
- data/lib/beaker/host.rb +28 -20
- data/lib/beaker/host/unix.rb +7 -4
- data/lib/beaker/host/unix/pkg.rb +42 -12
- data/lib/beaker/host/windows.rb +9 -5
- data/lib/beaker/host/windows/group.rb +1 -1
- data/lib/beaker/host/windows/pkg.rb +41 -8
- data/lib/beaker/hypervisor.rb +23 -10
- data/lib/beaker/hypervisor/aixer.rb +15 -19
- data/lib/beaker/hypervisor/blimper.rb +71 -72
- data/lib/beaker/hypervisor/fusion.rb +11 -10
- data/lib/beaker/hypervisor/solaris.rb +17 -23
- data/lib/beaker/hypervisor/vagrant.rb +27 -12
- data/lib/beaker/hypervisor/vcloud.rb +154 -138
- data/lib/beaker/hypervisor/vcloud_pooled.rb +97 -0
- data/lib/beaker/hypervisor/vsphere.rb +8 -5
- data/lib/beaker/hypervisor/vsphere_helper.rb +43 -33
- data/lib/beaker/network_manager.rb +16 -12
- data/lib/beaker/options/command_line_parser.rb +199 -0
- data/lib/beaker/options/hosts_file_parser.rb +39 -0
- data/lib/beaker/options/options_file_parser.rb +45 -0
- data/lib/beaker/options/options_hash.rb +294 -0
- data/lib/beaker/options/parser.rb +288 -0
- data/lib/beaker/options/pe_version_scraper.rb +35 -0
- data/lib/beaker/options/presets.rb +70 -0
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/shared/host_handler.rb +7 -2
- data/lib/beaker/shared/repetition.rb +1 -0
- data/lib/beaker/shared/timed.rb +14 -0
- data/lib/beaker/test_case.rb +2 -38
- data/lib/beaker/test_suite.rb +11 -25
- data/lib/beaker/utils/repo_control.rb +6 -8
- data/lib/beaker/utils/setup_helper.rb +9 -20
- data/spec/beaker/answers_spec.rb +109 -0
- data/spec/beaker/command_spec.rb +2 -2
- data/spec/beaker/dsl/assertions_spec.rb +1 -3
- data/spec/beaker/dsl/helpers_spec.rb +519 -84
- data/spec/beaker/dsl/install_utils_spec.rb +265 -16
- data/spec/beaker/dsl/roles_spec.rb +31 -10
- data/spec/beaker/host/windows/group_spec.rb +55 -0
- data/spec/beaker/host_spec.rb +130 -40
- data/spec/beaker/hypervisor/aixer_spec.rb +34 -0
- data/spec/beaker/hypervisor/blimper_spec.rb +77 -0
- data/spec/beaker/hypervisor/fusion_spec.rb +26 -0
- data/spec/beaker/hypervisor/hypervisor_spec.rb +66 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +39 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +105 -0
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +60 -0
- data/spec/beaker/hypervisor/vcloud_spec.rb +70 -0
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +162 -0
- data/spec/beaker/hypervisor/vsphere_spec.rb +76 -0
- data/spec/beaker/options/command_line_parser_spec.rb +25 -0
- data/spec/beaker/options/data/LATEST +1 -0
- data/spec/beaker/options/data/badyaml.cfg +21 -0
- data/spec/beaker/options/data/hosts.cfg +21 -0
- data/spec/beaker/options/data/opts.txt +6 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -0
- data/spec/beaker/options/options_file_parser_spec.rb +23 -0
- data/spec/beaker/options/options_hash_spec.rb +111 -0
- data/spec/beaker/options/parser_spec.rb +172 -0
- data/spec/beaker/options/pe_version_scaper_spec.rb +15 -0
- data/spec/beaker/options/presets_spec.rb +24 -0
- data/spec/beaker/puppet_command_spec.rb +54 -21
- data/spec/beaker/shared/error_handler_spec.rb +40 -0
- data/spec/beaker/shared/host_handler_spec.rb +104 -0
- data/spec/beaker/shared/repetition_spec.rb +72 -0
- data/spec/beaker/test_suite_spec.rb +3 -16
- data/spec/beaker/utils/ntp_control_spec.rb +42 -0
- data/spec/beaker/utils/repo_control_spec.rb +168 -0
- data/spec/beaker/utils/setup_helper_spec.rb +82 -0
- data/spec/beaker/utils/validator_spec.rb +58 -0
- data/spec/helpers.rb +97 -0
- data/spec/matchers.rb +39 -0
- data/spec/mock_blimpy.rb +48 -0
- data/spec/mock_fission.rb +60 -0
- data/spec/mock_vsphere.rb +310 -0
- data/spec/mock_vsphere_helper.rb +183 -0
- data/spec/mocks.rb +83 -0
- data/spec/spec_helper.rb +8 -1
- metadata +106 -13
- data/beaker.rb +0 -10
- data/lib/beaker/options_parsing.rb +0 -323
- data/lib/beaker/test_config.rb +0 -148
- data/spec/beaker/options_parsing_spec.rb +0 -37
- data/spec/mocks_and_helpers.rb +0 -34
data/beaker.rb
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
module Beaker
|
|
2
|
-
class Options
|
|
3
|
-
GITREPO = 'git://github.com/puppetlabs'
|
|
4
|
-
|
|
5
|
-
def self.options
|
|
6
|
-
return @options
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.repo?
|
|
10
|
-
GITREPO
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.parse_install_options(install_opts)
|
|
14
|
-
install_opts.map! { |opt|
|
|
15
|
-
case opt
|
|
16
|
-
when /^PUPPET\//
|
|
17
|
-
opt = "#{GITREPO}/puppet.git##{opt.split('/', 2)[1]}"
|
|
18
|
-
when /^FACTER\//
|
|
19
|
-
opt = "#{GITREPO}/facter.git##{opt.split('/', 2)[1]}"
|
|
20
|
-
when /^HIERA\//
|
|
21
|
-
opt = "#{GITREPO}/hiera.git##{opt.split('/', 2)[1]}"
|
|
22
|
-
when /^HIERA-PUPPET\//
|
|
23
|
-
opt = "#{GITREPO}/hiera-puppet.git##{opt.split('/', 2)[1]}"
|
|
24
|
-
end
|
|
25
|
-
opt
|
|
26
|
-
}
|
|
27
|
-
install_opts
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.file_list(paths)
|
|
31
|
-
files = []
|
|
32
|
-
if not paths.empty?
|
|
33
|
-
paths.each do |root|
|
|
34
|
-
if File.file? root then
|
|
35
|
-
files << root
|
|
36
|
-
else
|
|
37
|
-
discover_files = Dir.glob(
|
|
38
|
-
File.join(root, "**/*.rb")
|
|
39
|
-
).select { |f| File.file?(f) }
|
|
40
|
-
if discover_files.empty?
|
|
41
|
-
raise ArgumentError, "Empty directory used as an option (#{root})!"
|
|
42
|
-
end
|
|
43
|
-
files += discover_files
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
files
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def self.parse_args
|
|
51
|
-
return @options if @options
|
|
52
|
-
|
|
53
|
-
@no_args = ARGV.empty? ? true : false
|
|
54
|
-
|
|
55
|
-
@defaults = {}
|
|
56
|
-
@options = {}
|
|
57
|
-
@options_from_file = {}
|
|
58
|
-
|
|
59
|
-
optparse = OptionParser.new do|opts|
|
|
60
|
-
# Set a banner
|
|
61
|
-
opts.banner = "Usage: #{File.basename($0)} [options...]"
|
|
62
|
-
|
|
63
|
-
@defaults[:config] = nil
|
|
64
|
-
opts.on '-c', '--config FILE',
|
|
65
|
-
'Use configuration FILE' do |file|
|
|
66
|
-
@options[:config] = file
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
@defaults[:options_file] = nil
|
|
70
|
-
opts.on '-o', '--options-file FILE',
|
|
71
|
-
'Read options from FILE',
|
|
72
|
-
'This should evaluate to a ruby hash.',
|
|
73
|
-
'CLI optons are given precedence.' do |file|
|
|
74
|
-
@options_from_file = parse_options_file file
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
@defaults[:type] = 'pe'
|
|
78
|
-
opts.on '--type TYPE',
|
|
79
|
-
'one of git or pe',
|
|
80
|
-
'used to determine underlying path structure of puppet install',
|
|
81
|
-
'defaults to pe' do |type|
|
|
82
|
-
@options[:type] = type
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
@defaults[:helper] = []
|
|
86
|
-
opts.on '--helper PATH/TO/SCRIPT',
|
|
87
|
-
'Ruby file evaluated prior to tests',
|
|
88
|
-
'(a la spec_helper)' do |script|
|
|
89
|
-
@options[:helper] = []
|
|
90
|
-
if script.is_a?(Array)
|
|
91
|
-
@options[:helper] += script
|
|
92
|
-
elsif script =~ /,/
|
|
93
|
-
@options[:helper] += script.split(',')
|
|
94
|
-
else
|
|
95
|
-
@options[:helper] << script
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
@defaults[:load_path] = []
|
|
100
|
-
opts.on '--load-path /PATH/TO/DIR,/ADDITIONAL/DIR/PATHS',
|
|
101
|
-
'Add paths to LOAD_PATH' do |value|
|
|
102
|
-
@options[:load_path] = []
|
|
103
|
-
if value.is_a?(Array)
|
|
104
|
-
@options[:load_path] += value
|
|
105
|
-
elsif value =~ /,/
|
|
106
|
-
@options[:load_path] += value.split(',')
|
|
107
|
-
else
|
|
108
|
-
@options[:load_path] << value
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
@defaults[:tests] = []
|
|
113
|
-
opts.on '-t', '--tests /PATH/TO/DIR,/ADDITIONA/DIR/PATHS,/PATH/TO/FILE.rb',
|
|
114
|
-
'Execute tests from paths and files' do |value|
|
|
115
|
-
@options[:tests] = []
|
|
116
|
-
if value.is_a?(Array)
|
|
117
|
-
@options[:tests] += value
|
|
118
|
-
elsif value =~ /,/
|
|
119
|
-
@options[:tests] += value.split(',')
|
|
120
|
-
else
|
|
121
|
-
@options[:tests] << value
|
|
122
|
-
end
|
|
123
|
-
@options[:tests] = file_list(@options[:tests])
|
|
124
|
-
if @options[:tests].empty?
|
|
125
|
-
raise ArgumentError, "No tests to run!"
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
@defaults[:pre_suite] = []
|
|
130
|
-
opts.on '--pre-suite /PRE-SUITE/DIR/PATH,/ADDITIONAL/DIR/PATHS,/PATH/TO/FILE.rb',
|
|
131
|
-
'Path to project specific steps to be run BEFORE testing' do |value|
|
|
132
|
-
@options[:pre_suite] = []
|
|
133
|
-
if value.is_a?(Array)
|
|
134
|
-
@options[:pre_suite] += value
|
|
135
|
-
elsif value =~ /,/
|
|
136
|
-
@options[:pre_suite] += value.split(',')
|
|
137
|
-
else
|
|
138
|
-
@options[:pre_suite] << value
|
|
139
|
-
end
|
|
140
|
-
@options[:pre_suite] = file_list(@options[:pre_suite])
|
|
141
|
-
if @options[:pre_suite].empty?
|
|
142
|
-
raise ArgumentError, "Empty pre-suite!"
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
@defaults[:post_suite] = []
|
|
147
|
-
opts.on '--post-suite /POST-SUITE/DIR/PATH,/OPTIONAL/ADDITONAL/DIR/PATHS,/PATH/TO/FILE.rb',
|
|
148
|
-
'Path to project specific steps to be run AFTER testing' do |value|
|
|
149
|
-
@options[:post_suite] = []
|
|
150
|
-
if value.is_a?(Array)
|
|
151
|
-
@options[:post_suite] += value
|
|
152
|
-
elsif value =~ /,/
|
|
153
|
-
@options[:post_suite] += value.split(',')
|
|
154
|
-
else
|
|
155
|
-
@options[:post_suite] << value
|
|
156
|
-
end
|
|
157
|
-
@options[:post_suite] = file_list(@options[:post_suite])
|
|
158
|
-
if @options[:post_suite].empty?
|
|
159
|
-
raise ArgumentError, "Empty post-suite!"
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
@defaults[:provision] = true
|
|
164
|
-
opts.on '--[no-]provision',
|
|
165
|
-
'Do not provision vm images before testing',
|
|
166
|
-
'(default: true)' do |bool|
|
|
167
|
-
@options[:provision] = bool
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
@defaults[:preserve_hosts] = false
|
|
171
|
-
opts.on '--[no-]preserve-hosts',
|
|
172
|
-
'Preserve cloud instances' do |value|
|
|
173
|
-
@options[:preserve_hosts] = value
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
@defaults[:root_keys] = false
|
|
177
|
-
opts.on '--root-keys',
|
|
178
|
-
'Install puppetlabs pubkeys for superuser',
|
|
179
|
-
'(default: false)' do |bool|
|
|
180
|
-
@options[:root_keys] = bool
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
@defaults[:keyfile] = "#{ENV['HOME']}/.ssh/id_rsa"
|
|
184
|
-
opts.on '--keyfile /PATH/TO/SSH/KEY',
|
|
185
|
-
'Specify alternate SSH key',
|
|
186
|
-
'(default: ~/.ssh/id_rsa)' do |key|
|
|
187
|
-
@options[:keyfile] = key
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
@defaults[:install] = []
|
|
192
|
-
opts.on '-i URI', '--install URI',
|
|
193
|
-
'Install a project repo/app on the SUTs',
|
|
194
|
-
'Provide full git URI or use short form KEYWORD/name',
|
|
195
|
-
'supported keywords: PUPPET, FACTER, HIERA, HIERA-PUPPET' do |value|
|
|
196
|
-
@options[:install] = []
|
|
197
|
-
if value.is_a?(Array)
|
|
198
|
-
@options[:install] += value
|
|
199
|
-
elsif value =~ /,/
|
|
200
|
-
@options[:install] += value.split(',')
|
|
201
|
-
else
|
|
202
|
-
@options[:install] << value
|
|
203
|
-
end
|
|
204
|
-
@options[:install] = parse_install_options(@options[:install])
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
@defaults[:modules] = []
|
|
208
|
-
opts.on('-m', '--modules URI', 'Select puppet module git install URI') do |value|
|
|
209
|
-
@options[:modules] ||= []
|
|
210
|
-
@options[:modules] << value
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
@defaults[:quiet] = false
|
|
214
|
-
opts.on '-q', '--[no-]quiet',
|
|
215
|
-
'Do not log output to STDOUT',
|
|
216
|
-
'(default: false)' do |bool|
|
|
217
|
-
@options[:quiet] = bool
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
@defaults[:xml] = false
|
|
221
|
-
opts.on '-x', '--[no-]xml',
|
|
222
|
-
'Emit JUnit XML reports on tests',
|
|
223
|
-
'(default: false)' do |bool|
|
|
224
|
-
@options[:xml] = bool
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
@defaults[:color] = true
|
|
228
|
-
opts.on '--[no-]color',
|
|
229
|
-
'Do not display color in log output',
|
|
230
|
-
'(default: true)' do |bool|
|
|
231
|
-
@options[:color] = bool
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
@defaults[:debug] = false
|
|
235
|
-
opts.on '--[no-]debug',
|
|
236
|
-
'Enable full debugging',
|
|
237
|
-
'(default: false)' do |bool|
|
|
238
|
-
@options[:debug] = bool
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
@defaults[:dry_run] = false
|
|
242
|
-
opts.on '-d', '--[no-]dry-run',
|
|
243
|
-
'Report what would happen on targets',
|
|
244
|
-
'(default: false)' do |bool|
|
|
245
|
-
@options[:dry_run] = bool
|
|
246
|
-
$dry_run = bool
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
@defaults[:fail_mode] = nil
|
|
250
|
-
opts.on '--fail-mode [MODE]',
|
|
251
|
-
'How should the harness react to errors/failures',
|
|
252
|
-
'Possible values:',
|
|
253
|
-
'fast (skip all subsequent tests, cleanup, exit)',
|
|
254
|
-
'stop (skip all subsequent tests, do no cleanup, exit immediately)' do |mode|
|
|
255
|
-
@options[:fail_mode] = mode
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
@defaults[:timesync] = false
|
|
259
|
-
opts.on '--[no-]ntp',
|
|
260
|
-
'Sync time on SUTs before testing',
|
|
261
|
-
'(default: false)' do |bool|
|
|
262
|
-
@options[:timesync] = bool
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
@defaults[:repo_proxy] = false
|
|
266
|
-
opts.on '--repo-proxy',
|
|
267
|
-
'Proxy packaging repositories on ubuntu, debian and solaris-11',
|
|
268
|
-
'(default: false)' do
|
|
269
|
-
@options[:repo_proxy] = true
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
@defaults[:add_el_extras] = false
|
|
273
|
-
opts.on '--add-el-extras',
|
|
274
|
-
'Add Extra Packages for Enterprise Linux (EPEL) repository to el-* hosts',
|
|
275
|
-
'(default: false)' do
|
|
276
|
-
@options[:add_el_extras] = true
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
opts.on('--help', 'Display this screen' ) do |yes|
|
|
280
|
-
puts opts
|
|
281
|
-
exit
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
optparse.parse!
|
|
286
|
-
|
|
287
|
-
# We have use the @no_args var because OptParse consumes ARGV as it parses
|
|
288
|
-
# so we have to check the value of ARGV at the begining of the method,
|
|
289
|
-
# let the options be set, then output usage.
|
|
290
|
-
puts optparse if @no_args
|
|
291
|
-
|
|
292
|
-
# merge in the options that we read from the file
|
|
293
|
-
@options = @options_from_file.merge(@options)
|
|
294
|
-
# merge in defaults
|
|
295
|
-
@options = @defaults.merge(@options)
|
|
296
|
-
|
|
297
|
-
if @options[:type] !~ /(pe)|(git)/
|
|
298
|
-
raise ArgumentError.new("--type must be one of pe or git, not '#{@options[:type]}'")
|
|
299
|
-
end
|
|
300
|
-
|
|
301
|
-
raise ArgumentError.new("--fail-mode must be one of fast, stop") unless ["fast", "stop", nil].include?(@options[:fail_mode])
|
|
302
|
-
|
|
303
|
-
@options
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
def self.parse_options_file(options_file_path)
|
|
307
|
-
options_file_path = File.expand_path(options_file_path)
|
|
308
|
-
unless File.exists?(options_file_path)
|
|
309
|
-
raise ArgumentError, "Specified options file '#{options_file_path}' does not exist!"
|
|
310
|
-
end
|
|
311
|
-
# This eval will allow the specified options file to have access to our
|
|
312
|
-
# scope. It is important that the variable 'options_file_path' is
|
|
313
|
-
# accessible, because some existing options files (e.g. puppetdb) rely on
|
|
314
|
-
# that variable to determine their own location (for use in 'require's, etc.)
|
|
315
|
-
result = eval(File.read(options_file_path))
|
|
316
|
-
unless result.is_a? Hash
|
|
317
|
-
raise ArgumentError, "Options file '#{options_file_path}' must return a hash!"
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
result
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
end
|
data/lib/beaker/test_config.rb
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
require 'open-uri'
|
|
2
|
-
require 'yaml'
|
|
3
|
-
|
|
4
|
-
module Beaker
|
|
5
|
-
# Config was taken by Ruby.
|
|
6
|
-
class TestConfig
|
|
7
|
-
|
|
8
|
-
attr_accessor :logger
|
|
9
|
-
def initialize(config_file, options)
|
|
10
|
-
@options = options
|
|
11
|
-
@logger = options[:logger]
|
|
12
|
-
@config = load_file(config_file)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def [](key)
|
|
16
|
-
@config[key]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def ssh_defaults
|
|
20
|
-
{
|
|
21
|
-
:config => false,
|
|
22
|
-
:paranoid => false,
|
|
23
|
-
:timeout => 300,
|
|
24
|
-
:auth_methods => ["publickey"],
|
|
25
|
-
:keys => [@options[:keyfile]],
|
|
26
|
-
:port => 22,
|
|
27
|
-
:user_known_hosts_file => "#{ENV['HOME']}/.ssh/known_hosts",
|
|
28
|
-
:forward_agent => true
|
|
29
|
-
}
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def load_file(config_file)
|
|
33
|
-
if config_file.is_a? Hash
|
|
34
|
-
config = config_file
|
|
35
|
-
else
|
|
36
|
-
config = YAML.load_file(config_file)
|
|
37
|
-
|
|
38
|
-
# Make sure the roles array is present for all hosts
|
|
39
|
-
config['HOSTS'].each_key do |host|
|
|
40
|
-
config['HOSTS'][host]['roles'] ||= []
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Merge some useful date into the config hash
|
|
45
|
-
config['CONFIG'] ||= {}
|
|
46
|
-
consoleport = ENV['consoleport'] || config['CONFIG']['consoleport'] || 443
|
|
47
|
-
config['CONFIG']['consoleport'] = consoleport.to_i
|
|
48
|
-
config['CONFIG']['ssh'] = ssh_defaults.merge(config['CONFIG']['ssh'] || {})
|
|
49
|
-
config['CONFIG']['modules'] = @options[:modules] || []
|
|
50
|
-
|
|
51
|
-
if is_pe?
|
|
52
|
-
config['CONFIG']['pe_dir'] = puppet_enterprise_dir
|
|
53
|
-
config['CONFIG']['pe_ver'] = puppet_enterprise_version
|
|
54
|
-
config['CONFIG']['pe_ver_win'] = puppet_enterprise_version_win
|
|
55
|
-
else
|
|
56
|
-
config['CONFIG']['puppet_ver'] = @options[:puppet]
|
|
57
|
-
config['CONFIG']['facter_ver'] = @options[:facter]
|
|
58
|
-
config['CONFIG']['hiera_ver'] = @options[:hiera]
|
|
59
|
-
config['CONFIG']['hiera_puppet_ver'] = @options[:hiera_puppet]
|
|
60
|
-
end
|
|
61
|
-
# need to load expect versions of PE binaries
|
|
62
|
-
config
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def is_pe?
|
|
66
|
-
@is_pe ||= @options[:type] =~ /pe/ ? true : false
|
|
67
|
-
unless ENV['IS_PE'].nil?
|
|
68
|
-
@is_pe ||= ENV['IS_PE'] == 'true'
|
|
69
|
-
end
|
|
70
|
-
@is_pe
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def puppet_enterprise_dir
|
|
74
|
-
@pe_dir ||= ENV['pe_dist_dir'] || '/opt/enterprise/dists'
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def load_pe_version
|
|
78
|
-
dist_dir = puppet_enterprise_dir
|
|
79
|
-
version_file = ENV['pe_version_file'] || 'LATEST'
|
|
80
|
-
version = ""
|
|
81
|
-
begin
|
|
82
|
-
open("#{dist_dir}/#{version_file}") do |file|
|
|
83
|
-
while line = file.gets
|
|
84
|
-
if /(\w.*)/ =~ line then
|
|
85
|
-
version = $1.strip
|
|
86
|
-
@logger.debug "Found LATEST: Puppet Enterprise Version #{version}"
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
rescue
|
|
91
|
-
version = 'unknown'
|
|
92
|
-
end
|
|
93
|
-
return version
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def puppet_enterprise_version
|
|
97
|
-
@pe_ver ||= load_pe_version if is_pe?
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def load_pe_version_win
|
|
101
|
-
dist_dir = puppet_enterprise_dir
|
|
102
|
-
version_file = ENV['pe_version_file'] || 'LATEST-win'
|
|
103
|
-
version = ""
|
|
104
|
-
begin
|
|
105
|
-
open("#{dist_dir}/#{version_file}") do |file|
|
|
106
|
-
while line = file.gets
|
|
107
|
-
if /(\w.*)/ =~ line then
|
|
108
|
-
version=$1.strip
|
|
109
|
-
@logger.debug "Found LATEST: Puppet Enterprise Windows Version #{version}"
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
rescue
|
|
114
|
-
version = 'unknown'
|
|
115
|
-
end
|
|
116
|
-
return version
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def puppet_enterprise_version_win
|
|
120
|
-
@pe_ver_win ||= load_pe_version_win if is_pe?
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# Print out test configuration
|
|
124
|
-
def dump
|
|
125
|
-
# Access "platform" for each host
|
|
126
|
-
@config["HOSTS"].each_key do|host|
|
|
127
|
-
@logger.notify "Platform for #{host} #{@config["HOSTS"][host]['platform']}"
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
# Access "roles" for each host
|
|
131
|
-
@config["HOSTS"].each_key do|host|
|
|
132
|
-
@config["HOSTS"][host]['roles'].each do |role|
|
|
133
|
-
@logger.notify "Role for #{host} #{role}"
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Print out Ruby versions
|
|
138
|
-
@config["HOSTS"].each_key do|host|
|
|
139
|
-
@logger.notify "Ruby version for #{host} #{@config["HOSTS"][host][:ruby_ver]}"
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
# Access @config keys/values
|
|
143
|
-
@config["CONFIG"].each_key do|cfg|
|
|
144
|
-
@logger.notify "Config Key|Val: #{cfg} #{@config["CONFIG"][cfg].inspect}"
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|