beaker 2.14.1 → 2.15.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.
Files changed (43) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +286 -27
  3. data/beaker.gemspec +1 -0
  4. data/lib/beaker/answers.rb +1 -1
  5. data/lib/beaker/answers/version40.rb +7 -5
  6. data/lib/beaker/cli.rb +2 -2
  7. data/lib/beaker/dsl/helpers/puppet_helpers.rb +24 -2
  8. data/lib/beaker/dsl/helpers/web_helpers.rb +3 -1
  9. data/lib/beaker/dsl/install_utils/foss_defaults.rb +11 -1
  10. data/lib/beaker/dsl/install_utils/foss_utils.rb +358 -248
  11. data/lib/beaker/dsl/install_utils/module_utils.rb +1 -7
  12. data/lib/beaker/dsl/install_utils/pe_defaults.rb +1 -1
  13. data/lib/beaker/dsl/install_utils/pe_utils.rb +63 -9
  14. data/lib/beaker/dsl/install_utils/puppet_utils.rb +40 -0
  15. data/lib/beaker/dsl/structure.rb +35 -0
  16. data/lib/beaker/host/pswindows/exec.rb +9 -0
  17. data/lib/beaker/host/unix/exec.rb +10 -1
  18. data/lib/beaker/host/unix/pkg.rb +0 -2
  19. data/lib/beaker/host_prebuilt_steps.rb +2 -2
  20. data/lib/beaker/hypervisor/aws_sdk.rb +1 -1
  21. data/lib/beaker/options/command_line_parser.rb +7 -0
  22. data/lib/beaker/options/parser.rb +28 -8
  23. data/lib/beaker/options/presets.rb +4 -3
  24. data/lib/beaker/shared/semvar.rb +23 -2
  25. data/lib/beaker/test_suite.rb +2 -2
  26. data/lib/beaker/version.rb +1 -1
  27. data/spec/beaker/cli_spec.rb +35 -34
  28. data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +78 -7
  29. data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +126 -17
  30. data/spec/beaker/dsl/install_utils/module_utils_spec.rb +2 -2
  31. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +106 -0
  32. data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +73 -0
  33. data/spec/beaker/dsl/structure_spec.rb +67 -0
  34. data/spec/beaker/host/unix/exec_spec.rb +53 -0
  35. data/spec/beaker/host/windows/exec_spec.rb +53 -0
  36. data/spec/beaker/host_prebuilt_steps_spec.rb +13 -0
  37. data/spec/beaker/hypervisor/aws_sdk_spec.rb +65 -0
  38. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  39. data/spec/beaker/options/parser_spec.rb +126 -1
  40. data/spec/beaker/shared/semvar_spec.rb +43 -0
  41. data/spec/beaker/test_suite_spec.rb +21 -0
  42. data/spec/helpers.rb +4 -0
  43. metadata +19 -2
@@ -41,6 +41,8 @@ module Beaker
41
41
  #
42
42
  # @!visibility private
43
43
  def fetch_http_file(base_url, file_name, dst_dir)
44
+ require 'open-uri'
45
+ require 'open_uri_redirections'
44
46
  FileUtils.makedirs(dst_dir)
45
47
  src = "#{base_url}/#{file_name}"
46
48
  dst = File.join(dst_dir, file_name)
@@ -49,7 +51,7 @@ module Beaker
49
51
  else
50
52
  logger.notify "Fetching: #{src}"
51
53
  logger.notify " and saving to #{dst}"
52
- open(src) do |remote|
54
+ open(src, :allow_redirections => :all) do |remote|
53
55
  File.open(dst, "w") do |file|
54
56
  FileUtils.copy_stream(remote, file)
55
57
  end
@@ -6,6 +6,16 @@ module Beaker
6
6
  #
7
7
  module FOSSDefaults
8
8
 
9
+ #Here be the default download URLs
10
+ FOSS_DEFAULT_DOWNLOAD_URLS = {
11
+ :win_download_url => "http://downloads.puppetlabs.com/windows",
12
+ :mac_download_url => "http://downloads.puppetlabs.com/mac",
13
+ :pe_promoted_builds_url => "http://pm.puppetlabs.com",
14
+ :release_apt_repo_url => "http://apt.puppetlabs.com",
15
+ :release_yum_repo_url => "http://yum.puppetlabs.com",
16
+ :dev_builds_url => "http://builds.delivery.puppetlabs.net",
17
+ }
18
+
9
19
  #Here be the pathing and default values for FOSS installs
10
20
  #
