beaker 2.18.3 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +439 -2
  3. data/acceptance/lib/beaker/acceptance/install_utils.rb +58 -0
  4. data/acceptance/pre_suite/puppet_git/install.rb +6 -65
  5. data/acceptance/tests/foss_utils/clone_git_repo_on.rb +49 -0
  6. data/beaker.gemspec +2 -0
  7. data/lib/beaker/dsl/helpers/web_helpers.rb +2 -1
  8. data/lib/beaker/dsl/install_utils/aio_defaults.rb +0 -2
  9. data/lib/beaker/dsl/install_utils/foss_utils.rb +97 -60
  10. data/lib/beaker/dsl/install_utils/pe_utils.rb +30 -53
  11. data/lib/beaker/dsl/install_utils/puppet_utils.rb +43 -0
  12. data/lib/beaker/dsl/install_utils/windows_utils.rb +144 -0
  13. data/lib/beaker/dsl/roles.rb +20 -3
  14. data/lib/beaker/dsl/structure.rb +14 -3
  15. data/lib/beaker/host.rb +24 -3
  16. data/lib/beaker/host/unix/pkg.rb +9 -0
  17. data/lib/beaker/host/windows/exec.rb +3 -0
  18. data/lib/beaker/host_prebuilt_steps.rb +5 -9
  19. data/lib/beaker/hypervisor/aws_sdk.rb +22 -18
  20. data/lib/beaker/hypervisor/docker.rb +7 -0
  21. data/lib/beaker/hypervisor/vmpooler.rb +4 -0
  22. data/lib/beaker/logger.rb +12 -1
  23. data/lib/beaker/options/command_line_parser.rb +9 -0
  24. data/lib/beaker/options/options_hash.rb +3 -296
  25. data/lib/beaker/options/parser.rb +12 -0
  26. data/lib/beaker/options/presets.rb +0 -1
  27. data/lib/beaker/ssh_connection.rb +48 -23
  28. data/lib/beaker/test_case.rb +1 -1
  29. data/lib/beaker/version.rb +1 -1
  30. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +10 -1
  31. data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +194 -49
  32. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +112 -22
  33. data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +57 -0
  34. data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +132 -0
  35. data/spec/beaker/dsl/roles_spec.rb +36 -5
  36. data/spec/beaker/dsl/structure_spec.rb +9 -2
  37. data/spec/beaker/host/unix/pkg_spec.rb +26 -6
  38. data/spec/beaker/host_prebuilt_steps_spec.rb +3 -2
  39. data/spec/beaker/host_spec.rb +18 -0
  40. data/spec/beaker/hypervisor/aixer_spec.rb +1 -1
  41. data/spec/beaker/hypervisor/aws_sdk_spec.rb +595 -58
  42. data/spec/beaker/hypervisor/docker_spec.rb +2 -1
  43. data/spec/beaker/hypervisor/solaris_spec.rb +1 -0
  44. data/spec/beaker/hypervisor/vagrant_spec.rb +2 -1
  45. data/spec/beaker/logger_spec.rb +39 -0
  46. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  47. data/spec/beaker/options/options_hash_spec.rb +1 -102
  48. data/spec/beaker/options/parser_spec.rb +19 -0
  49. data/spec/beaker/options/pe_version_scaper_spec.rb +11 -1
  50. data/spec/beaker/options/presets_spec.rb +8 -0
  51. data/spec/beaker/ssh_connection_spec.rb +39 -21
  52. data/spec/helpers.rb +9 -3
  53. data/spec/mocks.rb +2 -0
  54. metadata +34 -11
  55. data/lib/beaker/answers.rb +0 -143
  56. data/lib/beaker/answers/version20.rb +0 -120
  57. data/lib/beaker/answers/version28.rb +0 -121
  58. data/lib/beaker/answers/version30.rb +0 -227
  59. data/lib/beaker/answers/version32.rb +0 -44
  60. data/lib/beaker/answers/version34.rb +0 -51
  61. data/lib/beaker/answers/version38.rb +0 -29
  62. data/lib/beaker/answers/version40.rb +0 -44
  63. data/spec/beaker/answers_spec.rb +0 -547
