beaker-puppet 1.29.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +28 -7
  5. data/.rubocop.yml +5 -0
  6. data/.rubocop_todo.yml +842 -0
  7. data/CHANGELOG.md +31 -0
  8. data/Gemfile +5 -20
  9. data/Rakefile +64 -169
  10. data/acceptance/config/acceptance-options.rb +3 -3
  11. data/acceptance/config/gem/acceptance-options.rb +8 -8
  12. data/acceptance/config/git/acceptance-options.rb +8 -8
  13. data/acceptance/config/pkg/acceptance-options.rb +7 -7
  14. data/acceptance/pre_suite/gem/install.rb +6 -6
  15. data/acceptance/pre_suite/git/install.rb +22 -22
  16. data/acceptance/pre_suite/pkg/install.rb +3 -3
  17. data/acceptance/tests/backwards_compatible.rb +6 -7
  18. data/acceptance/tests/clone_git_repo_on_test.rb +12 -13
  19. data/acceptance/tests/create_tmpdir_on_test.rb +13 -9
  20. data/acceptance/tests/install_smoke_test.rb +5 -4
  21. data/acceptance/tests/stub_host.rb +11 -10
  22. data/acceptance/tests/web_helpers_test.rb +11 -10
  23. data/beaker-puppet.gemspec +16 -23
  24. data/bin/beaker-puppet +2 -4
  25. data/lib/beaker-puppet/helpers/facter_helpers.rb +9 -7
  26. data/lib/beaker-puppet/helpers/host_helpers.rb +10 -7
  27. data/lib/beaker-puppet/helpers/puppet_helpers.rb +151 -160
  28. data/lib/beaker-puppet/helpers/rake_helpers.rb +1 -1
  29. data/lib/beaker-puppet/helpers/tk_helpers.rb +22 -28
  30. data/lib/beaker-puppet/install_utils/aio_defaults.rb +39 -43
  31. data/lib/beaker-puppet/install_utils/ezbake_utils.rb +34 -42
  32. data/lib/beaker-puppet/install_utils/foss_defaults.rb +134 -138
  33. data/lib/beaker-puppet/install_utils/foss_utils.rb +293 -320
  34. data/lib/beaker-puppet/install_utils/module_utils.rb +58 -70
  35. data/lib/beaker-puppet/install_utils/puppet5.rb +30 -35
  36. data/lib/beaker-puppet/install_utils/puppet_utils.rb +58 -68
  37. data/lib/beaker-puppet/install_utils/windows_utils.rb +34 -36
  38. data/lib/beaker-puppet/version.rb +1 -1
  39. data/lib/beaker-puppet/wrappers.rb +13 -14
  40. data/lib/beaker-puppet.rb +4 -5
  41. data/setup/aio/010_Install_Puppet_Agent.rb +5 -6
  42. data/setup/common/000-delete-puppet-when-none.rb +2 -4
  43. data/setup/common/003_solaris_cert_fix.rb +74 -70
  44. data/setup/common/005_redhat_subscription_fix.rb +3 -2
  45. data/setup/common/011_Install_Puppet_Server.rb +7 -9
  46. data/setup/common/012_Finalize_Installs.rb +5 -5
  47. data/setup/common/025_StopFirewall.rb +1 -1
  48. data/setup/common/030_StopSssd.rb +2 -2
  49. data/setup/common/040_ValidateSignCert.rb +10 -12
  50. data/setup/common/045_EnsureMasterStarted.rb +2 -2
  51. data/setup/gem/010_GemInstall.rb +5 -4
  52. data/setup/git/000_EnvSetup.rb +48 -48
  53. data/setup/git/010_TestSetup.rb +13 -12
  54. data/setup/git/020_PuppetUserAndGroup.rb +3 -2
  55. data/setup/git/060_InstallModules.rb +14 -14
  56. data/setup/git/070_InstallCACerts.rb +82 -82
  57. data/spec/beaker-puppet/helpers/facter_helpers_spec.rb +22 -24
  58. data/spec/beaker-puppet/helpers/host_helpers_spec.rb +10 -6
  59. data/spec/beaker-puppet/helpers/puppet_helpers_spec.rb +506 -517
  60. data/spec/beaker-puppet/helpers/tk_helpers_spec.rb +20 -24
  61. data/spec/beaker-puppet/install_utils/ezbake_utils_spec.rb +86 -90
  62. data/spec/beaker-puppet/install_utils/foss_utils_spec.rb +636 -599
  63. data/spec/beaker-puppet/install_utils/module_utils_spec.rb +125 -116
  64. data/spec/beaker-puppet/install_utils/puppet5_spec.rb +159 -165
  65. data/spec/beaker-puppet/install_utils/puppet_utils_spec.rb +92 -77
  66. data/spec/beaker-puppet/install_utils/windows_utils_spec.rb +101 -89
  67. data/spec/beaker-puppet/wrappers_spec.rb +10 -10
  68. data/spec/helpers.rb +85 -91
  69. data/tasks/ci.rake +171 -179
  70. metadata +33 -62
  71. data/setup/common/020_InstallCumulusModules.rb +0 -13
  72. data/setup/common/021_InstallAristaModuleMasters.rb +0 -12
  73. data/setup/common/022_InstallAristaModuleAgents.rb +0 -13