11
21
  FOSS_DEFAULTS = {
@@ -128,7 +138,7 @@ module Beaker
128
138
  # @param [Host] host A single host to act upon
129
139
  # @param [String] platform The platform type of this host, one of windows, pswindows, freebsd, mac & unix
130
140
  def remove_platform_foss_defaults(host, platform)
131
- PE_DEFAULTS[platform].each_pair do |key, val|
141
+ FOSS_DEFAULTS[platform].each_pair do |key, val|
132
142
  host.delete(key)
133
143
  end
134
144
  host['group'] = nil
@@ -19,11 +19,6 @@ module Beaker
19
19
  include FOSSDefaults
20
20
  include PuppetUtils
21
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
22
  # The default install path
28
23
  SourcePath = "/opt/puppet-git-repos"
29
24
 
@@ -40,7 +35,7 @@ module Beaker
40
35
  # or a role (String or Symbol) that identifies one or more hosts.
41
36
  def configure_foss_defaults_on( hosts )
42
37
  block_on hosts do |host|
43
- if host['type'] && host['type'] =~ /aio/
38
+ if (host[:version] && (not version_is_less(host[:version], '4.0'))) or host['type'] && host['type'] =~ /aio/
44
39
  # add foss defaults to host
45
40
  add_aio_defaults_on(host)
46
41
  else
@@ -220,7 +215,7 @@ module Beaker
220
215
  # @raise [StandardError] When encountering an unsupported platform by default, or if gem cannot be found when default_action => 'gem_install'
221
216
  # @raise [FailTest] When error occurs during the actual installation process
222
217
  def install_puppet_on(hosts, opts={})
223
- opts = DEFAULT_DOWNLOAD_URLS.merge(opts)
218
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
224
219
 
225
220
  # If version isn't specified assume the latest in the 3.x series
226
221
  if opts[:version] and not version_is_less(opts[:version], '4.0.0')
@@ -251,6 +246,8 @@ module Beaker
251
246
  end
252
247
  end
253
248
 
249
+ host[:version] = opts[:version]
250
+
254
251
  # Certain install paths may not create the config dirs/files needed
255
252
  on host, "mkdir -p #{host['puppetpath']}" unless host[:type] =~ /aio/
256
253
  on host, "echo '' >> #{host.puppet['hiera_config']}"
@@ -282,25 +279,30 @@ module Beaker
282
279
  # @option opts [String] :puppet_gem_version Version of puppet to install via gem if no puppet-agent package is available
283
280
  # @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-agent-%version%.msi
284
281
  # @option opts [String] :win_download_url Url to download dmg pattern of %url%/puppet-agent-%version%.msi
282
+ # @option opts [String] :puppet_collection Defaults to 'PC1'
285
283
  #
286
284
  # @return nil
287
285
  # @raise [StandardError] When encountering an unsupported platform by default, or if gem cannot be found when default_action => 'gem_install'
288
286
  # @raise [FailTest] When error occurs during the actual installation process
289
287
  def install_puppet_agent_on(hosts, opts)
290
- opts = DEFAULT_DOWNLOAD_URLS.merge(opts)
291
- opts[:repo] ||= 'pc1'
288
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
289
+ opts[:puppet_collection] ||= 'PC1'
292
290
 
293
291
  block_on hosts do |host|
292
+ host[:type] = 'aio' #we are installing agent, so we want aio type
294
293
  case host['platform']
294
+ when /el-4|sles/
295
+ # pe-only agent, get from dev repo
296
+ logger.warn("install_puppet_agent_on for pe-only platform #{host['platform']} - use install_puppet_agent_pe_promoted_repo_on")
295
297
  when /el-|fedora/
296
- install_puppetlabs_release_repo(host, opts[:repo])
298
+ install_puppetlabs_release_repo(host, opts[:puppet_collection])
297
299
  if opts[:version]
298
300
  host.install_package("puppet-agent-#{opts[:version]}")
299
301
  else
300
302
  host.install_package('puppet-agent')
301
303
  end
302
304
  when /debian|ubuntu|cumulus/
303
- install_puppetlabs_release_repo(host, opts[:repo])
305
+ install_puppetlabs_release_repo(host, opts[:puppet_collection])
304
306
  if opts[:version]
305
307
  host.install_package("puppet-agent=#{opts[:version]}-1#{host['platform'].codename}")
306
308
  else
@@ -382,9 +384,10 @@ module Beaker
382
384
  end
383
385
  end
384
386
 
385
- # Installs Puppet and dependencies using rpm
387
+ # Installs Puppet and dependencies using rpm on provided host(s).
386
388
  #
387
- # @param [Host] host The host to install packages on
389
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
390
+ # or a role (String or Symbol) that identifies one or more hosts.
388
391
  # @param [Hash{Symbol=>String}] opts An options hash
389
392
  # @option opts [String] :version The version of Puppet to install, if nil installs latest version
390
393
  # @option opts [String] :facter_version The version of Facter to install, if nil installs latest version
@@ -394,26 +397,29 @@ module Beaker
394
397
  #
395
398
  # @return nil
396
399
  # @api private
397
- def install_puppet_from_rpm_on( host, opts )
398
- install_puppetlabs_release_repo(host)
400
+ def install_puppet_from_rpm_on( hosts, opts )
401
+ block_on hosts do |host|
402
+ install_puppetlabs_release_repo(host)
399
403
 
400
- if opts[:facter_version]
401
- host.install_package("facter-#{opts[:facter_version]}")
402
- end
404
+ if opts[:facter_version]
405
+ host.install_package("facter-#{opts[:facter_version]}")
406
+ end
403
407
 
404
- if opts[:hiera_version]
405
- host.install_package("hiera-#{opts[:hiera_version]}")
406
- end
408
+ if opts[:hiera_version]
409
+ host.install_package("hiera-#{opts[:hiera_version]}")
410
+ end
407
411
 
408
- puppet_pkg = opts[:version] ? "puppet-#{opts[:version]}" : 'puppet'
409
- host.install_package("#{puppet_pkg}")
410
- configure_foss_defaults_on( host )
412
+ puppet_pkg = opts[:version] ? "puppet-#{opts[:version]}" : 'puppet'
413
+ host.install_package("#{puppet_pkg}")
414
+ configure_foss_defaults_on( host )
415
+ end
411
416
  end
412
417
  alias_method :install_puppet_from_rpm, :install_puppet_from_rpm_on
413
418
 
414
- # Installs Puppet and dependencies from deb
419
+ # Installs Puppet and dependencies from deb on provided host(s).
415
420
  #
416
- # @param [Host] host The host to install packages on
421
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
422
+ # or a role (String or Symbol) that identifies one or more hosts.
417
423
  # @param [Hash{Symbol=>String}] opts An options hash
418
424
  # @option opts [String] :version The version of Puppet to install, if nil installs latest version
419
425
  # @option opts [String] :facter_version The version of Facter to install, if nil installs latest version
@@ -421,30 +427,33 @@ module Beaker
421
427
  #
422
428
  # @return nil
423
429
  # @api private
424
- def install_puppet_from_deb_on( host, opts )
425
- install_puppetlabs_release_repo(host)
430
+ def install_puppet_from_deb_on( hosts, opts )
431
+ block_on hosts do |host|
432
+ install_puppetlabs_release_repo(host)
426
433
 
427
- if opts[:facter_version]
428
- host.install_package("facter=#{opts[:facter_version]}-1puppetlabs1")
429
- end
434
+ if opts[:facter_version]
435
+ host.install_package("facter=#{opts[:facter_version]}-1puppetlabs1")
436
+ end
430
437
 
431
- if opts[:hiera_version]
432
- host.install_package("hiera=#{opts[:hiera_version]}-1puppetlabs1")
433
- end
438
+ if opts[:hiera_version]
439
+ host.install_package("hiera=#{opts[:hiera_version]}-1puppetlabs1")
440
+ end
434
441
 
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')
442
+ if opts[:version]
443
+ host.install_package("puppet-common=#{opts[:version]}-1puppetlabs1")
444
+ host.install_package("puppet=#{opts[:version]}-1puppetlabs1")
445
+ else
446
+ host.install_package('puppet')
447
+ end
448
+ configure_foss_defaults_on( host )
440
449
  end
441
- configure_foss_defaults_on( host )
442
450
  end
443
451
  alias_method :install_puppet_from_deb, :install_puppet_from_deb_on
444
452
 
445
- # Installs Puppet and dependencies from msi
453
+ # Installs Puppet and dependencies from msi on provided host(s).
446
454
  #
447
- # @param [Host] host The host to install packages on
455
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
456
+ # or a role (String or Symbol) that identifies one or more hosts.
448
457
  # @param [Hash{Symbol=>String}] opts An options hash
449
458
  # @option opts [String] :version The version of Puppet to install
450
459
  # @option opts [String] :puppet_agent_version The version of the
@@ -453,24 +462,26 @@ module Beaker
453
462
  #
454
463
  # @note on windows, the +:ruby_arch+ host parameter can determine in addition
455
464
  # 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]
465
+ def install_puppet_from_msi_on( hosts, opts )
466
+ block_on hosts do |host|
467
+ version = opts[:version]
459
468
 
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
469
+ if version && !version_is_less(version, '4.0.0')
470
+ if opts[:puppet_agent_version].nil?
471
+ raise "You must specify the version of puppet agent you " +
472
+ "want to install if you want to install Puppet 4.0 " +
473
+ "or greater on Windows"
474
+ end
466
475
 
467
- opts[:version] = opts[:puppet_agent_version]
468
- install_puppet_agent_from_msi_on(host, opts)
476
+ opts[:version] = opts[:puppet_agent_version]
477
+ install_puppet_agent_from_msi_on(host, opts)
469
478
 
470
- else
471
- compute_puppet_msi_name(host, opts)
472
- install_a_puppet_msi_on(host, opts)
479
+ else
480
+ compute_puppet_msi_name(host, opts)
481
+ install_a_puppet_msi_on(host, opts)
473
482
 
483
+ end
484
+ configure_foss_defaults_on( host )
474
485
  end
475
486
  end
476
487
  alias_method :install_puppet_from_msi, :install_puppet_from_msi_on
@@ -506,63 +517,72 @@ module Beaker
506
517
  end
507
518
  end
508
519
 
509
- # Installs Puppet Agent and dependencies from msi
520
+ # Installs Puppet Agent and dependencies from msi on provided host(s).
510
521
  #
511
- # @param [Host] host The host to install packages on
522
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
523
+ # or a role (String or Symbol) that identifies one or more hosts.
512
524
  # @param [Hash{Symbol=>String}] opts An options hash
513
525
  # @option opts [String] :version The version of Puppet Agent to install
514
526
  # @option opts [String] :win_download_url The url to download puppet from
515
527
  #
516
528
  # @note on windows, the +:ruby_arch+ host parameter can determine in addition
517
529
  # 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'
530
+ def install_puppet_agent_from_msi_on(hosts, opts)
531
+ block_on hosts do |host|
520
532
 
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
533
+ is_config_32 = true == (host['ruby_arch'] == 'x86') || host['install_32'] || opts['install_32']
534
+ should_install_64bit = host.is_x86_64? && !is_config_32
535
+ arch = should_install_64bit ? 'x64' : 'x86'
527
536
 
528
- install_a_puppet_msi_on(host, opts)
537
+ # If we don't specify a version install the latest MSI for puppet-agent
538
+ if opts[:version]
539
+ host['dist'] = "puppet-agent-#{opts[:version]}-#{arch}"
540
+ else
541
+ host['dist'] = "puppet-agent-#{arch}-latest"
542
+ end
543
+
544
+ install_a_puppet_msi_on(host, opts)
545
+ end
529
546
  end
530
547
 
531
548
  # @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
549
+ def install_a_puppet_msi_on(hosts, opts)
550
+ block_on hosts do |host|
551
+ link = "#{opts[:win_download_url]}/#{host['dist']}.msi"
552
+ if not link_exists?( link )
553
+ raise "Puppet #{version} at #{link} does not exist!"
554
+ end
537
555
 
538
- if host.is_cygwin?
539
- dest = "#{host['dist']}.msi"
540
- on host, "curl -O #{link}"
556
+ if host.is_cygwin?
557
+ dest = "#{host['dist']}.msi"
558
+ on host, "curl -O #{link}"
541
559
 
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 }
560
+ #Because the msi installer doesn't add Puppet to the environment path
561
+ #Add both potential paths for simplicity
562
+ #NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up
563
+ puppetbin_path = "\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\""
564
+ on host, %Q{ echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc }
547
565
 