@@ -0,0 +1,58 @@
1
+ module Beaker
2
+ module Acceptance
3
+ module InstallUtils
4
+
5
+ PLATFORM_PATTERNS = {
6
+ :redhat => /fedora|el|centos/,
7
+ :debian => /debian|ubuntu/,
8
+ :debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/,
9
+ :solaris_10 => /solaris-10/,
10
+ :solaris_11 => /solaris-11/,
11
+ :windows => /windows/,
12
+ :sles => /sles/,
13
+ }.freeze
14
+
15
+ # Installs packages on the hosts.
16
+ #
17
+ # @param hosts [Array<Host>] Array of hosts to install packages to.
18
+ # @param package_hash [Hash{Symbol=>Array<String,Array<String,String>>}]
19
+ # Keys should be a symbol for a platform in PLATFORM_PATTERNS. Values
20
+ # should be an array of package names to install, or of two element
21
+ # arrays where a[0] is the command we expect to find on the platform
22
+ # and a[1] is the package name (when they are different).
23
+ # @param options [Hash{Symbol=>Boolean}]
24
+ # @option options [Boolean] :check_if_exists First check to see if
25
+ # command is present before installing package. (Default false)
26
+ # @return true
27
+ def install_packages_on(hosts, package_hash, options = {})
28
+ return true if hosts == nil
29
+ check_if_exists = options[:check_if_exists]
30
+ hosts = [hosts] unless hosts.kind_of?(Array)
31
+ hosts.each do |host|
32
+ package_hash.each do |platform_key,package_list|
33
+ if pattern = PLATFORM_PATTERNS[platform_key]
34
+ if pattern.match(host['platform'])
35
+ package_list.each do |cmd_pkg|
36
+ if cmd_pkg.kind_of?(Array)
37
+ command, package = cmd_pkg
38
+ else
39
+ command = package = cmd_pkg
40
+ end
41
+ if !check_if_exists || !host.check_for_package(command)
42
+ host.logger.notify("Installing #{package}")
43
+ additional_switches = '--allow-unauthenticated' if platform_key == :debian
44
+ host.install_package(package, additional_switches)
45
+ end
46
+ end
47
+ end
48
+ else
49
+ raise("Unknown platform '#{platform_key}' in package_hash")
50
+ end
51
+ end
52
+ end
53
+ return true
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,9 @@
1
+ begin
2
+ require 'beaker/acceptance/install_utils'
3
+ extend Beaker::Acceptance::InstallUtils
4
+ end
5
+ test_name 'Puppet git pre-suite'
6
+
1
7
  install = [
2
8
  'facter#2.1.0',
3
9
  'hiera#1.3.4',
@@ -40,73 +46,8 @@ PACKAGES = {
40
46
  ]
41
47
  }
42
48
 
43
- PLATFORM_PATTERNS = {
44
- :redhat => /fedora|el|centos/,
45
- :debian => /debian|ubuntu/,
46
- :debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/,
47
- :solaris_10 => /solaris-10/,
48
- :solaris_11 => /solaris-11/,
49
- :windows => /windows/,
50
- :sles => /sles/,
51
- }.freeze
52
-
53
- # Installs packages on the hosts.
54
- #
55
- # @param hosts [Array<Host>] Array of hosts to install packages to.
56
- # @param package_hash [Hash{Symbol=>Array<String,Array<String,String>>}]
57
- # Keys should be a symbol for a platform in PLATFORM_PATTERNS. Values
58
- # should be an array of package names to install, or of two element
59
- # arrays where a[0] is the command we expect to find on the platform
60
- # and a[1] is the package name (when they are different).
61
- # @param options [Hash{Symbol=>Boolean}]
62
- # @option options [Boolean] :check_if_exists First check to see if
63
- # command is present before installing package. (Default false)
64
- # @return true
65
- def install_packages_on(hosts, package_hash, options = {})
66
- return true if hosts == nil
67
- check_if_exists = options[:check_if_exists]
68
- hosts = [hosts] unless hosts.kind_of?(Array)
69
- hosts.each do |host|
70
- package_hash.each do |platform_key,package_list|
71
- if pattern = PLATFORM_PATTERNS[platform_key]
72
- if pattern.match(host['platform'])
73
- package_list.each do |cmd_pkg|
74
- if cmd_pkg.kind_of?(Array)
75
- command, package = cmd_pkg
76
- else
77
- command = package = cmd_pkg
78
- end
79
- if !check_if_exists || !host.check_for_package(command)
80
- host.logger.notify("Installing #{package}")
81
- additional_switches = '--allow-unauthenticated' if platform_key == :debian
82
- host.install_package(package, additional_switches)
83
- end
84
- end
85
- end
86
- else
87
- raise("Unknown platform '#{platform_key}' in package_hash")
88
- end
89
- end
90
- end
91
- return true
92
- end
93
-
94
49
  install_packages_on(hosts, PACKAGES, :check_if_exists => true)
