beaker 2.13.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +8 -8
  2. data/Gemfile +19 -0
  3. data/HISTORY.md +335 -2
  4. data/acceptance/pre_suite/puppet_git/install.rb +2 -2
  5. data/lib/beaker/answers.rb +45 -2
  6. data/lib/beaker/answers/version20.rb +9 -9
  7. data/lib/beaker/answers/version28.rb +9 -9
  8. data/lib/beaker/answers/version30.rb +19 -19
  9. data/lib/beaker/answers/version32.rb +1 -1
  10. data/lib/beaker/answers/version34.rb +4 -4
  11. data/lib/beaker/answers/version40.rb +1 -1
  12. data/lib/beaker/cli.rb +11 -4
  13. data/lib/beaker/command.rb +4 -2
  14. data/lib/beaker/command_factory.rb +5 -1
  15. data/lib/beaker/dsl/helpers/host_helpers.rb +17 -5
  16. data/lib/beaker/dsl/install_utils.rb +3 -2
  17. data/lib/beaker/dsl/install_utils/aio_defaults.rb +86 -0
  18. data/lib/beaker/dsl/install_utils/foss_defaults.rb +163 -0
  19. data/lib/beaker/dsl/install_utils/foss_utils.rb +988 -0
  20. data/lib/beaker/dsl/install_utils/pe_defaults.rb +139 -0
  21. data/lib/beaker/dsl/install_utils/pe_utils.rb +140 -38
  22. data/lib/beaker/dsl/install_utils/puppet_utils.rb +26 -751
  23. data/lib/beaker/dsl/structure.rb +7 -1
  24. data/lib/beaker/host.rb +35 -58
  25. data/lib/beaker/host/freebsd.rb +4 -16
  26. data/lib/beaker/host/mac.rb +3 -39
  27. data/lib/beaker/host/mac/pkg.rb +2 -1
  28. data/lib/beaker/host/pswindows.rb +2 -28
  29. data/lib/beaker/host/unix.rb +3 -51
  30. data/lib/beaker/host/unix/pkg.rb +34 -33
  31. data/lib/beaker/host/windows.rb +1 -45
  32. data/lib/beaker/host_prebuilt_steps.rb +11 -24
  33. data/lib/beaker/hypervisor/aixer.rb +1 -1
  34. data/lib/beaker/hypervisor/docker.rb +43 -4
  35. data/lib/beaker/hypervisor/openstack.rb +1 -0
  36. data/lib/beaker/hypervisor/solaris.rb +1 -1
  37. data/lib/beaker/hypervisor/vmpooler.rb +19 -8
  38. data/lib/beaker/network_manager.rb +5 -4
  39. data/lib/beaker/options/command_line_parser.rb +9 -9
  40. data/lib/beaker/options/parser.rb +21 -17
  41. data/lib/beaker/options/presets.rb +0 -33
  42. data/lib/beaker/platform.rb +7 -3
  43. data/lib/beaker/ssh_connection.rb +1 -1
  44. data/lib/beaker/version.rb +1 -1
  45. data/spec/beaker/answers_spec.rb +13 -8
  46. data/spec/beaker/cli_spec.rb +6 -6
  47. data/spec/beaker/command_spec.rb +18 -0
  48. data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +2 -0
  49. data/spec/beaker/dsl/install_utils/{puppet_utils_spec.rb → foss_utils_spec.rb} +34 -21
  50. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +2 -0
  51. data/spec/beaker/dsl/structure_spec.rb +8 -0
  52. data/spec/beaker/host/unix/pkg_spec.rb +15 -10
  53. data/spec/beaker/host_prebuilt_steps_spec.rb +1 -1
  54. data/spec/beaker/host_spec.rb +3 -54
  55. data/spec/beaker/hypervisor/docker_spec.rb +2 -0
  56. data/spec/beaker/hypervisor/vmpooler_spec.rb +67 -10
  57. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  58. data/spec/beaker/options/parser_spec.rb +35 -24
  59. data/spec/beaker/options/presets_spec.rb +0 -26
  60. data/spec/helpers.rb +5 -5
  61. data/spec/mocks.rb +1 -2
  62. metadata +7 -3