548
- on host, "cmd /C 'start /w msiexec.exe /qn /i #{dest}'"
549
- else
550
- dest = "C:\\Windows\\Temp\\#{host['dist']}.msi"
566
+ on host, "cmd /C 'start /w msiexec.exe /qn /i #{dest}'"
567
+ else
568
+ dest = "C:\\Windows\\Temp\\#{host['dist']}.msi"
551
569
 
552
- on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{dest}')")
570
+ on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{dest}')")
553
571
 
554
- on host, "start /w msiexec.exe /qn /i #{dest}"
555
- end
572
+ on host, "start /w msiexec.exe /qn /i #{dest}"
573
+ end
556
574
 
557
- configure_foss_defaults_on( host )
558
- if not host.is_cygwin?
559
- host.mkdir_p host['distmoduledir']
575
+ configure_foss_defaults_on( host )
576
+ if not host.is_cygwin?
577
+ host.mkdir_p host['distmoduledir']
578
+ end
560
579
  end
561
580
  end
562
581
 
563
- # Installs Puppet and dependencies from dmg
582
+ # Installs Puppet and dependencies from dmg on provided host(s).
564
583
  #
565
- # @param [Host] host The host to install packages on
584
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
585
+ # or a role (String or Symbol) that identifies one or more hosts.
566
586
  # @param [Hash{Symbol=>String}] opts An options hash