95
50
 
96
- def lookup_in_env(env_variable_name, project_name, default)
97
- project_specific_name = "#{project_name.upcase.gsub("-","_")}_#{env_variable_name}"
98
- ENV[project_specific_name] || ENV[env_variable_name] || default
99
- end
100
-
101
- def build_giturl(project_name, git_fork = nil, git_server = nil)
102
- git_fork ||= lookup_in_env('FORK', project_name, 'puppetlabs')
103
- git_server ||= lookup_in_env('GIT_SERVER', project_name, 'github.com')
104
- repo = (git_server == 'github.com') ?
105
- "#{git_fork}/#{project_name}.git" :
106
- "#{git_fork}-#{project_name}.git"
107
- "git://#{git_server}/#{repo}"
108
- end
109
-
110
51
  hosts.each do |host|
111
52
  case host['platform']
112
53
  when /windows/
@@ -0,0 +1,49 @@
1
+ begin
2
+ require 'beaker/acceptance/install_utils'
3
+ extend Beaker::Acceptance::InstallUtils
4
+ end
5
+ test_name 'Clone from git'
6
+
7
+ PACKAGES = {
8
+ :redhat => [
9
+ 'git',
10
+ ],
11
+ :debian => [
12
+ ['git', 'git-core'],
13
+ ],
14
+ :solaris_11 => [
15
+ ['git', 'developer/versioning/git'],
16
+ ],
17
+ :solaris_10 => [
18
+ 'coreutils',
19
+ 'curl', # update curl to fix "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!" issue
20
+ 'git',
21
+ ],
22
+ :windows => [
23
+ 'git',
24
+ ],
25
+ :sles => [
26
+ 'git-core',
27
+ ]
28
+ }
29
+
30
+ install_packages_on(hosts, PACKAGES, :check_if_exists => true)
31
+
32
+ # build_giturl implicitly looks these up
33
+ ENV['HIERA_FORK']='puppetlabs'
34
+ ENV['FORK']='fail'
35
+
36
+ # implicitly tests build_giturl() and lookup_in_env()
37
+ hosts.each do |host|
38
+ on host, "echo #{GitHubSig} >> $HOME/.ssh/known_hosts"
39
+ testdir = create_tmpdir_on(host, File.basename(__FILE__))
40
+
41
+ step 'should find fork name from the correct environment variable'
42
+ results = clone_git_repo_on(host, "#{testdir}", extract_repo_info_from(build_git_url('puppet')))
43
+ assert_match( /github\.com:fail/, result.cmd, 'Did not find correct fork name')
44
+ assert_equal( 1, result.exit_code, 'Did not produce error exit_code of 1')
45
+
46
+ step 'should clone hiera from correct fork'
47
+ results = clone_git_repo_on(host, "#{testdir}", extract_repo_info_from(build_git_url('hiera')))
48
+ assert_match( /From github\.com:puppetlabs\/hiera/, result.output, 'Did not find clone')
49
+ end
@@ -39,6 +39,8 @@ Gem::Specification.new do |s|
39
39
  s.add_runtime_dependency 'inifile', '~> 2.0'