@@ -5,21 +5,20 @@ module Beaker
5
5
  # This module contains methods useful for both foss and pe installs
6
6
  #
7
7
  module PuppetUtils
8
-
9
- #Given a type return an understood host type
10
- #@param [String] type The host type to be normalized
11
- #@return [String] The normalized type
8
+ # Given a type return an understood host type
9
+ # @param [String] type The host type to be normalized
10
+ # @return [String] The normalized type
12
11
  #
13
- #@example
12
+ # @example
14
13
  # normalize_type('pe-aio')
15
14
  # 'pe'
16
- #@example
15
+ # @example
17
16
  # normalize_type('git')
18
17
  # 'foss'
19
- #@example
18
+ # @example
20
19
  # normalize_type('foss-internal')
21
20
  # 'foss'
22
- def normalize_type type
21
+ def normalize_type(type)
23
22
  case type
24
23
  when /(\A|-)foss(\Z|-)/
25
24
  'foss'
@@ -27,44 +26,40 @@ module Beaker
27
26
  'pe'
28
27
  when /(\A|-)aio(\Z|-)/
29
28
  'aio'
30
- else
31
- nil
32
29
  end
33
30
  end
34
31
 
35
- #Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir
32
+ # Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir
36
33
  # @param [Host] host A single host to construct pathing for
37
34
  def construct_puppet_path(host)
38
- path = (%w(puppetbindir facterbindir hierabindir privatebindir)).compact.reject(&:empty?)
39
- #get the PATH defaults
35
+ path = %w[puppetbindir facterbindir hierabindir privatebindir].compact.reject(&:empty?)
36
+ # get the PATH defaults
40
37
  path.map! { |val| host[val] }
41
38
  path = path.compact.reject(&:empty?)
42
- #run the paths through echo to see if they have any subcommands that need processing
39
+ # run the paths through echo to see if they have any subcommands that need processing
43
40
  path.map! { |val| echo_on(host, val) }
44
41
 
45
42
  separator = host['pathseparator']
46
- if not host.is_powershell?
47
- separator = ':'
48
- end
43
+ separator = ':' unless host.is_powershell?
49
44
  path.join(separator)
50
45
  end
51
46
 
52
- #Append puppetbindir, facterbindir and hierabindir to the PATH for each host
47
+ # Append puppetbindir, facterbindir and hierabindir to the PATH for each host
53
48
  # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
54
49
  # or a role (String or Symbol) that identifies one or more hosts.
55
50
  def add_puppet_paths_on(hosts)
56
- block_on hosts do | host |
51
+ block_on hosts do |host|
57
52
  puppet_path = construct_puppet_path(host)
58
53
  host.add_env_var('PATH', puppet_path)
59
54
  end
60
55
  end