567
587
  # @option opts [String] :version The version of Puppet to install
568
588
  # @option opts [String] :facter_version The version of Facter to install
@@ -571,61 +591,66 @@ module Beaker
571
591
  #
572
592
  # @return nil
573
593
  # @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
594
+ def install_puppet_from_dmg_on( hosts, opts )
595
+ block_on hosts do |host|
596
+ if opts[:version] && !version_is_less(opts[:version], '4.0.0')
597
+ if opts[:puppet_agent_version].nil?
598
+ raise "You must specify the version of puppet-agent you " +
599
+ "want to install if you want to install Puppet 4.0 " +
600
+ "or greater on OSX"
601
+ end
582
602
 
583
- opts[:version] = opts[:puppet_agent_version]
584
- install_puppet_agent_from_dmg_on(host, opts)
603
+ opts[:version] = opts[:puppet_agent_version]
604
+ install_puppet_agent_from_dmg_on(host, opts)
585
605
 
586
- else
587
- puppet_ver = opts[:version] || 'latest'
588
- facter_ver = opts[:facter_version] || 'latest'
589
- hiera_ver = opts[:hiera_version] || 'latest'
606
+ else
607
+ puppet_ver = opts[:version] || 'latest'
608
+ facter_ver = opts[:facter_version] || 'latest'
609
+ hiera_ver = opts[:hiera_version] || 'latest'
590
610
 
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
611
+ if [puppet_ver, facter_ver, hiera_ver].include?(nil)
612
+ 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',})"
613
+ end
594
614
 
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"
615
+ on host, "curl -O #{opts[:mac_download_url]}/puppet-#{puppet_ver}.dmg"
616
+ on host, "curl -O #{opts[:mac_download_url]}/facter-#{facter_ver}.dmg"
617
+ on host, "curl -O #{opts[:mac_download_url]}/hiera-#{hiera_ver}.dmg"
598
618
 