40
40
  s.add_runtime_dependency 'rsync', '~> 1.0.9'
41
41
  s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
42
+ s.add_runtime_dependency 'beaker-answers', '~> 0.0'
43
+ s.add_runtime_dependency 'stringify-hash', '~> 0.0'
42
44
 
43
45
  # Optional provisioner specific support
44
46
  s.add_runtime_dependency 'rbvmomi', '~> 1.8'
@@ -33,7 +33,7 @@ module Beaker
33
33
  #
34
34
  # @param [String] base_url The base url from which to recursively download
35
35
  # files.
36
- # @param [String] file_name The trailing name compnent of both the source url
36
+ # @param [String] file_name The trailing name component of both the source url
37
37
  # and the destination file.
38
38
  # @param [String] dst_dir The local destination directory.
39
39
  #
@@ -44,6 +44,7 @@ module Beaker
44
44
  require 'open-uri'
45
45
  require 'open_uri_redirections'
46
46
  FileUtils.makedirs(dst_dir)
47
+ base_url.chomp!('/')
47
48
  src = "#{base_url}/#{file_name}"
48
49
  dst = File.join(dst_dir, file_name)
49
50
  if File.exists?(dst)
@@ -36,7 +36,6 @@ module Beaker
36
36
  else
37
37
  host['group'] = 'puppet'
38
38
  end
39
- host['type'] = 'aio'
40
39
  end
41
40
 
42
41
  # Add the appropriate aio defaults to an array of hosts
@@ -60,7 +59,6 @@ module Beaker
60
59
  AIO_DEFAULTS[platform].each_pair do |key, val|
61
60
  host.delete(key)
62
61
  end
63
- host['type'] = nil
64
62
  host['group'] = nil
65
63
  end
66
64
 
@@ -1,4 +1,4 @@
1
- [ 'aio_defaults', 'foss_defaults', 'puppet_utils' ].each do |lib|
1
+ [ 'aio_defaults', 'foss_defaults', 'puppet_utils', 'windows_utils' ].each do |lib|
2
2
  require "beaker/dsl/install_utils/#{lib}"
3
3
  end
4
4
  module Beaker
@@ -18,6 +18,7 @@ module Beaker
18
18
  include AIODefaults
19
19
  include FOSSDefaults
20
20
  include PuppetUtils
21
+ include WindowsUtils
21
22
 
22
23
  # The default install path
23
24
  SourcePath = "/opt/puppet-git-repos"
@@ -28,26 +29,39 @@ module Beaker
28
29
  # Github's ssh signature for cloning via ssh
29
30
  GitHubSig = 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
30
31
 
31
- # Set defaults and PATH for these hosts to be either foss or aio, have host['type'] == aio for aio settings, defaults
32
- # to foss.
32
+ # lookup project-specific git environment variables
33
+ # PROJECT_VAR or VAR otherwise return the default
33
34
  #
34
- # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
35
- # or a role (String or Symbol) that identifies one or more hosts.
36
- def configure_foss_defaults_on( hosts )
37
- block_on hosts do |host|
38
- if (not_controller(host) && host[:version] && (not version_is_less(host[:version], '4.0'))) \
39
- or (host['type'] && host['type'] =~ /aio/)
40
- # add aio defaults to host
41
- add_aio_defaults_on(host)
42
- # provide a sane default here for puppetservice
43
- host['puppetservice'] ||= 'puppetserver'
44
- else
45
- add_foss_defaults_on(host)
46
- end
47
- # add pathing env
48
- add_puppet_paths_on(host)
35
+ # @!visibility private
36
+ def lookup_in_env(env_variable_name, project_name=nil, default=nil)
37
+ env_variable_name = "#{env_variable_name.upcase.gsub('-','_')}"
38
+ project_specific_name = "#{project_name.upcase.gsub('-','_')}_#{env_variable_name}" if project_name
39
+ project_name && ENV[project_specific_name] || ENV[env_variable_name] || default
40
+ end
41
+
42
+ # @param [String] project_name
43
+ # @param [String] git_fork When not provided will use PROJECT_FORK environment variable
44
+ # @param [String] git_server When not provided will use PROJECT_SERVER environment variable
45
+ # @param [String] git_protocol 'git','ssh','https'
46
+ #
47
+ # @return [String] Returns a git-usable url
48
+ #
49
+ # TODO: enable other protocols, clarify, http://git-scm.com/book/ch4-1.html
50
+ def build_git_url(project_name, git_fork = nil, git_server = nil, git_protocol='https')
51
+ git_fork ||= lookup_in_env('FORK', project_name, 'puppetlabs')
52
+ git_server ||= lookup_in_env('SERVER', project_name, 'github.com')
53
+
54
+ case git_protocol
55
+ when /(ssh|git)/
56
+ git_protocol = 'git@'
57
+ when /https/
58
+ git_protocol = 'https://'
49
59
  end