@@ -0,0 +1,988 @@
1
+ [ 'aio_defaults', 'foss_defaults', 'puppet_utils' ].each do |lib|
2
+ require "beaker/dsl/install_utils/#{lib}"
3
+ end
4
+ module Beaker
5
+ module DSL
6
+ module InstallUtils
7
+ #
8
+ # This module contains methods to install FOSS puppet from various sources
9
+ #
10
+ # To mix this is into a class you need the following:
11
+ # * a method *hosts* that yields any hosts implementing
12
+ # {Beaker::Host}'s interface to act upon.
13
+ # * a method *options* that provides an options hash, see {Beaker::Options::OptionsHash}
14
+ # * the module {Beaker::DSL::Roles} that provides access to the various hosts implementing
15
+ # {Beaker::Host}'s interface to act upon
16
+ # * the module {Beaker::DSL::Wrappers} the provides convenience methods for {Beaker::DSL::Command} creation
17
+ module FOSSUtils
18
+ include AIODefaults
19
+ include FOSSDefaults
20
+ include PuppetUtils
21
+
22
+ DEFAULT_DOWNLOAD_URLS = {
23
+ :win_download_url => "http://downloads.puppetlabs.com/windows",
24
+ :mac_download_url => "http://downloads.puppetlabs.com/mac"
25
+ }
26
+
27
+ # The default install path
28
+ SourcePath = "/opt/puppet-git-repos"
29
+
30
+ # A regex to know if the uri passed is pointing to a git repo
31
+ GitURI = %r{^(git|https?|file)://|^git@|^gitmirror@}
32
+
33
+ # Github's ssh signature for cloning via ssh
34
+ GitHubSig = 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
35
+
36
+ # Set defaults and PATH for these hosts to be either foss or aio, have host['type'] == aio for aio settings, defaults
37
+ # to foss.
38
+ #
39
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
40
+ # or a role (String or Symbol) that identifies one or more hosts.
41
+ def configure_foss_defaults_on( hosts )
42
+ block_on hosts do |host|
43
+ if host['type'] && host['type'] =~ /aio/
44
+ # add foss defaults to host
45
+ add_aio_defaults_on(host)
46
+ else
47
+ add_foss_defaults_on(host)
48
+ end
49
+ # add pathing env
50
+ add_puppet_paths_on(host)
51
+ end
52
+ end
53
+
54
+ # @param [String] uri A uri in the format of <git uri>#<revision>
55
+ # the `git://`, `http://`, `https://`, and ssh
56
+ # (if cloning as the remote git user) protocols
57
+ # are valid for <git uri>
58
+ #
59
+ # @example Usage
60
+ # project = extract_repo_info_from 'git@github.com:puppetlabs/SuperSecretSauce#what_is_justin_doing'
61
+ #
62
+ # puts project[:name]
63
+ # #=> 'SuperSecretSauce'
64
+ #
65
+ # puts project[:rev]
66
+ # #=> 'what_is_justin_doing'
67
+ #
68
+ # @return [Hash{Symbol=>String}] Returns a hash containing the project
69
+ # name, repository path, and revision
70
+ # (defaults to HEAD)
71
+ #
72
+ def extract_repo_info_from uri
73
+ require 'pathname'
74
+ project = {}
75
+ repo, rev = uri.split('#', 2)
76
+ project[:name] = Pathname.new(repo).basename('.git').to_s
77
+ project[:path] = repo
78
+ project[:rev] = rev || 'HEAD'
79
+ return project
80
+ end
81
+
82
+ # Takes an array of package info hashes (like that returned from
83
+ # {#extract_repo_info_from}) and sorts the `puppet`, `facter`, `hiera`
84
+ # packages so that puppet's dependencies will be installed first.
85
+ #
86
+ # @!visibility private
87
+ def order_packages packages_array
88
+ puppet = packages_array.select {|e| e[:name] == 'puppet' }
89
+ puppet_depends_on = packages_array.select do |e|
90
+ e[:name] == 'hiera' or e[:name] == 'facter'
91
+ end
92
+ depends_on_puppet = (packages_array - puppet) - puppet_depends_on
93
+ [puppet_depends_on, puppet, depends_on_puppet].flatten
94
+ end
95
+
96
+ # @param [Host] host An object implementing {Beaker::Hosts}'s
97
+ # interface.
98
+ # @param [String] path The path on the remote [host] to the repository
99
+ # @param [Hash{Symbol=>String}] repository A hash representing repo
100
+ # info like that emitted by
101
+ # {#extract_repo_info_from}
102
+ #
103
+ # @example Getting multiple project versions
104
+ # versions = [puppet_repo, facter_repo, hiera_repo].inject({}) do |vers, repo_info|
105
+ # vers.merge(find_git_repo_versions(host, '/opt/git-puppet-repos', repo_info) )
106
+ # end
107
+ # @return [Hash] Executes git describe on [host] and returns a Hash
108
+ # with the key of [repository[:name]] and value of
109
+ # the output from git describe.
110
+ #
111
+ # @note This requires the helper methods:
112
+ # * {Beaker::DSL::Helpers#on}
113
+ #
114
+ def find_git_repo_versions host, path, repository
115
+ logger.notify("\n * Grab version for #{repository[:name]}")
116
+
117
+ version = {}
118
+ on host, "cd #{path}/#{repository[:name]} && " +
119
+ "git describe || true" do
120
+ version[repository[:name]] = stdout.chomp
121
+ end
122
+
123
+ version
124
+ end
125
+
126
+ #
127
+ # @see #find_git_repo_versions
128
+ def install_from_git host, path, repository
129
+ name = repository[:name]
130
+ repo = repository[:path]
131
+ rev = repository[:rev]
132
+ depth = repository[:depth]
133
+ depth_branch = repository[:depth_branch]
134
+ target = "#{path}/#{name}"
135
+
136
+ if (depth_branch.nil?)
137
+ depth_branch = rev
138
+ end
139
+
140
+ clone_cmd = "git clone #{repo} #{target}"
141
+ if (depth)
142
+ clone_cmd = "git clone --branch #{depth_branch} --depth #{depth} #{repo} #{target}"
143
+ end
144
+
145
+ logger.notify("\n * Clone #{repo} if needed")
146
+
147
+ on host, "test -d #{path} || mkdir -p #{path}"
148
+ on host, "test -d #{target} || #{clone_cmd}"
149
+
150
+ logger.notify("\n * Update #{name} and check out revision #{rev}")
151
+
152
+ commands = ["cd #{target}",
153
+ "remote rm origin",
154
+ "remote add origin #{repo}",
155
+ "fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*",
156
+ "clean -fdx",
157
+ "checkout -f #{rev}"]
158
+ on host, commands.join(" && git ")
159
+
160
+ logger.notify("\n * Install #{name} on the system")
161
+ # The solaris ruby IPS package has bindir set to /usr/ruby/1.8/bin.
162
+ # However, this is not the path to which we want to deliver our
163
+ # binaries. So if we are using solaris, we have to pass the bin and
164
+ # sbin directories to the install.rb
165
+ install_opts = ''
166
+ install_opts = '--bindir=/usr/bin --sbindir=/usr/sbin' if
167
+ host['platform'].include? 'solaris'
168
+
169
+ on host, "cd #{target} && " +
170
+ "if [ -f install.rb ]; then " +
171
+ "ruby ./install.rb #{install_opts}; " +
172
+ "else true; fi"
173
+ end
174
+
175
+ # @deprecated Use {#install_puppet_on} instead.
176
+ def install_puppet(opts = {})
177
+ #send in the global hosts!
178
+ install_puppet_on(hosts, opts)
179
+ end
180
+
181
+ #Install FOSS based on specified hosts using provided options
182
+ # @example will install puppet 3.6.1 from native puppetlabs provided packages wherever possible and will fail over to gem installation when impossible
183
+ # install_puppet_on(hosts, {
184
+ # :version => '3.6.1',
185
+ # :facter_version => '2.0.1',
186
+ # :hiera_version => '1.3.3',
187
+ # :default_action => 'gem_install',
188
+ # })
189
+ #
190
+ # @example will install puppet 4 from native puppetlabs provided puppet-agent 1.x package wherever possible and will fail over to gem installation when impossible
191
+ # install_puppet({
192
+ # :version => '4',
193
+ # :default_action => 'gem_install'
194
+ # })
195
+ #
196
+ # @example will install puppet 4.1.0 from native puppetlabs provided puppet-agent 1.1.0 package wherever possible and will fail over to gem installation when impossible
197
+ # install_puppet({
198
+ # :version => '4.1.0',
199
+ # :puppet_agent_version => '1.1.0',
200
+ # :default_action => 'gem_install'
201
+ # })
202
+ #
203
+ #
204
+ #
205
+ # @example Will install latest packages on Enterprise Linux and Debian based distros and fail hard on all othere platforms.
206
+ # install_puppet_on(hosts)
207
+ #
208
+ # @note This will attempt to add a repository for apt.puppetlabs.com on
209
+ # Debian, Ubuntu, or Cumulus machines, or yum.puppetlabs.com on EL or Fedora
210
+ # machines, then install the package 'puppet' or 'puppet-agent'.
211
+ #
212
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
213
+ # or a role (String or Symbol) that identifies one or more hosts.
214
+ # @param [Hash{Symbol=>String}] opts
215
+ # @option opts [String] :version Version of puppet to download
216
+ # @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-%version%.msi
217
+ # @option opts [String] :win_download_url Url to download dmg pattern of %url%/(puppet|hiera|facter)-%version%.msi
218
+ #
219
+ # @return nil
220
+ # @raise [StandardError] When encountering an unsupported platform by default, or if gem cannot be found when default_action => 'gem_install'
221
+ # @raise [FailTest] When error occurs during the actual installation process
222
+ def install_puppet_on(hosts, opts={})
223
+ opts = DEFAULT_DOWNLOAD_URLS.merge(opts)
224
+
225
+ # If version isn't specified assume the latest in the 3.x series
226
+ if opts[:version] and not version_is_less(opts[:version], '4.0.0')
227
+ opts[:version] = opts[:puppet_agent_version]
228
+ install_puppet_agent_on(hosts, opts)
229
+
230
+ else
231
+ block_on hosts do |host|
232
+ if host['platform'] =~ /el-(5|6|7)/
233
+ relver = $1
234
+ install_puppet_from_rpm_on(host, opts.merge(:release => relver, :family => 'el'))
235
+ elsif host['platform'] =~ /fedora-(\d+)/
236
+ relver = $1
237
+ install_puppet_from_rpm_on(host, opts.merge(:release => relver, :family => 'fedora'))
238
+ elsif host['platform'] =~ /(ubuntu|debian|cumulus)/
239
+ install_puppet_from_deb_on(host, opts)
240
+ elsif host['platform'] =~ /windows/
241
+ relver = opts[:version]
242
+ install_puppet_from_msi_on(host, opts)
243
+ elsif host['platform'] =~ /osx/
244
+ install_puppet_from_dmg_on(host, opts)
245
+ else
246
+ if opts[:default_action] == 'gem_install'
247
+ opts[:version] ||= '~> 3.x'
248
+ install_puppet_from_gem_on(host, opts)
249
+ else
250
+ raise "install_puppet() called for unsupported platform '#{host['platform']}' on '#{host.name}'"
251
+ end
252
+ end
253
+
254
+ # Certain install paths may not create the config dirs/files needed
255
+ on host, "mkdir -p #{host['puppetpath']}" unless host[:type] =~ /aio/
256
+ on host, "echo '' >> #{host.puppet['hiera_config']}"
257
+ end
258
+ end
259
+
260
+ nil
261
+ end
262
+
263
+ #Install Puppet Agent based on specified hosts using provided options
264
+ # @example will install puppet-agent 1.1.0 from native puppetlabs provided packages wherever possible and will fail over to gem installing latest puppet
265
+ # install_puppet_agent_on(hosts, {
266
+ # :version => '1.1.0',
267
+ # :default_action => 'gem_install',
268
+ # })
269
+ #
270
+ #
271
+ # @example Will install latest packages on Enterprise Linux, Debian based distros, Windows, OSX and fail hard on all othere platforms.
272
+ # install_puppet_agent_on(hosts)
273
+ #
274
+ # @note This will attempt to add a repository for apt.puppetlabs.com on
275
+ # Debian, Ubuntu, or Cumulus machines, or yum.puppetlabs.com on EL or Fedora
276
+ # machines, then install the package 'puppet-agent'.
277
+ #
278
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
279
+ # or a role (String or Symbol) that identifies one or more hosts.
280
+ # @param [Hash{Symbol=>String}] opts
281
+ # @option opts [String] :version Version of puppet to download
282
+ # @option opts [String] :puppet_gem_version Version of puppet to install via gem if no puppet-agent package is available
283
+ # @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-agent-%version%.msi
284
+ # @option opts [String] :win_download_url Url to download dmg pattern of %url%/puppet-agent-%version%.msi
285
+ #
286
+ # @return nil
287
+ # @raise [StandardError] When encountering an unsupported platform by default, or if gem cannot be found when default_action => 'gem_install'
288
+ # @raise [FailTest] When error occurs during the actual installation process
289
+ def install_puppet_agent_on(hosts, opts)
290
+ opts = DEFAULT_DOWNLOAD_URLS.merge(opts)
291
+ opts[:repo] ||= 'pc1'
292
+
293
+ block_on hosts do |host|
294
+ case host['platform']
295
+ when /el-|fedora/
296
+ install_puppetlabs_release_repo(host, opts[:repo])
297
+ if opts[:version]
298
+ host.install_package("puppet-agent-#{opts[:version]}")
299
+ else
300
+ host.install_package('puppet-agent')
301
+ end
302
+ when /debian|ubuntu|cumulus/
303
+ install_puppetlabs_release_repo(host, opts[:repo])
304
+ if opts[:version]
305
+ host.install_package("puppet-agent=#{opts[:version]}-1#{host['platform'].codename}")
306
+ else
307
+ host.install_package('puppet-agent')
308
+ end
309
+ when /windows/
310
+ install_puppet_agent_from_msi_on(host, opts)
311
+ when /osx/
312
+ install_puppet_agent_from_dmg_on(host, opts)
313
+ else
314
+ if opts[:default_action] == 'gem_install'
315
+ opts[:version] = opts[:puppet_gem_version]
316
+ install_puppet_from_gem_on(host, opts)
317
+ on host, "echo '' >> #{host.puppet['hiera_config']}"
318
+ else
319
+ raise "install_puppet_agent_on() called for unsupported " +
320
+ "platform '#{host['platform']}' on '#{host.name}'"
321
+ end
322
+ end
323
+ end
324
+ end
325
+
326
+ # @deprecated Use {#configure_puppet_on} instead.
327
+ def configure_puppet(opts={})
328
+ hosts.each do |host|
329
+ configure_puppet_on(host,opts)
330
+ end
331
+ end
332
+
333
+ # Configure puppet.conf on the given host(s) based upon a provided hash
334
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
335
+ # or a role (String or Symbol) that identifies one or more hosts.
336
+ # @param [Hash{Symbol=>String}] opts
337
+ # @option opts [Hash{String=>String}] :main configure the main section of puppet.conf
338
+ # @option opts [Hash{String=>String}] :agent configure the agent section of puppet.conf
339
+ #
340
+ # @example will configure /etc/puppet.conf on the puppet master.
341
+ # config = {
342
+ # 'main' => {
343
+ # 'server' => 'testbox.test.local',
344
+ # 'certname' => 'testbox.test.local',
345
+ # 'logdir' => '/var/log/puppet',
346
+ # 'vardir' => '/var/lib/puppet',
347
+ # 'ssldir' => '/var/lib/puppet/ssl',
348
+ # 'rundir' => '/var/run/puppet'
349
+ # },
350
+ # 'agent' => {
351
+ # 'environment' => 'dev'
352
+ # }
353
+ # }
354
+ # configure_puppet(master, config)
355
+ #
356
+ # @return nil
357
+ def configure_puppet_on(hosts, opts = {})
358
+ block_on hosts do |host|
359
+ if host['platform'] =~ /windows/
360
+ puppet_conf = host.puppet['config']
361
+ conf_data = ''
362
+ opts.each do |section,options|
363
+ conf_data << "[#{section}]`n"
364
+ options.each do |option,value|
365
+ conf_data << "#{option}=#{value}`n"
366
+ end
367
+ conf_data << "`n"
368
+ end
369
+ on host, powershell("\$text = \\\"#{conf_data}\\\"; Set-Content -path '#{puppet_conf}' -value \$text")
370
+ else
371
+ puppet_conf = host.puppet['config']
372
+ conf_data = ''
373
+ opts.each do |section,options|
374
+ conf_data << "[#{section}]\n"
375
+ options.each do |option,value|
376
+ conf_data << "#{option}=#{value}\n"
377
+ end
378
+ conf_data << "\n"
379
+ end
380
+ on host, "echo \"#{conf_data}\" > #{puppet_conf}"
381
+ end
382
+ end
383
+ end
384
+
385
+ # Installs Puppet and dependencies using rpm
386
+ #
387
+ # @param [Host] host The host to install packages on
388
+ # @param [Hash{Symbol=>String}] opts An options hash
389
+ # @option opts [String] :version The version of Puppet to install, if nil installs latest version
390
+ # @option opts [String] :facter_version The version of Facter to install, if nil installs latest version
391
+ # @option opts [String] :hiera_version The version of Hiera to install, if nil installs latest version
392
+ # @option opts [String] :release The major release of the OS
393
+ # @option opts [String] :family The OS family (one of 'el' or 'fedora')
394
+ #
395
+ # @return nil
396
+ # @api private
397
+ def install_puppet_from_rpm_on( host, opts )
398
+ install_puppetlabs_release_repo(host)
399
+
400
+ if opts[:facter_version]
401
+ host.install_package("facter-#{opts[:facter_version]}")
402
+ end
403
+
404
+ if opts[:hiera_version]
405
+ host.install_package("hiera-#{opts[:hiera_version]}")
406
+ end
407
+
408
+ puppet_pkg = opts[:version] ? "puppet-#{opts[:version]}" : 'puppet'
409
+ host.install_package("#{puppet_pkg}")
410
+ configure_foss_defaults_on( host )
411
+ end
412
+ alias_method :install_puppet_from_rpm, :install_puppet_from_rpm_on
413
+
414
+ # Installs Puppet and dependencies from deb
415
+ #
416
+ # @param [Host] host The host to install packages on
417
+ # @param [Hash{Symbol=>String}] opts An options hash
418
+ # @option opts [String] :version The version of Puppet to install, if nil installs latest version
419
+ # @option opts [String] :facter_version The version of Facter to install, if nil installs latest version
420
+ # @option opts [String] :hiera_version The version of Hiera to install, if nil installs latest version
421
+ #
422
+ # @return nil
423
+ # @api private
424
+ def install_puppet_from_deb_on( host, opts )
425
+ install_puppetlabs_release_repo(host)
426
+
427
+ if opts[:facter_version]
428
+ host.install_package("facter=#{opts[:facter_version]}-1puppetlabs1")
429
+ end
430
+
431
+ if opts[:hiera_version]
432
+ host.install_package("hiera=#{opts[:hiera_version]}-1puppetlabs1")
433
+ end
434
+
435
+ if opts[:version]
436
+ host.install_package("puppet-common=#{opts[:version]}-1puppetlabs1")
437
+ host.install_package("puppet=#{opts[:version]}-1puppetlabs1")
438
+ else
439
+ host.install_package('puppet')
440
+ end
441
+ configure_foss_defaults_on( host )
442
+ end
443
+ alias_method :install_puppet_from_deb, :install_puppet_from_deb_on
444
+
445
+ # Installs Puppet and dependencies from msi
446
+ #
447
+ # @param [Host] host The host to install packages on
448
+ # @param [Hash{Symbol=>String}] opts An options hash
449
+ # @option opts [String] :version The version of Puppet to install
450
+ # @option opts [String] :puppet_agent_version The version of the
451
+ # puppet-agent package to install, required if version is 4.0.0 or greater
452
+ # @option opts [String] :win_download_url The url to download puppet from
453
+ #
454
+ # @note on windows, the +:ruby_arch+ host parameter can determine in addition
455
+ # to other settings whether the 32 or 64bit install is used
456
+ def install_puppet_from_msi_on( host, opts )
457
+
458
+ version = opts[:version]
459
+
460
+ if version && !version_is_less(version, '4.0.0')
461
+ if opts[:puppet_agent_version].nil?
462
+ raise "You must specify the version of puppet agent you " +
463
+ "want to install if you want to install Puppet 4.0 " +
464
+ "or greater on Windows"
465
+ end
466
+
467
+ opts[:version] = opts[:puppet_agent_version]
468
+ install_puppet_agent_from_msi_on(host, opts)
469
+
470
+ else
471
+ compute_puppet_msi_name(host, opts)
472
+ install_a_puppet_msi_on(host, opts)
473
+
474
+ end
475
+ end
476
+ alias_method :install_puppet_from_msi, :install_puppet_from_msi_on
477
+
478
+ # @api private
479
+ def compute_puppet_msi_name(host, opts)
480
+ version = opts[:version]
481
+ install_32 = host['install_32'] || opts['install_32']
482
+ less_than_3_dot_7 = version && version_is_less(version, '3.7')
483
+
484
+ # If there's no version declared, install the latest in the 3.x series
485
+ if not version
486
+ if !host.is_x86_64? || install_32
487
+ host['dist'] = 'puppet-latest'
488
+ else
489
+ host['dist'] = 'puppet-x64-latest'
490
+ end
491
+
492
+ # Install Puppet 3.x with the x86 installer if:
493
+ # - we are on puppet < 3.7, or
494
+ # - we are less than puppet 4.0 and on an x86 host, or
495
+ # - we have install_32 set on host or globally
496
+ # Install Puppet 3.x with the x64 installer if:
497
+ # - we are otherwise trying to install Puppet 3.x on a x64 host
498
+ elsif less_than_3_dot_7 or not host.is_x86_64? or install_32
499
+ host['dist'] = "puppet-#{version}"
500
+
501
+ elsif host.is_x86_64?
502
+ host['dist'] = "puppet-#{version}-x64"
503
+
504
+ else
505
+ raise "I don't understand how to install Puppet version: #{version}"
506
+ end
507
+ end
508
+
509
+ # Installs Puppet Agent and dependencies from msi
510
+ #
511
+ # @param [Host] host The host to install packages on
512
+ # @param [Hash{Symbol=>String}] opts An options hash
513
+ # @option opts [String] :version The version of Puppet Agent to install
514
+ # @option opts [String] :win_download_url The url to download puppet from
515
+ #
516
+ # @note on windows, the +:ruby_arch+ host parameter can determine in addition
517
+ # to other settings whether the 32 or 64bit install is used
518
+ def install_puppet_agent_from_msi_on(host, opts)
519
+ arch = host.is_x86_64? ? 'x64' : 'x86'
520
+
521
+ # If we don't specify a version install the latest MSI for puppet-agent
522
+ if opts['version']
523
+ host['dist'] = "puppet-agent-#{opts[:version]}-#{arch}"
524
+ else
525
+ host['dist'] = "puppet-agent-#{arch}-latest"
526
+ end
527
+
528
+ install_a_puppet_msi_on(host, opts)
529
+ end
530
+
531
+ # @api private
532
+ def install_a_puppet_msi_on(host, opts)
533
+ link = "#{opts[:win_download_url]}/#{host['dist']}.msi"
534
+ if not link_exists?( link )
535
+ raise "Puppet #{version} at #{link} does not exist!"
536
+ end
537
+
538
+ if host.is_cygwin?
539
+ dest = "#{host['dist']}.msi"
540
+ on host, "curl -O #{link}"
541
+
542
+ #Because the msi installer doesn't add Puppet to the environment path
543
+ #Add both potential paths for simplicity
544
+ #NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up
545
+ puppetbin_path = "\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\""
546
+ on host, %Q{ echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc }
547
+
548
+ on host, "cmd /C 'start /w msiexec.exe /qn /i #{dest}'"
549
+ else
550
+ dest = "C:\\Windows\\Temp\\#{host['dist']}.msi"
551
+
552
+ on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{dest}')")
553
+
554
+ on host, "start /w msiexec.exe /qn /i #{dest}"
555
+ end
556
+
557
+ configure_foss_defaults_on( host )
558
+ if not host.is_cygwin?
559
+ host.mkdir_p host['distmoduledir']
560
+ end
561
+ end
562
+
563
+ # Installs Puppet and dependencies from dmg
564
+ #
565
+ # @param [Host] host The host to install packages on
566
+ # @param [Hash{Symbol=>String}] opts An options hash
567
+ # @option opts [String] :version The version of Puppet to install
568
+ # @option opts [String] :facter_version The version of Facter to install
569
+ # @option opts [String] :hiera_version The version of Hiera to install
570
+ # @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-%version%.msi
571
+ #
572
+ # @return nil
573
+ # @api private
574
+ def install_puppet_from_dmg_on( host, opts )
575
+
576
+ if opts[:version] && !version_is_less(opts[:version], '4.0.0')
577
+ if opts[:puppet_agent_version].nil?
578
+ raise "You must specify the version of puppet-agent you " +
579
+ "want to install if you want to install Puppet 4.0 " +
580
+ "or greater on OSX"
581
+ end
582
+
583
+ opts[:version] = opts[:puppet_agent_version]
584
+ install_puppet_agent_from_dmg_on(host, opts)
585
+
586
+ else
587
+ puppet_ver = opts[:version] || 'latest'
588
+ facter_ver = opts[:facter_version] || 'latest'
589
+ hiera_ver = opts[:hiera_version] || 'latest'
590
+
591
+ if [puppet_ver, facter_ver, hiera_ver].include?(nil)
592
+ raise "You need to specify versions for OSX host\n eg. install_puppet({:version => '3.6.2',:facter_version => '2.1.0',:hiera_version => '1.3.4',})"
593
+ end
594
+
595
+ on host, "curl -O #{opts[:mac_download_url]}/puppet-#{puppet_ver}.dmg"
596
+ on host, "curl -O #{opts[:mac_download_url]}/facter-#{facter_ver}.dmg"
597
+ on host, "curl -O #{opts[:mac_download_url]}/hiera-#{hiera_ver}.dmg"
598
+
599
+ host.install_package("puppet-#{puppet_ver}")
600
+ host.install_package("facter-#{facter_ver}")
601
+ host.install_package("hiera-#{hiera_ver}")
602
+
603
+ configure_foss_defaults_on( host )
604
+ end
605
+ end
606
+ alias_method :install_puppet_from_dmg, :install_puppet_from_dmg_on
607
+
608
+ # Installs Puppet and dependencies from dmg
609
+ #
610
+ # @param [Host] host The host to install packages on
611
+ # @param [Hash{Symbol=>String}] opts An options hash
612
+ # @option opts [String] :version The version of Puppet Agent to install
613
+ # @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-%version%.msi
614
+ #
615
+ # @return nil
616
+ # @api private
617
+ def install_puppet_agent_from_dmg_on(host, opts)
618
+ version = opts[:version] || 'latest'
619
+ on host, "curl -O #{opts[:mac_download_url]}/puppet-agent-#{version}.dmg"
620
+
621
+ host.install_package("puppet-agent-#{version}")
622
+
623
+ configure_foss_defaults_on( host )
624
+ end
625
+
626
+ # Installs Puppet and dependencies from gem
627
+ #
628
+ # @param [Host] host The host to install packages on
629
+ # @param [Hash{Symbol=>String}] opts An options hash
630
+ # @option opts [String] :version The version of Puppet to install, if nil installs latest
631
+ # @option opts [String] :facter_version The version of Facter to install, if nil installs latest
632
+ # @option opts [String] :hiera_version The version of Hiera to install, if nil installs latest
633
+ #
634
+ # @return nil
635
+ # @raise [StandardError] if gem does not exist on target host
636
+ # @api private
637
+ def install_puppet_from_gem_on( host, opts )
638
+ # There are a lot of special things to do for Solaris and Solaris 10.
639
+ # This is easier than checking host['platform'] every time.
640
+ is_solaris10 = host['platform'] =~ /solaris-10/
641
+ is_solaris = host['platform'] =~ /solaris/
642
+
643
+ # Hosts may be provisioned with csw but pkgutil won't be in the
644
+ # PATH by default to avoid changing the behavior for Puppet's tests
645
+ if is_solaris10
646
+ on host, 'ln -s /opt/csw/bin/pkgutil /usr/bin/pkgutil'
647
+ end
648
+
649
+ # Solaris doesn't necessarily have this, but gem needs it
650
+ if is_solaris
651
+ on host, 'mkdir -p /var/lib'
652
+ end
653
+
654
+ unless host.check_for_command( 'gem' )
655
+ gempkg = case host['platform']
656
+ when /solaris-11/ then 'ruby-18'
657
+ when /ubuntu-14/ then 'ruby'
658
+ when /solaris-10|ubuntu|debian|el-|cumulus/ then 'rubygems'
659
+ else
660
+ raise "install_puppet() called with default_action " +
661
+ "'gem_install' but program `gem' is " +
662
+ "not installed on #{host.name}"
663
+ end
664
+
665
+ host.install_package gempkg
666
+ end
667
+
668
+ # Link 'gem' to /usr/bin instead of adding /opt/csw/bin to PATH.
669
+ if is_solaris10
670
+ on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem'
671
+ end
672
+
673
+ if host['platform'] =~ /debian|ubuntu|solaris|cumulus/
674
+ gem_env = YAML.load( on( host, 'gem environment' ).stdout )
675
+ gem_paths_array = gem_env['RubyGems Environment'].find {|h| h['GEM PATHS'] != nil }['GEM PATHS']
676
+ path_with_gem = 'export PATH=' + gem_paths_array.join(':') + ':${PATH}'
677
+ on host, "echo '#{path_with_gem}' >> ~/.bashrc"
678
+ end
679
+
680
+ if opts[:facter_version]
681
+ on host, "gem install facter -v'#{opts[:facter_version]}' --no-ri --no-rdoc"
682
+ end
683
+
684
+ if opts[:hiera_version]
685
+ on host, "gem install hiera -v'#{opts[:hiera_version]}' --no-ri --no-rdoc"
686
+ end
687
+
688
+ ver_cmd = opts[:version] ? "-v '#{opts[:version]}'" : ''
689
+ on host, "gem install puppet #{ver_cmd} --no-ri --no-rdoc"
690
+
691
+ # Similar to the treatment of 'gem' above.
692
+ # This avoids adding /opt/csw/bin to PATH.
693
+ if is_solaris
694
+ gem_env = YAML.load( on( host, 'gem environment' ).stdout )
695
+ # This is the section we want - this has the dir where gem executables go.
696
+ env_sect = 'EXECUTABLE DIRECTORY'
697
+ # Get the directory where 'gem' installs executables.
698
+ # On Solaris 10 this is usually /opt/csw/bin
699
+ gem_exec_dir = gem_env['RubyGems Environment'].find {|h| h[env_sect] != nil }[env_sect]
700
+
701
+ on host, "ln -s #{gem_exec_dir}/hiera /usr/bin/hiera"
702
+ on host, "ln -s #{gem_exec_dir}/facter /usr/bin/facter"
703
+ on host, "ln -s #{gem_exec_dir}/puppet /usr/bin/puppet"
704
+ end
705
+ configure_foss_defaults_on( host )
706
+ end
707
+ alias_method :install_puppet_from_gem, :install_puppet_from_gem_on
708
+ alias_method :install_puppet_agent_from_gem_on, :install_puppet_from_gem_on
709
+
710
+ # Install official puppetlabs release repository configuration on host.
711
+ #
712
+ # @param [Host] host An object implementing {Beaker::Hosts}'s
713
+ # interface.
714
+ #
715
+ # @note This method only works on redhat-like and debian-like hosts.
716
+ #
717
+ def install_puppetlabs_release_repo_on( host, repo = nil, opts = options )
718
+ variant, version, arch, codename = host['platform'].to_array
719
+ repo_name = repo.nil? ? '' : '-' + repo
720
+
721
+ case variant
722
+ when /^(fedora|el|centos)$/
723
+ variant = (($1 == 'centos') ? 'el' : $1)
724
+
725
+ rpm = "puppetlabs-release%s-%s-%s.noarch.rpm" % [repo_name, variant, version]
726
+ remote = URI.join( options[:release_yum_repo_url], rpm )
727
+
728
+ on host, "rpm -ivh #{remote}"
729
+
730
+ when /^(debian|ubuntu|cumulus)$/
731
+ deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename]
732
+
733
+ remote = URI.join( options[:release_apt_repo_url], deb )
734
+
735
+ on host, "wget -O /tmp/puppet.deb #{remote}"
736
+ on host, "dpkg -i --force-all /tmp/puppet.deb"
737
+ on host, "apt-get update"
738
+ else
739
+ raise "No repository installation step for #{variant} yet..."
740
+ end
741
+ configure_foss_defaults_on( host )
742
+ end
743
+ alias_method :install_puppetlabs_release_repo, :install_puppetlabs_release_repo_on
744
+
745
+ # Install development repository on the given host. This method pushes all
746
+ # repository information including package files for the specified
747
+ # package_name to the host and modifies the repository configuration file
748
+ # to point at the new repository. This is particularly useful for
749
+ # installing development packages on hosts that can't access the builds
750
+ # server.
751
+ #
752
+ # @param [Host] host An object implementing {Beaker::Hosts}'s
753
+ # interface.
754
+ # @param [String] package_name The name of the package whose repository is
755
+ # being installed.
756
+ # @param [String] build_version A string identifying the output of a
757
+ # packaging job for use in looking up
758
+ # repository directory information
759
+ # @param [String] repo_configs_dir A local directory where repository files will be
760
+ # stored as an intermediate step before
761
+ # pushing them to the given host.
762
+ # @param [Hash{Symbol=>String}] opts Options to alter execution.
763
+ # @option opts [String] :dev_builds_url The URL to look for dev builds.
764
+ # @option opts [String, Array<String>] :dev_builds_repos The repo(s)
765
+ # to check for dev builds in.
766
+ #
767
+ # @note This method only works on redhat-like and debian-like hosts.
768
+ #
769
+ def install_puppetlabs_dev_repo ( host, package_name, build_version,
770
+ repo_configs_dir = 'tmp/repo_configs',
771
+ opts = options )
772
+ variant, version, arch, codename = host['platform'].to_array
773
+ platform_configs_dir = File.join(repo_configs_dir, variant)
774
+
775
+ # some of the uses of dev_builds_url below can't include protocol info,
776
+ # plus this opens up possibility of switching the behavior on provided
777
+ # url type
778
+ _, protocol, hostname = opts[:dev_builds_url].partition /.*:\/\//
779
+ dev_builds_url = protocol + hostname
780
+
781
+ on host, "mkdir -p /root/#{package_name}"
782
+
783
+ case variant
784
+ when /^(fedora|el|centos)$/
785
+ variant = (($1 == 'centos') ? 'el' : $1)
786
+ fedora_prefix = ((variant == 'fedora') ? 'f' : '')
787
+
788
+ if host.is_pe?
789
+ pattern = "pl-%s-%s-repos-pe-%s-%s%s-%s.repo"
790
+ else
791
+ pattern = "pl-%s-%s-%s-%s%s-%s.repo"
792
+ end
793
+
794
+ repo_filename = pattern % [
795
+ package_name,
796
+ build_version,
797
+ variant,
798
+ fedora_prefix,
799
+ version,
800
+ arch
801
+ ]
802
+
803
+ repo = fetch_http_file( "%s/%s/%s/repo_configs/rpm/" %
804
+ [ dev_builds_url, package_name, build_version ],
805
+ repo_filename,
806
+ platform_configs_dir)
807
+
808
+ link = nil
809
+ package_repos = opts[:dev_builds_repos].nil? ? [] : [opts[:dev_builds_repos]]
810
+ package_repos.push(['products', 'devel']).flatten!
811
+ package_repos.each do |repo|
812
+ link = "%s/%s/%s/repos/%s/%s%s/%s/%s/" %
813
+ [ dev_builds_url, package_name, build_version, variant,
814
+ fedora_prefix, version, repo, arch ]
815
+
816
+ unless link_exists?( link )
817
+ logger.debug("couldn't find link at '#{repo}', falling back to next option...")
818
+ else
819
+ logger.debug("found link at '#{repo}'")
820
+ break
821
+ end
822
+ end
823
+ raise "Unable to reach a repo directory at #{link}" unless link_exists?( link )
824
+
825
+ repo_dir = fetch_http_dir( link, platform_configs_dir )
826
+
827
+ config_dir = '/etc/yum.repos.d/'
828
+ scp_to host, repo, config_dir
829
+ scp_to host, repo_dir, "/root/#{package_name}"
830
+
831
+ search = "baseurl\\s*=\\s*http:\\/\\/#{hostname}.*$"
832
+ replace = "baseurl=file:\\/\\/\\/root\\/#{package_name}\\/#{arch}"
833
+ sed_command = "sed -i 's/#{search}/#{replace}/'"
834
+ find_and_sed = "find #{config_dir} -name \"*.repo\" -exec #{sed_command} {} \\;"
835
+
836
+ on host, find_and_sed
837
+
838
+ when /^(debian|ubuntu|cumulus)$/
839
+ list = fetch_http_file( "%s/%s/%s/repo_configs/deb/" %
840
+ [ dev_builds_url, package_name, build_version ],
841
+ "pl-%s-%s-%s.list" %
842
+ [ package_name, build_version, codename ],
843
+ platform_configs_dir )
844
+
845
+ repo_dir = fetch_http_dir( "%s/%s/%s/repos/apt/%s" %
846
+ [ dev_builds_url, package_name,
847
+ build_version, codename ],
848
+ platform_configs_dir )
849
+
850
+ config_dir = '/etc/apt/sources.list.d'
851
+ scp_to host, list, config_dir
852
+ scp_to host, repo_dir, "/root/#{package_name}"
853
+
854
+ repo_name = nil
855
+ package_repos = opts[:dev_builds_repos].nil? ? [] : [opts[:dev_builds_repos]]
856
+ package_repos.flatten!
857
+ package_repos.each do |repo|
858
+ repo_path = "/root/#{package_name}/#{codename}/#{repo}"
859
+ repo_check = on(host, "[[ -d #{repo_path} ]]", :acceptable_exit_codes => [0,1])
860
+ if repo_check.exit_code == 0
861
+ logger.debug("found repo at '#{repo_path}'")
862
+ repo_name = repo
863
+ break
864
+ else
865
+ logger.debug("couldn't find repo at '#{repo_path}', falling back to next option...")
866
+ end
867
+ end
868
+ if repo_name.nil?
869
+ repo_name = 'main'
870
+ logger.debug("using default repo '#{repo_name}'")
871
+ end
872
+
873
+ search = "deb\\s\\+http:\\/\\/#{hostname}.*$"
874
+ replace = "deb file:\\/\\/\\/root\\/#{package_name}\\/#{codename} #{codename} #{repo_name}"
875
+ sed_command = "sed -i 's/#{search}/#{replace}/'"
876
+ find_and_sed = "find #{config_dir} -name \"*.list\" -exec #{sed_command} {} \\;"
877
+
878
+ on host, find_and_sed
879
+ on host, "apt-get update"
880
+ configure_foss_defaults_on( host )
881
+
882
+ else
883
+ raise "No repository installation step for #{variant} yet..."
884
+ end
885
+ end
886
+
887
+ # Installs packages from the local development repository on the given host
888
+ #
889
+ # @param [Host] host An object implementing {Beaker::Hosts}'s
890
+ # interface.
891
+ # @param [Regexp] package_name The name of the package whose repository is
892
+ # being installed.
893
+ #
894
+ # @note This method only works on redhat-like and debian-like hosts.
895
+ # @note This method is paired to be run directly after {#install_puppetlabs_dev_repo}
896
+ #
897
+ def install_packages_from_local_dev_repo( host, package_name )
898
+ if host['platform'] =~ /debian|ubuntu|cumulus/
899
+ find_filename = '*.deb'
900
+ find_command = 'dpkg -i'
901
+ elsif host['platform'] =~ /fedora|el|centos/
902
+ find_filename = '*.rpm'
903
+ find_command = 'rpm -ivh'
904
+ else
905
+ raise "No repository installation step for #{host['platform']} yet..."
906
+ end
907
+ find_command = "find /root/#{package_name} -type f -name '#{find_filename}' -exec #{find_command} {} \\;"
908
+ on host, find_command
909
+ configure_foss_defaults_on( host )
910
+ end
911
+
912
+ # Install development repo of the puppet-agent on the given host
913
+ #
914
+ # @param [Host] host An object implementing {Beaker::Hosts}'s interface
915
+ # @param [Hash{Symbol=>String}] opts An options hash
916
+ # @option opts [String] :version The version of puppet-agent to install
917
+ # @option opts [String] :copy_base_local Directory where puppet-agent artifact
918
+ # will be stored locally
919
+ # (default: 'tmp/repo_configs')
920
+ # @option opts [String] :copy_dir_external Directory where puppet-agent
921
+ # artifact will be pushed to on the external machine
922
+ # (default: '/root')
923
+ #
924
+ # @note on windows, the +:ruby_arch+ host parameter can determine in addition
925
+ # to other settings whether the 32 or 64bit install is used
926
+ #
927
+ # @return nil
928
+ def install_puppetagent_dev_repo( host, opts )
929
+ opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
930
+ opts[:copy_dir_external] ||= File.join('/', 'root')
931
+ variant, version, arch, codename = host['platform'].to_array
932
+ release_path = "#{options[:dev_builds_url]}/puppet-agent/#{opts[:version]}/artifacts/"
933
+ copy_dir_local = File.join(opts[:copy_base_local], variant)
934
+ onhost_copy_base = opts[:copy_dir_external]
935
+
936
+ case variant
937
+ when /^(fedora|el|centos)$/
938
+ release_path << "el/#{version}/products/#{arch}"
939
+ release_file = "puppet-agent-#{opts[:version]}-1.#{arch}.rpm"
940
+ when /^(debian|ubuntu|cumulus)$/
941
+ release_path << "deb/#{codename}"
942
+ release_file = "puppet-agent_#{opts[:version]}-1_#{arch}.deb"
943
+ when /^windows$/
944
+ release_path << 'windows'
945
+ onhost_copy_base = '`cygpath -smF 35`/'
946
+ is_config_32 = host['ruby_arch'] == 'x86' || host['install_32'] || opts['install_32']
947
+ should_install_64bit = host.is_x86_64? && !is_config_32
948
+ # only install 64bit builds if
949
+ # - we do not have install_32 set on host
950
+ # - we do not have install_32 set globally
951
+ arch_suffix = should_install_64bit ? '64' : '86'
952
+ release_file = "puppet-agent-x#{arch_suffix}.msi"
953
+ else
954
+ raise "No repository installation step for #{variant} yet..."
955
+ end
956
+
957
+ onhost_copied_file = File.join(onhost_copy_base, release_file)
958
+ fetch_http_file( release_path, release_file, copy_dir_local)
959
+ scp_to host, File.join(copy_dir_local, release_file), onhost_copy_base
960
+
961
+ case variant
962
+ when /^(fedora|el|centos)$/
963
+ on host, "rpm -ivh #{onhost_copied_file}"
964
+ when /^(debian|ubuntu|cumulus)$/
965
+ on host, "dpkg -i --force-all #{onhost_copied_file}"
966
+ on host, "apt-get update"
967
+ when /^windows$/
968
+ result = on host, "echo #{onhost_copied_file}"
969
+ onhost_copied_file = result.raw_output.chomp
970
+ on host, Command.new("start /w #{onhost_copied_file}", [], { :cmdexe => true })
971
+ end
972
+ configure_foss_defaults_on( host )
973
+ end
974
+
975
+ # This method will install a pem file certifcate on a windows host
976
+ #
977
+ # @param [Host] host A host object
978
+ # @param [String] cert_name The name of the pem file
979
+ # @param [String] cert The contents of the certificate
980
+ #
981
+ def install_cert_on_windows(host, cert_name, cert)
982
+ create_remote_file(host, "C:\\Windows\\Temp\\#{cert_name}.pem", cert)
983
+ on host, "certutil -v -addstore Root C:\\Windows\\Temp\\#{cert_name}.pem"
984
+ end
985
+ end
986
+ end
987
+ end
988
+ end