599
- host.install_package("puppet-#{puppet_ver}")
600
- host.install_package("facter-#{facter_ver}")
601
- host.install_package("hiera-#{hiera_ver}")
619
+ host.install_package("puppet-#{puppet_ver}")
620
+ host.install_package("facter-#{facter_ver}")
621
+ host.install_package("hiera-#{hiera_ver}")
602
622
 
603
- configure_foss_defaults_on( host )
623
+ configure_foss_defaults_on( host )
624
+ end
604
625
  end
605
626
  end
606
627
  alias_method :install_puppet_from_dmg, :install_puppet_from_dmg_on
607
628
 
608
- # Installs Puppet and dependencies from dmg
629
+ # Installs Puppet and dependencies from dmg on provided host(s).
609
630
  #
610
- # @param [Host] host The host to install packages on
631
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
632
+ # or a role (String or Symbol) that identifies one or more hosts.
611
633
  # @param [Hash{Symbol=>String}] opts An options hash
612
634
  # @option opts [String] :version The version of Puppet Agent to install
613
635
  # @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-%version%.msi
614
636
  #
615
637
  # @return nil
616
638
  # @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"
639
+ def install_puppet_agent_from_dmg_on(hosts, opts)
640
+ block_on hosts do |host|
641
+ version = opts[:version] || 'latest'
642
+ on host, "curl -O #{opts[:mac_download_url]}/puppet-agent-#{version}.dmg"
620
643
 
621
- host.install_package("puppet-agent-#{version}")
644
+ host.install_package("puppet-agent-#{version}")
622
645
 
623
- configure_foss_defaults_on( host )
646
+ configure_foss_defaults_on( host )
647
+ end
624
648
  end
625
649
 
626
- # Installs Puppet and dependencies from gem
650
+ # Installs Puppet and dependencies from gem on provided host(s)
627
651
  #
628
- # @param [Host] host The host to install packages on
652
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
653
+ # or a role (String or Symbol) that identifies one or more hosts.
629
654
  # @param [Hash{Symbol=>String}] opts An options hash
630
655
  # @option opts [String] :version The version of Puppet to install, if nil installs latest
631
656
  # @option opts [String] :facter_version The version of Facter to install, if nil installs latest
@@ -634,111 +659,116 @@ module Beaker
634
659
  # @return nil
635
660
  # @raise [StandardError] if gem does not exist on target host
636
661
  # @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
662
+ def install_puppet_from_gem_on( hosts, opts )
663
+ block_on hosts do |host|
664
+ # There are a lot of special things to do for Solaris and Solaris 10.
665
+ # This is easier than checking host['platform'] every time.
666
+ is_solaris10 = host['platform'] =~ /solaris-10/
667
+ is_solaris = host['platform'] =~ /solaris/
668
+
669
+ # Hosts may be provisioned with csw but pkgutil won't be in the
670
+ # PATH by default to avoid changing the behavior for Puppet's tests
671
+ if is_solaris10
672
+ on host, 'ln -s /opt/csw/bin/pkgutil /usr/bin/pkgutil'
673
+ end
648
674
 