60
+
61
+ repo = (git_server == 'github.com') ? "#{git_fork}/#{project_name}.git" : "#{git_fork}-#{project_name}.git"
62
+ return git_protocol == 'git@' ? "#{git_protocol}#{git_server}:#{repo}" : "#{git_protocol}#{git_server}/#{repo}"
50
63
  end
64
+ alias_method :build_giturl, :build_git_url
51
65
 
52
66
  # @param [String] uri A uri in the format of <git uri>#<revision>
53
67
  # the `git://`, `http://`, `https://`, and ssh
@@ -121,9 +135,18 @@ module Beaker
121
135
  version
122
136
  end
123
137
 
138
+ # @param [Host] host An object implementing {Beaker::Hosts}'s
139
+ # interface.
140
+ # @param [String] path The path on the remote [host] to the repository
141
+ # @param [Hash{Symbol=>String}] repository A hash representing repo
142
+ # info like that emitted by
143
+ # {#extract_repo_info_from}
124
144
  #
125
- # @see #find_git_repo_versions
126
- def install_from_git host, path, repository
145
+ # @note This requires the helper methods:
146
+ # * {Beaker::DSL::Helpers#on}
147
+ #
148
+ def clone_git_repo_on host, path, repository, opts = {}
149
+ opts = {:accept_all_exit_codes => true}.merge(opts)
127
150
  name = repository[:name]
128
151
  repo = repository[:path]
129
152
  rev = repository[:rev]
@@ -142,33 +165,41 @@ module Beaker
142
165
 
143
166
  logger.notify("\n * Clone #{repo} if needed")
144
167
 
145
- on host, "test -d #{path} || mkdir -p #{path}"
146
- on host, "test -d #{target} || #{clone_cmd}"
168
+ on host, "test -d #{path} || mkdir -p #{path}", opts
169
+ on host, "test -d #{target} || #{clone_cmd}", opts
147
170
 
148
171
  logger.notify("\n * Update #{name} and check out revision #{rev}")
149
-
150
172
  commands = ["cd #{target}",
151
173
  "remote rm origin",
152
174
  "remote add origin #{repo}",
153
175
  "fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*",
154
176
  "clean -fdx",
155
177
  "checkout -f #{rev}"]
156
- on host, commands.join(" && git ")
178
+ on host, commands.join(" && git "), opts
179
+ end
157
180
 
181
+ # @see #find_git_repo_versions
182
+ # @note This assumes the target repository application
183
+ # can be installed via an install.rb ruby script.
184
+ def install_from_git_on host, path, repository, opts = {}
185
+ opts = {:accept_all_exit_codes => true}.merge(opts)
186
+ clone_git_repo_on host, path, repository, opts
187
+ name = repository[:name]
158
188
  logger.notify("\n * Install #{name} on the system")
159
189
  # The solaris ruby IPS package has bindir set to /usr/ruby/1.8/bin.
160
190
  # However, this is not the path to which we want to deliver our
161
191
  # binaries. So if we are using solaris, we have to pass the bin and
162
192
  # sbin directories to the install.rb
193
+ target = "#{path}/#{name}"
163
194
  install_opts = ''