61
56
 
62
- #Remove puppetbindir, facterbindir and hierabindir to the PATH for each host
57
+ # Remove puppetbindir, facterbindir and hierabindir to the PATH for each host
63
58
  #
64
59
  # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
65
60
  # or a role (String or Symbol) that identifies one or more hosts.
66
61
  def remove_puppet_paths_on(hosts)
67
- block_on hosts do | host |
62
+ block_on hosts do |host|
68
63
  puppet_path = construct_puppet_path(host)
69
64
  host.delete_env_var('PATH', puppet_path)
70
65
  end
@@ -76,12 +71,12 @@ module Beaker
76
71
  # @deprecated This method returns 'PC1' as the latest puppet collection;
77
72
  # this is incorrect. Use {#puppet_collection_for} instead.
78
73
  def get_puppet_collection(agent_version = 'latest')
79
- collection = "PC1"
74
+ collection = 'PC1'
80
75
  if agent_version != 'latest'
81
- if ! version_is_less( agent_version, "5.5.4") and version_is_less(agent_version, "5.99")
82
- collection = "puppet5"
83
- elsif ! version_is_less( agent_version, "5.99")
84
- collection = "puppet6"
76
+ if !version_is_less(agent_version, '5.5.4') and version_is_less(agent_version, '5.99')
77
+ collection = 'puppet5'
78
+ elsif !version_is_less(agent_version, '5.99')
79
+ collection = 'puppet6'
85
80
  end
86
81
  end
87
82
  collection
@@ -98,15 +93,13 @@ module Beaker
98
93
  # @param version [String] a version number or the string 'latest'
99
94
  # @returns [String|nil] the name of the corresponding puppet collection, if any
100
95
  def puppet_collection_for(package, version)