649
- # Solaris doesn't necessarily have this, but gem needs it
650
- if is_solaris
651
- on host, 'mkdir -p /var/lib'
652
- end
675
+ # Solaris doesn't necessarily have this, but gem needs it
676
+ if is_solaris
677
+ on host, 'mkdir -p /var/lib'
678
+ end
653
679
 
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
680
+ unless host.check_for_command( 'gem' )
681
+ gempkg = case host['platform']
682
+ when /solaris-11/ then 'ruby-18'
683
+ when /ubuntu-14/ then 'ruby'
684
+ when /solaris-10|ubuntu|debian|el-|cumulus/ then 'rubygems'
685
+ else
686
+ raise "install_puppet() called with default_action " +
687
+ "'gem_install' but program `gem' is " +
688
+ "not installed on #{host.name}"
689
+ end
690
+
691
+ host.install_package gempkg
692
+ end
667
693
 
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
694
+ # Link 'gem' to /usr/bin instead of adding /opt/csw/bin to PATH.
695
+ if is_solaris10
696
+ on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem'
697
+ end
672
698
 
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
699
+ if host['platform'] =~ /debian|ubuntu|solaris|cumulus/
700
+ gem_env = YAML.load( on( host, 'gem environment' ).stdout )
701
+ gem_paths_array = gem_env['RubyGems Environment'].find {|h| h['GEM PATHS'] != nil }['GEM PATHS']
702
+ path_with_gem = 'export PATH=' + gem_paths_array.join(':') + ':${PATH}'
703
+ on host, "echo '#{path_with_gem}' >> ~/.bashrc"
704
+ end
679
705
 
680
- if opts[:facter_version]
681
- on host, "gem install facter -v'#{opts[:facter_version]}' --no-ri --no-rdoc"
682
- end
706
+ if opts[:facter_version]
707
+ on host, "gem install facter -v'#{opts[:facter_version]}' --no-ri --no-rdoc"
708
+ end
683
709
 
684
- if opts[:hiera_version]
685
- on host, "gem install hiera -v'#{opts[:hiera_version]}' --no-ri --no-rdoc"
686
- end
710
+ if opts[:hiera_version]
711
+ on host, "gem install hiera -v'#{opts[:hiera_version]}' --no-ri --no-rdoc"
712
+ end
687
713
 
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"
714
+ ver_cmd = opts[:version] ? "-v '#{opts[:version]}'" : ''
715
+ on host, "gem install puppet #{ver_cmd} --no-ri --no-rdoc"
716
+
717
+ # Similar to the treatment of 'gem' above.
718
+ # This avoids adding /opt/csw/bin to PATH.
719
+ if is_solaris
720
+ gem_env = YAML.load( on( host, 'gem environment' ).stdout )
721
+ # This is the section we want - this has the dir where gem executables go.
722
+ env_sect = 'EXECUTABLE DIRECTORY'
723
+ # Get the directory where 'gem' installs executables.
724
+ # On Solaris 10 this is usually /opt/csw/bin
725
+ gem_exec_dir = gem_env['RubyGems Environment'].find {|h| h[env_sect] != nil }[env_sect]
726
+
727
+ on host, "ln -s #{gem_exec_dir}/hiera /usr/bin/hiera"
728
+ on host, "ln -s #{gem_exec_dir}/facter /usr/bin/facter"
729
+ on host, "ln -s #{gem_exec_dir}/puppet /usr/bin/puppet"
730
+ end
731
+ configure_foss_defaults_on( host )
704
732
  end
705
- configure_foss_defaults_on( host )
706
733
  end
707
734
  alias_method :install_puppet_from_gem, :install_puppet_from_gem_on
708
735
  alias_method :install_puppet_agent_from_gem_on, :install_puppet_from_gem_on
709
736
 
710
- # Install official puppetlabs release repository configuration on host.
737
+ # Install official puppetlabs release repository configuration on host(s).
711
738
  #
712
- # @param [Host] host An object implementing {Beaker::Hosts}'s
713
- # interface.
739
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
740
+ # or a role (String or Symbol) that identifies one or more hosts.
714
741
  #
715
742
  # @note This method only works on redhat-like and debian-like hosts.
716
743
  #
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
744
+ def install_puppetlabs_release_repo_on( hosts, repo = nil, opts = options )
745
+ block_on hosts do |host|
746
+ variant, version, arch, codename = host['platform'].to_array
747
+ repo_name = repo.nil? ? '' : '-' + repo
748
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
720
749
 
721
- case variant
722
- when /^(fedora|el|centos)$/
723
- variant = (($1 == 'centos') ? 'el' : $1)
750
+ case variant
751
+ when /^(fedora|el|centos)$/
752
+ variant = (($1 == 'centos') ? 'el' : $1)
724
753
 
725
- rpm = "puppetlabs-release%s-%s-%s.noarch.rpm" % [repo_name, variant, version]
726
- remote = URI.join( options[:release_yum_repo_url], rpm )
754
+ rpm = "puppetlabs-release%s-%s-%s.noarch.rpm" % [repo_name, variant, version]
755
+ remote = URI.join( opts[:release_yum_repo_url], rpm )
727
756
 
728
- on host, "rpm -ivh #{remote}"
757
+ on host, "rpm --replacepkgs -ivh #{remote}"
729
758
 
730
- when /^(debian|ubuntu|cumulus)$/
731
- deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename]
759
+ when /^(debian|ubuntu|cumulus)$/
760
+ deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename]
732
761
 