164
- install_opts = '--bindir=/usr/bin --sbindir=/usr/sbin' if
165
- host['platform'].include? 'solaris'
195
+ install_opts = '--bindir=/usr/bin --sbindir=/usr/sbin' if host['platform'].include? 'solaris'
166
196
 
167
- on host, "cd #{target} && " +
168
- "if [ -f install.rb ]; then " +
169
- "ruby ./install.rb #{install_opts}; " +
170
- "else true; fi"
197
+ on host, "cd #{target} && " +
198
+ "if [ -f install.rb ]; then " +
199
+ "ruby ./install.rb #{install_opts}; " +
200
+ "else true; fi", opts
171
201
  end
202
+ alias_method :install_from_git, :install_from_git_on
172
203
 
173
204
  # @deprecated Use {#install_puppet_on} instead.
174
205
  def install_puppet(opts = {})
@@ -299,7 +330,7 @@ module Beaker
299
330
  opts[:puppet_agent_version] ||= opts[:version] #backwards compatability with old parameter name
300
331
 
301
332
  block_on hosts do |host|
302
- host[:type] = 'aio' #we are installing agent, so we want aio type
333
+ add_role(host, 'aio') #we are installing agent, so we want aio role
303
334
  case host['platform']
304
335
  when /el-4|sles/
305
336
  # pe-only agent, get from dev repo
@@ -421,7 +452,7 @@ module Beaker
421
452
 
422
453
  puppet_pkg = opts[:version] ? "puppet-#{opts[:version]}" : 'puppet'
423
454
  host.install_package("#{puppet_pkg}")
424
- configure_foss_defaults_on( host )
455
+ configure_type_defaults_on( host )
425
456
  end
426
457
  end
427
458
  alias_method :install_puppet_from_rpm, :install_puppet_from_rpm_on
@@ -455,7 +486,7 @@ module Beaker
455
486
  else
456
487
  host.install_package('puppet')
457
488
  end
458
- configure_foss_defaults_on( host )
489
+ configure_type_defaults_on( host )
459
490
  end
460
491
  end
461
492
  alias_method :install_puppet_from_deb, :install_puppet_from_deb_on
@@ -491,7 +522,7 @@ module Beaker
491
522
  install_a_puppet_msi_on(host, opts)
492
523
 
493
524
  end
494
- configure_foss_defaults_on( host )
525
+ configure_type_defaults_on( host )
495
526
  end
496
527
  end
497
528
  alias_method :install_puppet_from_msi, :install_puppet_from_msi_on
@@ -540,7 +571,7 @@ module Beaker
540
571
  def install_puppet_agent_from_msi_on(hosts, opts)
541
572
  block_on hosts do |host|
542
573
 
543
- host[:type] = 'aio' #we are installing agent, so we want aio type
574
+ add_role(host, 'aio') #we are installing agent, so we want aio role
544
575
  is_config_32 = true == (host['ruby_arch'] == 'x86') || host['install_32'] || opts['install_32']
545
576
  should_install_64bit = host.is_x86_64? && !is_config_32
546
577
  arch = should_install_64bit ? 'x64' : 'x86'
@@ -564,26 +595,26 @@ module Beaker
564
595
  raise "Puppet #{version} at #{link} does not exist!"
565
596
  end
566
597
 
598
+
599
+ msi_download_path = "#{get_temp_path(host)}\\#{host['dist']}.msi"
600
+
567
601
  if host.is_cygwin?
568
- dest = "#{host['dist']}.msi"
569
- on host, "curl -O #{link}"
602
+ # NOTE: it is critical that -o be before -O on Windows
603
+ on host, "curl -o \"#{msi_download_path}\" -O #{link}"
570
604
 
571
605
  #Because the msi installer doesn't add Puppet to the environment path
572
606
  #Add both potential paths for simplicity
573
607
  #NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up
574
608
  puppetbin_path = "\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\""
575
609
  on host, %Q{ echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc }
576
-
577
- on host, "cmd /C 'start /w msiexec.exe /qn /i #{dest}'"
578
610
  else