101
- valid_packages = [
102
- :puppet_agent,
103
- :puppet,
104
- :puppetserver
96
+ valid_packages = %i[
97
+ puppet_agent
98
+ puppet
99
+ puppetserver
105
100
  ]
106
101
 
107
- unless valid_packages.include?(package)
108
- raise "package must be one of #{valid_packages.join(', ')}"
109
- end
102
+ raise "package must be one of #{valid_packages.join(', ')}" unless valid_packages.include?(package)
110
103
 
111
104
  case package
112
105
  when :puppet_agent, :puppet, :puppetserver
@@ -119,7 +112,7 @@ module Beaker
119
112
  pc1_x = {
120
113
  puppet: 4,
121
114
  puppet_agent: 1,
122
- puppetserver: 2
115
+ puppetserver: 2,
123
116
  }
124
117
 
125
118
  return 'pc1' if x == pc1_x[package]
@@ -136,9 +129,8 @@ module Beaker
136
129
  # @returns [String|nil] The version of puppet-agent, or nil if puppet-agent is not installed
137
130
  def puppet_agent_version_on(host)
138
131
  result = on(host, facter('aio_agent_version'), accept_all_exit_codes: true)
139
- if result.exit_code.zero?
140
- return result.stdout.strip
141
- end
132
+ return result.stdout.strip if result.exit_code.zero?
133
+
142
134
  nil
143
135
  end
144
136
 
@@ -149,36 +141,36 @@ module Beaker
149
141
  def puppetserver_version_on(host)
150
142
  result = on(host, 'puppetserver --version', accept_all_exit_codes: true)
151
143
  if result.exit_code.zero?
152
- matched = result.stdout.strip.scan(%r{\d+\.\d+\.\d+})
144
+ matched = result.stdout.strip.scan(/\d+\.\d+\.\d+/)
153
145
  return matched.first
154
146
  end
155
147
  nil
156
148
  end
157
149
 
158
- #Configure the provided hosts to be of the provided type (one of foss, aio, pe), if the host
159
- #is already associated with a type then remove the previous settings for that type
150
+ # Configure the provided hosts to be of the provided type (one of foss, aio, pe), if the host
151
+ # is already associated with a type then remove the previous settings for that type
160
152
  # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
161
153
  # or a role (String or Symbol) that identifies one or more hosts.
162
154
  # @param [String] type One of 'aio', 'pe' or 'foss'
163
- def configure_defaults_on( hosts, type )
155
+ def configure_defaults_on(hosts, type)
164
156
  block_on hosts do |host|
165
-
166
157
  # check to see if the host already has a type associated with it
167
158
  remove_defaults_on(host)
168
159
 
169
160
  add_method = "add_#{type}_defaults_on"
170
- if self.respond_to?(add_method, host)
171
- self.send(add_method, host)
172
- else
173
- raise "cannot add defaults of type #{type} for host #{host.name} (#{add_method} not present)"
174
- end
161
+ raise "cannot add defaults of type #{type} for host #{host.name} (#{add_method} not present)" unless respond_to?(
162
+ add_method, host
163
+ )
164
+
165
+ send(add_method, host)
166
+
175
167
  # add pathing env
176
168
  add_puppet_paths_on(host)
177
169
  end
178
170
  end
179
171
 
180
172
  # Configure the provided hosts to be of their host[:type], it host[type] == nil do nothing
181
- def configure_type_defaults_on( hosts )
173
+ def configure_type_defaults_on(hosts)
182
174
  block_on hosts do |host|
183
175
  has_defaults = false
184
176
  if host[:type]
@@ -189,11 +181,12 @@ module Beaker
189
181
  host_type = normalize_type(host_type)
190
182
  if host_type and host_type !~ /aio/
191
183
  add_method = "add_#{host_type}_defaults_on"
192
- if self.respond_to?(add_method, host)
193
- self.send(add_method, host)
194
- else
195
- raise "cannot add defaults of type #{host_type} for host #{host.name} (#{add_method} not present)"
196
- end
184
+ raise "cannot add defaults of type #{host_type} for host #{host.name} (#{add_method} not present)" unless respond_to?(
185
+ add_method, host
186
+ )
187
+
188
+ send(add_method, host)
189
+
197
190
  has_defaults = true
198
191
  end
199
192
  end
@@ -202,18 +195,16 @@ module Beaker
202
195
  has_defaults = true
203
196
  end
204
197
  # add pathing env
205
- if has_defaults
206
- add_puppet_paths_on(host)
207
- end
198
+ add_puppet_paths_on(host) if has_defaults
208
199
  end
209
200
  end
210
- alias_method :configure_foss_defaults_on, :configure_type_defaults_on
211
- alias_method :configure_pe_defaults_on, :configure_type_defaults_on
201
+ alias configure_foss_defaults_on configure_type_defaults_on
202
+ alias configure_pe_defaults_on configure_type_defaults_on
212
203
 
213
- #If the host is associated with a type remove all defaults and environment associated with that type.
204
+ # If the host is associated with a type remove all defaults and environment associated with that type.
214
205
  # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
215
206
  # or a role (String or Symbol) that identifies one or more hosts.
216
- def remove_defaults_on( hosts )
207
+ def remove_defaults_on(hosts)
217
208
  block_on hosts do |host|
218
209
  if host['type']
219
210
  # clean up the naming conventions here (some teams use foss-package, git-whatever, we need
@@ -222,14 +213,13 @@ module Beaker
222
213
  host_type = normalize_type(host['type'])
223
214
  remove_puppet_paths_on(hosts)
224
215
  remove_method = "remove_#{host_type}_defaults_on"
225
- if self.respond_to?(remove_method, host)
226
- self.send(remove_method, host)
227
- else
228
- raise "cannot remove defaults of type #{host_type} associated with host #{host.name} (#{remove_method} not present)"
229
- end
230
- if aio_version?(host)
231
- remove_aio_defaults_on(host)
232
- end
216
+ raise "cannot remove defaults of type #{host_type} associated with host #{host.name} (#{remove_method} not present)" unless respond_to?(
217
+ remove_method, host
218
+ )
219
+
220
+ send(remove_method, host)
221
+
222
+ remove_aio_defaults_on(host) if aio_version?(host)
233
223
  end
234
224
  end
235
225
  end
@@ -13,7 +13,7 @@ module Beaker
13
13
  def get_system_temp_path(host)
14
14
  host.system_temp_path
15
15
  end
16
- alias_method :get_temp_path, :get_system_temp_path
16
+ alias get_temp_path get_system_temp_path
17
17
 
18
18
  # Generates commands to be inserted into a Windows batch file to launch an MSI install
19
19
  # @param [String] msi_path The path of the MSI - can be a local Windows style file path like
@@ -25,15 +25,15 @@ module Beaker
25
25
  # @api private
26
26
  def msi_install_script(msi_path, msi_opts, log_path)
27
27
  # msiexec requires backslashes in file paths launched under cmd.exe start /w
28
- url_pattern = /^(https?|file):\/\//
29
- msi_path = msi_path.gsub(/\//, "\\") if msi_path !~ url_pattern
28
+ url_pattern = %r{^(https?|file)://}
29
+ msi_path = msi_path.gsub(%r{/}, '\\') if msi_path !~ url_pattern
30
30
 
31
- msi_params = msi_opts.map{|k, v| "#{k}=#{v}"}.join(' ')
31
+ msi_params = msi_opts.map { |k, v| "#{k}=#{v}" }.join(' ')
32
32
 
33
33
  # msiexec requires quotes around paths with backslashes - c:\ or file://c:\
34
34
  # not strictly needed for http:// but it simplifies this code
35
35
  batch_contents = <<~BATCH
36
- start /w msiexec.exe /i \"#{msi_path}\" /qn /L*V #{log_path} #{msi_params}
36
+ start /w msiexec.exe /i "#{msi_path}" /qn /L*V #{log_path} #{msi_params}
37
37
  exit /B %errorlevel%
38
38
  BATCH
39
39
  end
@@ -67,7 +67,7 @@ module Beaker
67
67
  host.do_scp_to(tmp_file.path, batch_path, {})
68
68
  end
69
69
 
70
- return batch_path, log_path
70
+ [batch_path, log_path]
71
71
  end
72
72
 
73
73
  # Given hosts construct a PATH that includes puppetbindir, facterbindir and hierabindir
@@ -112,34 +112,31 @@ module Beaker
112
112
  #
113
113
  # @api private
114
114
  def install_msi_on(hosts, msi_path, msi_opts = {}, opts = {})
115
- block_on hosts do | host |
115
+ block_on hosts do |host|
116
116
  msi_opts['PUPPET_AGENT_STARTUP_MODE'] ||= 'Manual'
117
117
  batch_path, log_file = create_install_msi_batch_on(host, msi_path, msi_opts)
118
118
  # Powershell command looses an escaped slash resulting in cygwin relative path
119
119
  # See https://github.com/puppetlabs/beaker/pull/1626#issuecomment-621341555
120
- log_file_escaped = log_file.gsub('\\','\\\\\\')
120
+ log_file_escaped = log_file.gsub('\\', '\\\\\\')
121
121
  # begin / rescue here so that we can reuse existing error msg propagation
122
122
  begin
123
123
  # 1641 = ERROR_SUCCESS_REBOOT_INITIATED
124
124
  # 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
125
- on host, Command.new("\"#{batch_path}\"", [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
126
- rescue
125
+ on host, Command.new("\"#{batch_path}\"", [], { cmdexe: true }), acceptable_exit_codes: [0, 1641, 3010]
126
+ rescue StandardError
127
127
  logger.info(file_contents_on(host, log_file_escaped))
128
128
  raise
129
129
  end
130
130
 
131
- if opts[:debug]
132
- logger.info(file_contents_on(host, log_file_escaped))
133
- end
131
+ logger.info(file_contents_on(host, log_file_escaped)) if opts[:debug]
134
132
 
135
133
  unless host.is_cygwin?
136
134
  # Enable the PATH updates
137
135
  host.close
138
136
 
139
137
  # Some systems require a full reboot to trigger the enabled path
140
- unless on(host, Command.new('puppet -h', [], { :cmdexe => true}), :accept_all_exit_codes => true).exit_code == 0
141
- host.reboot
142
- end
138
+ host.reboot unless on(host, Command.new('puppet -h', [], { cmdexe: true }),
139
+ accept_all_exit_codes: true).exit_code == 0
143
140
  end
144
141
 
145
142
  # verify service status post install
@@ -149,18 +146,18 @@ module Beaker
149
146
  #
150
147
  # We also take advantage of this output to verify the startup
151
148
  # settings are honored as supplied to the MSI
152
- on host, Command.new("sc qc puppet || sc qc pe-puppet", [], { :cmdexe => true }) do |result|
149
+ on host, Command.new('sc qc puppet || sc qc pe-puppet', [], { cmdexe: true }) do |result|
153
150
  output = result.stdout
154
151
  startup_mode = msi_opts['PUPPET_AGENT_STARTUP_MODE'].upcase
155
152
 
156
153
  search = case startup_mode
157
- when 'AUTOMATIC'
158
- { :code => 2, :name => 'AUTO_START' }
159
- when 'MANUAL'
160
- { :code => 3, :name => 'DEMAND_START' }
161
- when 'DISABLED'
162
- { :code => 4, :name => 'DISABLED' }
163
- end
154
+ when 'AUTOMATIC'
155
+ { code: 2, name: 'AUTO_START' }
156
+ when 'MANUAL'
157
+ { code: 3, name: 'DEMAND_START' }
158
+ when 'DISABLED'
159
+ { code: 4, name: 'DISABLED' }
160
+ end
164
161
 
165
162
  if output !~ /^\s+START_TYPE\s+:\s+#{search[:code]}\s+#{search[:name]}/
166
163
  raise "puppet service startup mode did not match supplied MSI option '#{startup_mode}'"
@@ -169,10 +166,13 @@ module Beaker
169
166
 
170
167
  # (PA-514) value for PUPPET_AGENT_STARTUP_MODE should be present in
171
168
  # registry and honored after install/upgrade.
172
- reg_key = host.is_x86_64? ? "HKLM\\SOFTWARE\\Wow6432Node\\Puppet Labs\\PuppetInstaller" :
173
- "HKLM\\SOFTWARE\\Puppet Labs\\PuppetInstaller"
174
- reg_query_command = %Q(reg query "#{reg_key}" /v "RememberedPuppetAgentStartupMode" | findstr #{msi_opts['PUPPET_AGENT_STARTUP_MODE']})
175
- on host, Command.new(reg_query_command, [], { :cmdexe => true })
169
+ reg_key = if host.is_x86_64?
170
+ 'HKLM\\SOFTWARE\\Wow6432Node\\Puppet Labs\\PuppetInstaller'
171
+ else
172
+ 'HKLM\\SOFTWARE\\Puppet Labs\\PuppetInstaller'
173
+ end
174
+ reg_query_command = %(reg query "#{reg_key}" /v "RememberedPuppetAgentStartupMode" | findstr #{msi_opts['PUPPET_AGENT_STARTUP_MODE']})
175
+ on host, Command.new(reg_query_command, [], { cmdexe: true })
176
176
 
177
177
  # emit the misc/versions.txt file which contains component versions for
178
178
  # puppet, facter, hiera, pxp-agent, packaging and vendored Ruby
@@ -180,7 +180,7 @@ module Beaker
180
180
  "'%PROGRAMFILES%\\Puppet Labs\\puppet\\misc\\versions.txt'",
181
181
  "'%PROGRAMFILES(X86)%\\Puppet Labs\\puppet\\misc\\versions.txt'",
182
182
  ].each do |path|
183
- result = on(host, "cmd /c type #{path}", :accept_all_exit_codes => true)
183
+ result = on(host, "cmd /c type #{path}", accept_all_exit_codes: true)
184
184
  if result.exit_code == 0
185
185
  logger.info(result.stdout)
186
186
  break
@@ -203,25 +203,23 @@ module Beaker
203
203
  #
204
204
  # @api private
205
205
  def generic_install_msi_on(hosts, msi_path, msi_opts = {}, opts = {})
206
- block_on hosts do | host |
206
+ block_on hosts do |host|
207
207
  batch_path, log_file = create_install_msi_batch_on(host, msi_path, msi_opts)
208
208
  # Powershell command looses an escaped slash resulting in cygwin relative path
209
209
  # See https://github.com/puppetlabs/beaker/pull/1626#issuecomment-621341555
210
- log_file_escaped = log_file.gsub('\\','\\\\\\')
210
+ log_file_escaped = log_file.gsub('\\', '\\\\\\')
211
211
  # begin / rescue here so that we can reuse existing error msg propagation
212
212
  begin
213
213
  # 1641 = ERROR_SUCCESS_REBOOT_INITIATED
214
214
  # 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
215
- on host, Command.new("\"#{batch_path}\"", [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
216
- rescue
215
+ on host, Command.new("\"#{batch_path}\"", [], { cmdexe: true }), acceptable_exit_codes: [0, 1641, 3010]
216
+ rescue StandardError
217
217
  logger.info(file_contents_on(host, log_file_escaped))
218
218
 
219
219
  raise
220
220
  end
221
221
 
222
- if opts[:debug]
223
- logger.info(file_contents_on(host, log_file_escaped))
224
- end
222
+ logger.info(file_contents_on(host, log_file_escaped)) if opts[:debug]
225
223
 
226
224
  host.close unless host.is_cygwin?
227
225
  end
@@ -1,3 +1,3 @@
1
1
  module BeakerPuppet
2
- VERSION = '1.29.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -1,7 +1,6 @@
1
1
  module Beaker
2
2
  module DSL
3
3
  module Wrappers
4
-
5
4
  # This is hairy and because of legacy code it will take a bit more
6
5
  # work to disentangle all of the things that are being passed into
7
6
  # this catchall param.
@@ -10,7 +9,7 @@ module Beaker
10
9
  options = args.last.is_a?(Hash) ? args.pop : {}
11
10
  options['ENV'] ||= {}
12
11
  options[:cmdexe] = true
13
- Command.new('facter', args, options )
12
+ Command.new('facter', args, options)
14
13
  end
15
14
 
16
15
  # This is hairy and because of legacy code it will take a bit more
@@ -21,7 +20,7 @@ module Beaker
21
20
  options = args.last.is_a?(Hash) ? args.pop : {}
22
21
  options['ENV'] ||= {}
23
22
  options[:cmdexe] = true
24
- Command.new('cfacter', args, options )
23
+ Command.new('cfacter', args, options)
25
24
  end
26
25
 
27
26
  # This is hairy and because of legacy code it will take a bit more
@@ -32,7 +31,7 @@ module Beaker
32
31
  options = args.last.is_a?(Hash) ? args.pop : {}
33
32
  options['ENV'] ||= {}
34
33
  options[:cmdexe] = true
35
- Command.new('hiera', args, options )
34
+ Command.new('hiera', args, options)
36
35
  end
37
36
 
38
37
  # This is hairy and because of legacy code it will take a bit more
@@ -46,48 +45,48 @@ module Beaker
46
45
  # we assume that an invocation with `puppet()` will have it's first argument
47
46
  # a face or sub command
48
47
  cmd = "puppet #{args.shift}"
49
- Command.new( cmd, args, options )
48
+ Command.new(cmd, args, options)
50
49
  end
51
50
 
52
51
  # @!visibility private
53
52
  def puppet_resource(*args)
54
- puppet( 'resource', *args )
53
+ puppet('resource', *args)
55
54
  end
56
55
 
57
56
  # @!visibility private
58
57
  def puppet_doc(*args)
59
- puppet( 'doc', *args )
58
+ puppet('doc', *args)
60
59
  end
61
60
 
62
61
  # @!visibility private
63
62
  def puppet_kick(*args)
64
- puppet( 'kick', *args )
63
+ puppet('kick', *args)
65
64
  end
66
65
 
67
66
  # @!visibility private
68
67
  def puppet_cert(*args)
69
- puppet( 'cert', *args )
68
+ puppet('cert', *args)
70
69
  end
71
70
 
72
71
  # @!visibility private
73
72
  def puppet_apply(*args)
74
- puppet( 'apply', *args )
73
+ puppet('apply', *args)
75
74
  end
76
75
 
77
76
  # @!visibility private
78
77
  def puppet_master(*args)
79
- puppet( 'master', *args )
78
+ puppet('master', *args)
80
79
  end
81
80
 
82
81
  # @!visibility private
83
82
  def puppet_agent(*args)
84
- puppet( 'agent', *args )
83
+ puppet('agent', *args)
85
84
  end
86
85
 
87
86
  # @!visibility private
88
87
  def puppet_filebucket(*args)
89
- puppet( 'filebucket', *args )
88
+ puppet('filebucket', *args)
90
89
  end
91
90
  end
92
91
  end
93
- end
92
+ end
data/lib/beaker-puppet.rb CHANGED
@@ -6,19 +6,18 @@ require 'beaker-puppet/wrappers'
6
6
 
7
7
  require 'beaker-puppet/helpers/rake_helpers'
8
8
 
9
- [ 'aio', 'foss' ].each do |lib|
9
+ %w[aio foss].each do |lib|
10
10
  require "beaker-puppet/install_utils/#{lib}_defaults"
11
11
  end
12
- [ 'windows', 'foss', 'puppet', 'ezbake', 'module' ].each do |lib|
12
+ %w[windows foss puppet ezbake module].each do |lib|
13
13
  require "beaker-puppet/install_utils/#{lib}_utils"
14
14
  end
15
- [ 'tk', 'facter', 'puppet', 'host' ].each do |lib|
15
+ %w[tk facter puppet host].each do |lib|
16
16
  require "beaker-puppet/helpers/#{lib}_helpers"
17
17
  end
18
18
 
19
19
  require 'beaker-puppet/install_utils/puppet5'
20
20
 
21
-
22
21
  module BeakerPuppet
23
22
  include Beaker::DSL::InstallUtils::FOSSDefaults
24
23
  include Beaker::DSL::InstallUtils::AIODefaults
@@ -40,4 +39,4 @@ module BeakerPuppet
40
39
  end
41
40
 
42
41
  # Register the DSL extension
43
- Beaker::DSL.register( BeakerPuppet )
42
+ Beaker::DSL.register(BeakerPuppet)
@@ -1,10 +1,9 @@
1
- test_name "Install Puppet Agent Packages" do
2
-
1
+ test_name 'Install Puppet Agent Packages' do
3
2
  opts = {
4
- :nightly_builds_url => ENV['NIGHTLY_BUILDS_URL'],
5
- :dev_builds_url => ENV['DEV_BUILDS_URL'],
6
- :puppet_agent_version => ENV['SHA'],
7
- :puppet_collection => ENV['RELEASE_STREAM']
3
+ nightly_builds_url: ENV.fetch('NIGHTLY_BUILDS_URL', nil),
4
+ dev_builds_url: ENV.fetch('DEV_BUILDS_URL', nil),
5
+ puppet_agent_version: ENV.fetch('SHA', nil),
6
+ puppet_collection: ENV.fetch('RELEASE_STREAM', nil),
8
7
  }
9
8
 
10
9
  install_puppet_agent_on(hosts, opts)
@@ -1,11 +1,9 @@
1
- test_name "Expunge puppet bits if hypervisor is none"
1
+ test_name 'Expunge puppet bits if hypervisor is none'
2
2
 
3
3
  # Ensure that the any previous installations of puppet
4
4
  # are removed from the host if it is not managed by a
5
5
  # provisioning hypervisor.
6
6
 
7
7
  hosts.each do |host|
8
- if host[:hypervisor] == "none"
9
- remove_puppet_on(host)
10
- end
8
+ remove_puppet_on(host) if host[:hypervisor] == 'none'
11
9
  end