733
- remote = URI.join( options[:release_apt_repo_url], deb )
762
+ remote = URI.join( opts[:release_apt_repo_url], deb )
734
763
 
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..."
764
+ on host, "wget -O /tmp/puppet.deb #{remote}"
765
+ on host, "dpkg -i --force-all /tmp/puppet.deb"
766
+ on host, "apt-get update"
767
+ else
768
+ raise "No repository installation step for #{variant} yet..."
769
+ end
770
+ configure_foss_defaults_on( host )
740
771
  end
741
- configure_foss_defaults_on( host )
742
772
  end
743
773
  alias_method :install_puppetlabs_release_repo, :install_puppetlabs_release_repo_on
744
774
 
@@ -771,6 +801,7 @@ module Beaker
771
801
  opts = options )
772
802
  variant, version, arch, codename = host['platform'].to_array
773
803
  platform_configs_dir = File.join(repo_configs_dir, variant)
804
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
774
805
 
775
806
  # some of the uses of dev_builds_url below can't include protocol info,
776
807
  # plus this opens up possibility of switching the behavior on provided
@@ -909,9 +940,11 @@ module Beaker
909
940
  configure_foss_defaults_on( host )
910
941
  end
911
942
 
912
- # Install development repo of the puppet-agent on the given host
943
+ # Install development repo of the puppet-agent on the given host(s). Downloaded from
944
+ # location of the form DOWNLOAD_URL/puppet-agent/AGENT_VERSION
913
945
  #
914
- # @param [Host] host An object implementing {Beaker::Hosts}'s interface
946
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
947
+ # or a role (String or Symbol) that identifies one or more hosts.
915
948
  # @param [Hash{Symbol=>String}] opts An options hash
916
949
  # @option opts [String] :version The version of puppet-agent to install
917
950
  # @option opts [String] :copy_base_local Directory where puppet-agent artifact
@@ -920,57 +953,134 @@ module Beaker
920
953
  # @option opts [String] :copy_dir_external Directory where puppet-agent
921
954
  # artifact will be pushed to on the external machine
922
955
  # (default: '/root')
956
+ # @option opts [String] :puppet_collection Defaults to 'PC1'
957
+ # @option opts [String] :download_url Base url to look for build at
923
958
  #
924
959
  # @note on windows, the +:ruby_arch+ host parameter can determine in addition
925
960
  # to other settings whether the 32 or 64bit install is used
926
961
  #
927
962
  # @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]
963
+ def install_puppet_agent_repo_on( hosts, opts )
935
964
 
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..."
965
+ block_on hosts do |host|
966
+ opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
967
+ opts[:copy_dir_external] ||= File.join('/', 'root')
968
+ opts[:puppet_collection] ||= 'PC1'
969
+ release_path = opts[:download_url]
970
+ variant, version, arch, codename = host['platform'].to_array
971
+ copy_dir_local = File.join(opts[:copy_base_local], variant)
972
+ onhost_copy_base = opts[:copy_dir_external]
973
+
974
+ case variant
975
+ when /^(fedora|el|centos|sles)$/
976
+ variant = ((variant == 'centos') ? 'el' : variant)
977
+ release_path << "#{variant}/#{version}/#{opts[:puppet_collection]}/#{arch}"
978
+ release_file = "puppet-agent-#{opts[:version]}-1.#{variant}#{version}.#{arch}.rpm"
979
+ when /^(debian|ubuntu|cumulus)$/
980
+ release_path << "deb/#{codename}/#{opts[:puppet_collection]}"
981
+ release_file = "puppet-agent_#{opts[:version]}-1#{codename}_#{arch}.deb"
982
+ when /^windows$/
983
+ release_path << 'windows'
984
+ onhost_copy_base = '`cygpath -smF 35`/'
985
+ is_config_32 = host['ruby_arch'] == 'x86' || host['install_32'] || opts['install_32']
986
+ should_install_64bit = host.is_x86_64? && !is_config_32
987
+ # only install 64bit builds if
988
+ # - we do not have install_32 set on host
989
+ # - we do not have install_32 set globally
990
+ arch_suffix = should_install_64bit ? '64' : '86'
991
+ release_file = "puppet-agent-x#{arch_suffix}.msi"
992
+ else
993
+ raise "No repository installation step for #{variant} yet..."
994
+ end
995
+
996
+ onhost_copied_file = File.join(onhost_copy_base, release_file)
997
+ fetch_http_file( release_path, release_file, copy_dir_local)
998
+ scp_to host, File.join(copy_dir_local, release_file), onhost_copy_base
999
+
1000
+ case variant
1001
+ when /^(fedora|el|centos|sles)$/
1002
+ on host, "rpm -ivh #{onhost_copied_file}"
1003
+ when /^(debian|ubuntu|cumulus)$/
1004
+ on host, "dpkg -i --force-all #{onhost_copied_file}"
1005
+ on host, "apt-get update"
1006
+ when /^windows$/
1007
+ result = on host, "echo #{onhost_copied_file}"
1008
+ onhost_copied_file = result.raw_output.chomp
1009
+ on host, Command.new("start /w #{onhost_copied_file}", [], { :cmdexe => true })
1010
+ end
1011
+ add_aio_defaults_on( host )
955
1012
  end