579
- dest = "C:\\Windows\\Temp\\#{host['dist']}.msi"
580
-
581
- on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{dest}')")
582
-
583
- on host, "start /w msiexec.exe /qn /i #{dest}"
611
+ on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{msi_download_path}')")
584
612
  end
585
613
 
586
- configure_foss_defaults_on( host )
614
+ opts = { :debug => host[:pe_debug] || opts[:pe_debug] }
615
+ install_msi_on(host, msi_download_path, {}, opts)
616
+
617
+ configure_type_defaults_on( host )
587
618
  if not host.is_cygwin?
588
619
  host.mkdir_p host['distmoduledir']
589
620
  end
@@ -657,7 +688,7 @@ module Beaker
657
688
  host.install_package("facter-#{facter_ver}")
658
689
  host.install_package("hiera-#{hiera_ver}")
659
690
 
660
- configure_foss_defaults_on( host )
691
+ configure_type_defaults_on( host )
661
692
  end
662
693
  end
663
694
  end
@@ -679,7 +710,7 @@ module Beaker
679
710
  opts[:puppet_collection] = opts[:puppet_collection].upcase #needs to be upcase, more lovely consistency
680
711
  block_on hosts do |host|
681
712
 
682
- host[:type] = 'aio' #we are installing agent, so we want aio type
713
+ add_role(host, 'aio') #we are installing agent, so we want aio role
683
714
 
684
715
  variant, version, arch, codename = host['platform'].to_array
685
716
  agent_version = opts[:puppet_agent_version] || 'latest'
@@ -694,7 +725,7 @@ module Beaker
694
725
 
695
726
  host.install_package(pkg_name)
696
727
 
697
- configure_foss_defaults_on( host )
728
+ configure_type_defaults_on( host )
698
729
  end
699
730
  end
700
731
 
@@ -714,7 +745,7 @@ module Beaker
714
745
  block_on hosts do |host|
715
746
  host.install_package('puppet')
716
747
 
717
- configure_foss_defaults_on(host)
748
+ configure_type_defaults_on(host)
718
749
  end
719
750
  end
720
751
 
@@ -808,7 +839,7 @@ module Beaker
808
839
  host.mkdir_p host.puppet[key] if host.puppet.has_key?(key)
809
840
  end
810
841
 
811
- configure_foss_defaults_on( host )
842
+ configure_type_defaults_on( host )
812
843
  end
813
844
  end
814
845
  alias_method :install_puppet_from_gem, :install_puppet_from_gem_on
@@ -847,7 +878,7 @@ module Beaker
847
878
  else
848
879
  raise "No repository installation step for #{variant} yet..."
849
880
  end
850
- configure_foss_defaults_on( host )
881
+ configure_type_defaults_on( host )
851
882
  end
852
883
  end
853
884
  alias_method :install_puppetlabs_release_repo, :install_puppetlabs_release_repo_on
@@ -988,7 +1019,7 @@ module Beaker
988
1019
 
989
1020
  on host, find_and_sed
990
1021
  on host, "apt-get update"
991
- configure_foss_defaults_on( host )
1022
+ configure_type_defaults_on( host )
992
1023
 
993
1024
  else
994
1025
  raise "No repository installation step for #{variant} yet..."
@@ -1017,7 +1048,7 @@ module Beaker
1017
1048
  end
1018
1049
  find_command = "find /root/#{package_name} -type f -name '#{find_filename}' -exec #{find_command} {} \\;"
1019
1050
  on host, find_command
1020
- configure_foss_defaults_on( host )
1051
+ configure_type_defaults_on( host )
1021
1052
  end
1022
1053
 
1023
1054
  # Install development repo of the puppet-agent on the given host(s). Downloaded from
@@ -1064,7 +1095,7 @@ module Beaker
1064
1095
  opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
1065
1096
  opts[:copy_dir_external] ||= File.join('/', 'root')
1066
1097
  opts[:puppet_collection] ||= 'PC1'
1067
- host[:type] = 'aio' #we are installing agent, so we want aio type
1098
+ add_role(host, 'aio') #we are installing agent, so we want aio role
1068
1099
  release_path = opts[:download_url]
1069
1100
  variant, version, arch, codename = host['platform'].to_array
1070
1101
  copy_dir_local = File.join(opts[:copy_base_local], variant)
@@ -1113,11 +1144,12 @@ module Beaker
1113
1144
  when /^windows$/
1114
1145
  result = on host, "echo #{onhost_copied_file}"
1115
1146
  onhost_copied_file = result.raw_output.chomp
1116
- on host, Command.new("start /w #{onhost_copied_file}", [], { :cmdexe => true })
1147
+ opts = { :debug => host[:pe_debug] || opts[:pe_debug] }
1148
+ install_msi_on(host, onhost_copied_file, {}, opts)
1117
1149
  when /^osx$/
1118
1150
  host.install_package("#{mac_pkg_name}*")
1119
1151
  end
1120
- configure_foss_defaults_on( host )
1152
+ configure_type_defaults_on( host )
1121
1153
  end
1122
1154
  end
1123
1155
  alias_method :install_puppetagent_dev_repo, :install_puppet_agent_dev_repo_on
@@ -1156,7 +1188,7 @@ module Beaker
1156
1188
  opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
1157
1189
  opts[:copy_dir_external] ||= File.join('/', 'root')
1158
1190
  opts[:puppet_collection] ||= 'PC1'
1159
- host[:type] = 'aio' #we are installing agent, so we want aio type
1191
+ add_role(host, 'aio') #we are installing agent, so we want aio role
1160
1192
  release_path = opts[:download_url]
1161
1193
  variant, version, arch, codename = host['platform'].to_array
1162
1194
  copy_dir_local = File.join(opts[:copy_base_local], variant)
@@ -1171,6 +1203,7 @@ module Beaker
1171
1203
  if arch == 'x86_64'
1172
1204
  arch = 'amd64'
1173
1205
  end
1206
+ version = version[0,2] + '.' + version[2,2] if variant =~ /ubuntu/ && version =~ /\.{0}/
1174
1207
  release_file = "/repos/apt/#{codename}/pool/#{opts[:puppet_collection]}/p/puppet-agent/puppet-agent*#{arch}.deb"
1175
1208
  download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
1176
1209
  when /^windows$/
@@ -1198,6 +1231,9 @@ module Beaker
1198
1231
  scp_to host, File.join(copy_dir_local, download_file), onhost_copy_base
1199
1232
 
1200
1233
  case variant
1234
+ when /^(fedora-22)$/
1235
+ on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}"
1236
+ on host, "dnf --nogpgcheck localinstall -y #{onhost_copied_file}"
1201
1237
  when /^(fedora|el|centos)$/
1202
1238
  on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}"
1203
1239
  on host, "yum --nogpgcheck localinstall -y #{onhost_copied_file}"
@@ -1211,19 +1247,20 @@ module Beaker
1211
1247
  when /^windows$/
1212
1248
  result = on host, "echo #{onhost_copied_file}"
1213
1249
  onhost_copied_file = result.raw_output.chomp
1214
- on host, Command.new("start /w #{onhost_copied_file}", [], { :cmdexe => true })
1250
+ opts = { :debug => host[:pe_debug] || opts[:pe_debug] }
1251
+ install_msi_on(host, onhost_copied_file, {}, opts)
1215
1252
  when /^osx$/
1216
1253
  on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}"
1217
1254
  # move to better location
1218
1255
  on host, "mv #{onhost_copied_file}.dmg ."
1219
1256
  host.install_package("puppet-agent-*")
1220
1257
  end
1221
- configure_foss_defaults_on( host )
1258
+ configure_type_defaults_on( host )
1222
1259
  end
1223
1260
  end
1224
1261
 
1225
1262
 
1226
- # This method will install a pem file certifcate on a windows host
1263
+ # This method will install a pem file certificate on a windows host
1227
1264
  #
1228
1265
  # @param [Host] host A host object
1229
1266
  # @param [String] cert_name The name of the pem file