1013
+ end
956
1014
 
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
1015
+ # Install shared repo of the puppet-agent on the given host(s). Downloaded from
1016
+ # location of the form PE_PROMOTED_BUILDS_URL/PE_VER/puppet-agent/AGENT_VERSION/repo
1017
+ #
1018
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
1019
+ # or a role (String or Symbol) that identifies one or more hosts.
1020
+ # @param [Hash{Symbol=>String}] opts An options hash
1021
+ # @option opts [String] :version The version of puppet-agent to install
1022
+ # @option opts [String] :sha The sha of puppet-agent to install
1023
+ # @option opts [String] :pe_ver The version of PE (will also use host['pe_ver']), defaults to '4.0'
1024
+ # @option opts [String] :copy_base_local Directory where puppet-agent artifact
1025
+ # will be stored locally
1026
+ # (default: 'tmp/repo_configs')
1027
+ # @option opts [String] :copy_dir_external Directory where puppet-agent
1028
+ # artifact will be pushed to on the external machine
1029
+ # (default: '/root')
1030
+ # @option opts [String] :puppet_collection Defaults to 'PC1'
1031
+ # @option opts [String] :pe_promoted_builds_url Base URL to pull artifacts from
1032
+ #
1033
+ # @note on windows, the +:ruby_arch+ host parameter can determine in addition
1034
+ # to other settings whether the 32 or 64bit install is used
1035
+ #
1036
+ # @example
1037
+ # install_puppet_agent_pe_promoted_repo_on(host, { :sha => '1.1.0.227', :version => '1.1.0.227.g1d8334c', :pe_ver => '4.0.0-rc1'})
1038
+ #
1039
+ # @return nil
1040
+ def install_puppet_agent_pe_promoted_repo_on( hosts, opts )
1041
+ block_on hosts do |host|
1042
+ pe_ver = host[:pe_ver] || opts[:pe_ver] || '4.0'
1043
+ variant, version, arch, codename = host['platform'].to_array
1044
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
1045
+ opts[:download_url] = "#{opts[:pe_promoted_builds_url]}/puppet-agent/#{pe_ver}/#{opts[:sha]}/repos/"
1046
+ install_puppet_agent_repo_on( host, opts )
1047
+ end
1048
+ end
960
1049
 
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 })
1050
+
1051
+ # Install development repo of the puppet-agent on the given host(s). Downloaded from
1052
+ # location of the form DEV_BUILDS_URL/puppet-agent/AGENT_VERSION/repos
1053
+ #
1054
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
1055
+ # or a role (String or Symbol) that identifies one or more hosts.
1056
+ # @param [Hash{Symbol=>String}] opts An options hash
1057
+ # @option opts [String] :version The version of puppet-agent to install
1058
+ # @option opts [String] :sha The sha of puppet-agent to install
1059
+ # @option opts [String] :copy_base_local Directory where puppet-agent artifact
1060
+ # will be stored locally
1061
+ # (default: 'tmp/repo_configs')
1062
+ # @option opts [String] :copy_dir_external Directory where puppet-agent
1063
+ # artifact will be pushed to on the external machine
1064
+ # (default: '/root')
1065
+ # @option opts [String] :puppet_collection Defaults to 'PC1'
1066
+ # @option opts [String] :dev_builds_url Base URL to pull artifacts from
1067
+ #
1068
+ # @note on windows, the +:ruby_arch+ host parameter can determine in addition
1069
+ # to other settings whether the 32 or 64bit install is used
1070
+ #
1071
+ # @example
1072
+ # install_puppet_agent_dev_repo_on(host, { :sha => 'd3377feaeac173aada3a2c2cedd141eb610960a7', :version => '1.1.1.225.gd3377fe' })
1073
+ #
1074
+ # @return nil
1075
+ def install_puppet_agent_dev_repo_on( hosts, opts )
1076
+ block_on hosts do |host|
1077
+ variant, version, arch, codename = host['platform'].to_array
1078
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
1079
+ opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{opts[:sha]}/repos/"
1080
+ install_puppet_agent_repo_on( host, opts )
971
1081
  end
972
- configure_foss_defaults_on( host )
973
1082
  end
1083
+ alias_method :install_puppetagent_dev_repo, :install_puppet_agent_dev_repo_on
974
1084
 
975
1085
  # This method will install a pem file certifcate on a windows host
976
1086
  #