beaker-puppet 2.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CODEOWNERS CHANGED
@@ -0,0 +1 @@
1
+ * @puppetlabs/phoenix @puppetlabs/unicorn
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # beaker-puppet: The Puppet-Specific Beaker Library
2
2
 
3
- [![License](https://img.shields.io/github/license/voxpupuli/beaker-puppet.svg)](https://github.com/voxpupuli/beaker-puppet/blob/master/LICENSE)
4
- [![Test](https://github.com/voxpupuli/beaker-puppet/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/beaker-puppet/actions/workflows/test.yml)
5
- [![codecov](https://codecov.io/gh/voxpupuli/beaker-puppet/branch/master/graph/badge.svg?token=Mypkl78hvK)](https://codecov.io/gh/voxpupuli/beaker-puppet)
6
- [![Release](https://github.com/voxpupuli/beaker-puppet/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/beaker-puppet/actions/workflows/release.yml)
3
+ [![License](https://img.shields.io/github/license/puppetlabs/beaker-puppet.svg)](https://github.com/puppetlabs/beaker-puppet/blob/master/LICENSE)
4
+ [![Test](https://github.com/puppetlabs/beaker-puppet/actions/workflows/test.yml/badge.svg)](https://github.com/puppetlabs/beaker-puppet/actions/workflows/test.yml)
5
+ [![codecov](https://codecov.io/gh/puppetlabs/beaker-puppet/branch/master/graph/badge.svg?token=Mypkl78hvK)](https://codecov.io/gh/puppetlabs/beaker-puppet)
6
+ [![Release](https://github.com/puppetlabs/beaker-puppet/actions/workflows/release.yml/badge.svg)](https://github.com/puppetlabs/beaker-puppet/actions/workflows/release.yml)
7
7
  [![RubyGem Version](https://img.shields.io/gem/v/beaker-puppet.svg)](https://rubygems.org/gems/beaker-puppet)
8
8
  [![RubyGem Downloads](https://img.shields.io/gem/dt/beaker-puppet.svg)](https://rubygems.org/gems/beaker-puppet)
9
- [![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)
10
9
 
11
10
  The purpose of this library is to hold all puppet-specific info & DSL methods.
12
11
  This includes all helper & installer methods.
@@ -79,14 +78,6 @@ file, or you can provide a beaker-hostgenerator value to the `TEST_TARGET`
79
78
  environment variable. You can also specify the tests that get executed with the
80
79
  `TESTS` environment variable.
81
80
 
82
- ## Transfer Notice
83
-
84
- This plugin was originally authored by [Puppet Inc](http://puppet.com).
85
- The maintainer preferred that Puppet Community take ownership of the module for future improvement and maintenance.
86
- Existing pull requests and issues were transferred over, please fork and continue to contribute here.
87
-
88
- Previously: https://github.com/puppetlabs/beaker
89
-
90
81
  ## License
91
82
 
92
83
  This gem is licensed under the Apache-2 license.
data/Rakefile CHANGED
@@ -189,7 +189,7 @@ else
189
189
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
190
190
  config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
191
191
  config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog]
192
- config.user = 'voxpupuli'
192
+ config.user = 'puppetlabs'
193
193
  config.project = 'beaker-puppet'
194
194
  config.future_release = "#{Gem::Specification.load("#{config.project}.gemspec").version}"
195
195
  end
@@ -44,7 +44,7 @@ step 'verify with_stub_host_on' do
44
44
  hosts.each do |host|
45
45
  hosts_file = get_hosts_file(host)
46
46
  result = on host, "cat #{hosts_file}"
47
- assert_no_match(/sleepy/, result.stdout)
47
+ refute_match(/sleepy/, result.stdout)
48
48
  end
49
49
  end
50
50
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.description = 'For use for the Beaker acceptance testing tool'
12
12
  s.license = 'Apache-2.0'
13
13
 
14
- s.required_ruby_version = '>= 2.7'
14
+ s.required_ruby_version = '>= 2.7', '< 3.2'
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -23,12 +23,12 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'rake', '~> 13.0'
24
24
  s.add_development_dependency 'rspec', '~> 3.0'
25
25
  s.add_development_dependency 'rspec-its', '~> 1.3'
26
- s.add_development_dependency 'voxpupuli-rubocop', '~> 1.2'
26
+ s.add_development_dependency 'voxpupuli-rubocop', '~> 2.1.0'
27
27
 
28
28
  # Acceptance Testing Dependencies
29
29
  s.add_development_dependency 'beaker-vmpooler', '~> 1.4'
30
30
 
31
31
  # Run time dependencies
32
- s.add_runtime_dependency 'beaker', '~> 4.1'
32
+ s.add_runtime_dependency 'beaker', '~> 5.0'
33
33
  s.add_runtime_dependency 'oga', '~> 3.4'
34
34
  end
@@ -81,21 +81,13 @@ module Beaker
81
81
  # Test Puppet running in a certain run mode with specific options.
82
82
  # This ensures the following steps are performed:
83
83
  # 1. The pre-test Puppet configuration is backed up
84
- # 2. A new Puppet configuraton file is layed down
84
+ # 2. Lay down a new Puppet configuraton file
85
85
  # 3. Puppet is started or restarted in the specified run mode
86
86
  # 4. Ensure Puppet has started correctly
87
87
  # 5. Further tests are yielded to
88
88
  # 6. Revert Puppet to the pre-test state
89
89
  # 7. Testing artifacts are saved in a folder named for the test
90
90
  #
91
- # @note Whether Puppet is started or restarted depends on what kind of
92
- # server you're running. Passenger and puppetserver are restarted before.
93
- # Webrick is started before and stopped after yielding, unless you're using
94
- # service scripts, then it'll behave like passenger & puppetserver.
95
- # Passenger and puppetserver (or webrick using service scripts)
96
- # restart after yielding by default. You can stop this from happening
97
- # by setting the :restart_when_done flag of the conf_opts argument.
98
- #
99
91
  # @param [Host] host One object that act like Host
100
92
  #
101
93
  # @param [Hash{Symbol=>String}] conf_opts Represents puppet settings.
@@ -112,22 +104,11 @@ module Beaker
112
104
  #
113
105
  # These will only be applied when starting a FOSS
114
106
  # master, as a pe master is just bounced.
115
- # @option conf_opts [Hash] :__service_args__ A special setting of options
116
- # for controlling how the puppet master service is
117
- # handled. The only setting currently is
118
- # :bypass_service_script, which if set true will
119
- # force stopping and starting a webrick master
120
- # using the start_puppet_from_source_* methods,
121
- # even if it seems the host has passenger.
122
- # This is needed in FOSS tests to initialize
123
- # SSL.
124
107
  # @option conf_opts [Boolean] :restart_when_done determines whether a restart
125
108
  # should be run after the test has been yielded to.
126
109
  # Will stop puppet if false. Default behavior
127
110
  # is to restart, but you can override this on the
128
111
  # host or with this option.
129
- # (Note: only works for passenger & puppetserver
130
- # masters (or webrick using the service scripts))
131
112
  # @param [File] testdir The temporary directory which will hold backup
132
113
  # configuration, and other test artifacts.
133
114
  #
@@ -156,12 +137,11 @@ module Beaker
156
137
  end
157
138
 
158
139
  cmdline_args = conf_opts[:__commandline_args__]
159
- service_args = conf_opts[:__service_args__] || {}
160
140
  restart_when_done = true
161
141
  restart_when_done = host[:restart_when_done] if host.has_key?(:restart_when_done)
162
142
  restart_when_done = conf_opts.fetch(:restart_when_done, restart_when_done)
163
143
  conf_opts = conf_opts.reject do |k, v|
164
- %i[__commandline_args__ __service_args__ restart_when_done].include?(k)
144
+ %i[__commandline_args__ restart_when_done].include?(k)
165
145
  end
166
146
 
167
147
  curl_retries = host['master-start-curl-retries'] || options['master-start-curl-retries']
@@ -202,13 +182,8 @@ module Beaker
202
182
  puppet_config(host, 'confdir', section: 'master'),
203
183
  testdir,
204
184
  'puppet.conf')
205
- lay_down_new_puppet_conf host, conf_opts, testdir
206
-
207
- if host.use_service_scripts? && !service_args[:bypass_service_script]
208
- bounce_service(host, host['puppetservice'], curl_retries)
209
- else
210
- puppet_master_started = start_puppet_from_source_on!(host, cmdline_args)
211
- end
185
+ lay_down_new_puppet_conf(host, conf_opts, testdir)
186
+ bounce_service(host, host['puppetservice'], curl_retries)
212
187
 
213
188
  yield self if block_given?
214
189
 
@@ -229,20 +204,11 @@ module Beaker
229
204
  raise(original_exception)
230
205
  ensure
231
206
  begin
232
- if host.use_service_scripts? && !service_args[:bypass_service_script]
233
- restore_puppet_conf_from_backup(host, backup_file)
234
- if restart_when_done
235
- bounce_service(host, host['puppetservice'], curl_retries)
236
- else
237
- host.exec puppet_resource('service', host['puppetservice'], 'ensure=stopped')
238
- end
207
+ restore_puppet_conf_from_backup(host, backup_file)
208
+ if restart_when_done
209
+ bounce_service(host, host['puppetservice'], curl_retries)
239
210
  else
240
- if puppet_master_started
241
- stop_puppet_from_source_on(host)
242
- else
243
- dump_puppet_log(host)
244
- end
245
- restore_puppet_conf_from_backup(host, backup_file)
211
+ host.exec puppet_resource('service', host['puppetservice'], 'ensure=stopped')
246
212
  end
247
213
  rescue Exception => teardown_exception
248
214
  begin
@@ -281,19 +247,6 @@ module Beaker
281
247
  end
282
248
  end
283
249
 
284
- # @!visibility private
285
- def start_puppet_from_source_on!(host, args = '')
286
- host.exec(puppet('master', args))
287
-
288
- logger.debug 'Waiting for the puppet master to start'
289
- raise Beaker::DSL::FailTest, 'Puppet master did not start in a timely fashion' unless port_open_within?(
290
- host, 8140, 10
291
- )
292
-
293
- logger.debug 'The puppet master has started'
294
- true
295
- end
296
-
297
250
  # @!visibility private
298
251
  def stop_puppet_from_source_on(host)
299
252
  pid = host.exec(Command.new('cat `puppet config print --section master pidfile`')).stdout.chomp
@@ -355,19 +308,12 @@ module Beaker
355
308
  def bounce_service(host, service, curl_retries = nil, port = nil)
356
309
  curl_retries = 120 if curl_retries.nil?
357
310
  port = options[:puppetserver_port] if port.nil?
358
- if host.graceful_restarts?
359
- service = host.check_for_command('apache2ctl') ? 'apache2ctl' : 'apachectl'
360
- apachectl_path = host.is_pe? ? "#{host['puppetsbindir']}/#{service}" : service
361
- host.exec(Command.new("#{apachectl_path} graceful"))
362
- else
363
- result = host.exec(Command.new("service #{service} reload"),
364
- acceptable_exit_codes: [0, 1, 3])
365
- return result if result.exit_code == 0
311
+ result = host.exec(Command.new("service #{service} reload"), acceptable_exit_codes: [0, 1, 3])
312
+ return result if result.exit_code == 0
366
313
 
367
- host.exec puppet_resource('service', service, 'ensure=stopped')
368
- host.exec puppet_resource('service', service, 'ensure=running')
314
+ host.exec puppet_resource('service', service, 'ensure=stopped')
315
+ host.exec puppet_resource('service', service, 'ensure=running')
369
316
 
370
- end
371
317
  curl_with_retries(" #{service} ", host, "https://localhost:#{port}", [35, 60], curl_retries)
372
318
  end
373
319
 
@@ -819,28 +765,17 @@ module Beaker
819
765
  def sign_certificate_for(host = [])
820
766
  hostnames = []
821
767
  hosts = host.is_a?(Array) ? host : [host]
822
- puppet_version = on(master, puppet('--version')).stdout.chomp
823
768
  hosts.each do |current_host|
824
769
  if [master, dashboard, database].include? current_host
825
- on current_host, puppet('agent -t'), acceptable_exit_codes: [0, 1, 2]
826
-
827
- if version_is_less(puppet_version, '5.99')
828
- on master, puppet("cert --allow-dns-alt-names sign #{current_host}"), acceptable_exit_codes: [0, 24]
829
- else
830
- on master, "puppetserver ca sign --certname #{current_host}"
831
- end
770
+ on(current_host, puppet('agent -t'), acceptable_exit_codes: [0, 1, 2])
771
+ on(master, "puppetserver ca sign --certname #{current_host}")
832
772
  else
833
773
  hostnames << Regexp.escape(current_host.node_name)
834
774
  end
835
775
  end
836
776
 
837
777
  if hostnames.size < 1
838
- if version_is_less(puppet_version, '5.99')
839
- on master, puppet('cert --sign --all --allow-dns-alt-names'),
840
- acceptable_exit_codes: [0, 24]
841
- else
842
- on master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]
843
- end
778
+ on(master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24])
844
779
  return
845
780
  end
846
781
 
@@ -852,21 +787,11 @@ module Beaker
852
787
  fail_test("Failed to sign cert for #{hostnames}")
853
788
  hostnames.clear
854
789
  end
855
-
856
- if version_is_less(puppet_version, '5.99')
857
- on master, puppet('cert --sign --all --allow-dns-alt-names'), acceptable_exit_codes: [0, 24]
858
- out = on(master, puppet('cert --list --all')).stdout
859
- if hostnames.all? { |hostname| out =~ /\+ "?#{hostname}"?/ }
860
- hostnames.clear
861
- break
862
- end
863
- else
864
- on master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]
865
- out = on(master, 'puppetserver ca list --all').stdout
866
- if out !~ /.*Requested.*/ && hostnames.all? { |hostname| out =~ /\b#{hostname}\b/ }
867
- hostnames.clear
868
- break
869
- end
790
+ on(master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24])
791
+ out = on(master, 'puppetserver ca list --all').stdout
792
+ if out !~ /.*Requested.*/ && hostnames.all? { |hostname| out =~ /\b#{hostname}\b/ }
793
+ hostnames.clear
794
+ break
870
795
  end
871
796
 
872
797
  sleep next_sleep
@@ -98,8 +98,8 @@ module Beaker
98
98
  git_protocol = 'https://'
99
99
  end
100
100
 
101
- repo = git_server == 'github.com' ? "#{git_fork}/#{project_name}.git" : "#{git_fork}-#{project_name}.git"
102
- git_protocol == 'git@' ? "#{git_protocol}#{git_server}:#{repo}" : "#{git_protocol}#{git_server}/#{repo}"
101
+ repo = (git_server == 'github.com') ? "#{git_fork}/#{project_name}.git" : "#{git_fork}-#{project_name}.git"
102
+ (git_protocol == 'git@') ? "#{git_protocol}#{git_server}:#{repo}" : "#{git_protocol}#{git_server}/#{repo}"
103
103
  end
104
104
  alias build_giturl build_git_url
105
105
 
@@ -406,7 +406,7 @@ module Beaker
406
406
  end
407
407
 
408
408
  case host['platform']
409
- when /el-|redhat|fedora|sles|centos|cisco_/
409
+ when /amazon|el-|redhat|fedora|sles|centos|cisco_/
410
410
  package_name = 'puppet-agent'
411
411
  package_name << "-#{opts[:puppet_agent_version]}" if opts[:puppet_agent_version]
412
412
  when /debian|ubuntu|huaweios/
@@ -993,7 +993,7 @@ module Beaker
993
993
  opts = sanitize_opts(opts)
994
994
 
995
995
  case variant
996
- when /^(fedora|el|redhat|centos|sles|cisco_nexus|cisco_ios_xr)$/
996
+ when /^(amazon|fedora|el|redhat|centos|sles|cisco_nexus|cisco_ios_xr)$/
997
997
  variant_url_value = (%w[redhat centos].include?(::Regexp.last_match(1)) ? 'el' : ::Regexp.last_match(1))
998
998
  if variant == 'cisco_nexus'
999
999
  variant_url_value = 'cisco-wrlinux'
@@ -1148,7 +1148,7 @@ module Beaker
1148
1148
  repo_configs_dir = nil,
1149
1149
  opts = options)
1150
1150
  variant, version, arch, codename = host['platform'].to_array
1151
- if variant !~ /^(fedora|el|redhat|centos|debian|ubuntu|huaweios|cisco_nexus|cisco_ios_xr|sles)$/
1151
+ if variant !~ /^(amazon|fedora|el|redhat|centos|debian|ubuntu|huaweios|cisco_nexus|cisco_ios_xr|sles)$/
1152
1152
  raise "No repository installation step for #{variant} yet..."
1153
1153
  end
1154
1154
 
@@ -1162,7 +1162,7 @@ module Beaker
1162
1162
  # url type
1163
1163
  _, protocol, hostname = opts[:dev_builds_url].partition %r{.*://}
1164
1164
  dev_builds_url = protocol + hostname
1165
- dev_builds_url = opts[:dev_builds_url] if variant =~ /^(fedora|el|redhat|centos)$/
1165
+ dev_builds_url = opts[:dev_builds_url] if variant =~ /^(amazon|fedora|el|redhat|centos)$/
1166
1166
 
1167
1167
  install_repo_configs(host, dev_builds_url, package_name,
1168
1168
  build_version, platform_configs_dir)
@@ -1195,193 +1195,6 @@ module Beaker
1195
1195
  configure_type_defaults_on(host)
1196
1196
  end
1197
1197
 
1198
- # Install development repo of the puppet-agent on the given host(s). Downloaded from
1199
- # location of the form DEV_BUILDS_URL/puppet-agent/AGENT_VERSION/repos
1200
- #
1201
- # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
1202
- # or a role (String or Symbol) that identifies one or more hosts.
1203
- # @param [Hash{Symbol=>String}] opts An options hash
1204
- # @option opts [String] :puppet_agent_version The version of puppet-agent to install. This
1205
- # parameter is used by puppet with the +SUITE_VERSION+ environment
1206
- # variable to provide a `git describe` value to beaker to create a
1207
- # build server URL. Note that +puppet_agent_sha+ will still be used
1208
- # instead of this if a value is provided for that option
1209
- # @option opts [String] :puppet_agent_sha The sha of puppet-agent to install, defaults to provided
1210
- # puppet_agent_version
1211
- # @option opts [String] :copy_base_local Directory where puppet-agent artifact
1212
- # will be stored locally
1213
- # (default: 'tmp/repo_configs')
1214
- # @option opts [String] :copy_dir_external Directory where puppet-agent
1215
- # artifact will be pushed to on the external machine
1216
- # (default: '/root')
1217
- # @option opts [String] :puppet_collection Defaults to 'PC1'
1218
- # @option opts [String] :dev_builds_url Base URL to pull artifacts from
1219
- # @option opts [String] :copy_base_local Directory where puppet-agent artifact
1220
- # will be stored locally
1221
- # (default: 'tmp/repo_configs')
1222
- # @option opts [String] :copy_dir_external Directory where puppet-agent
1223
- # artifact will be pushed to on the external machine
1224
- # (default: '/root')
1225
- #
1226
- # @note on windows, the +:ruby_arch+ host parameter can determine in addition
1227
- # to other settings whether the 32 or 64bit install is used
1228
- #
1229
- # @example
1230
- # install_puppet_agent_dev_repo_on(host, { :puppet_agent_sha => 'd3377feaeac173aada3a2c2cedd141eb610960a7', :puppet_agent_version => '1.1.1.225.gd3377fe' })
1231
- #
1232
- # @return nil
1233
- def install_puppet_agent_dev_repo_on(hosts, global_opts)
1234
- global_opts[:puppet_agent_version] ||= global_opts[:version] # backward compatability
1235
- unless global_opts[:puppet_agent_version]
1236
- raise 'must provide :puppet_agent_version (puppet-agent version) for install_puppet_agent_dev_repo_on'
1237
- end
1238
-
1239
- block_on hosts do |host|
1240
- opts = global_opts.dup
1241
-
1242
- # TODO: consolidate these values as they serve no purpose from beaker's side
1243
- # you could provide any values you could to one to the other
1244
- puppet_agent_version = opts[:puppet_agent_sha] || opts[:puppet_agent_version]
1245
-
1246
- opts = sanitize_opts(opts)
1247
- opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{puppet_agent_version}/repos/"
1248
- opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
1249
- opts[:puppet_collection] ||= 'PC1'
1250
-
1251
- release_path = opts[:download_url]
1252
-
1253
- variant, version, arch, codename = host['platform'].to_array
1254
- add_role(host, 'aio') # we are installing agent, so we want aio role
1255
- copy_dir_local = File.join(opts[:copy_base_local], variant)
1256
- onhost_copy_base = opts[:copy_dir_external] || host.external_copy_base
1257
-
1258
- case variant
1259
- when /^(fedora|el|redhat|centos|debian|ubuntu|huaweios|cisco_nexus|cisco_ios_xr)$/
1260
- if arch == 's390x' || host['hypervisor'] == 'ec2'
1261
- logger.trace("#install_puppet_agent_dev_repo_on: unsupported host #{host} for repo detected. using dev package")
1262
- else
1263
- install_puppetlabs_dev_repo(host, 'puppet-agent', puppet_agent_version, nil, opts)
1264
- host.install_package('puppet-agent')
1265
- logger.trace('#install_puppet_agent_dev_repo_on: install_puppetlabs_dev_repo finished')
1266
- next
1267
- end
1268
- when /^(eos|osx|windows|solaris|sles|aix)$/
1269
- # Download installer package file & run install manually.
1270
- # Done below, so that el hosts with s390x arch or on ec2 can use this
1271
- # workflow as well
1272
- else
1273
- raise "No repository installation step for #{variant} yet..."
1274
- end
1275
-
1276
- release_path_end, release_file = host.puppet_agent_dev_package_info(
1277
- opts[:puppet_collection], opts[:puppet_agent_version], opts
1278
- )
1279
- release_path << release_path_end
1280
- logger.trace('#install_puppet_agent_dev_repo_on: dev_package_info, continuing...')
1281
-
1282
- if variant =~ /eos/
1283
- host.get_remote_file("#{release_path}/#{release_file}")
1284
- else
1285
- onhost_copied_file = File.join(onhost_copy_base, release_file)
1286
- fetch_http_file(release_path, release_file, copy_dir_local)
1287
- scp_to host, File.join(copy_dir_local, release_file), onhost_copy_base
1288
- end
1289
-
1290
- case variant
1291
- when /^eos/
1292
- host.install_from_file(release_file)
1293
- when /^(sles|aix|fedora|el|redhat|centos)$/
1294
- # NOTE: AIX does not support repo management. This block assumes
1295
- # that the desired rpm has been mirrored to the 'repos' location.
1296
- # NOTE: the AIX 7.1 package will only install on 7.2 with
1297
- # --ignoreos. This is a bug in package building on AIX 7.1's RPM
1298
- aix_72_ignoreos_hack = '--ignoreos' if variant == 'aix' && version == '7.2'
1299
- on host, "rpm -ivh #{aix_72_ignoreos_hack} #{onhost_copied_file}"
1300
- when /^windows$/
1301
- result = on host, "echo #{onhost_copied_file}"
1302
- onhost_copied_file = result.raw_output.chomp
1303
- msi_opts = { debug: host[:pe_debug] || opts[:pe_debug] }
1304
- install_msi_on(host, onhost_copied_file, {}, msi_opts)
1305
- when /^osx$/
1306
- host.install_package("puppet-agent-#{opts[:puppet_agent_version]}*")
1307
- when /^solaris$/
1308
- host.solaris_install_local_package(release_file, onhost_copy_base)
1309
- end
1310
- configure_type_defaults_on(host)
1311
- end
1312
- end
1313
- alias install_puppetagent_dev_repo install_puppet_agent_dev_repo_on
1314
-
1315
- # Install shared repo of the puppet-agent on the given host(s). Downloaded from
1316
- # location of the form PE_PROMOTED_BUILDS_URL/PE_VER/puppet-agent/AGENT_VERSION/repo
1317
- #
1318
- # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
1319
- # or a role (String or Symbol) that identifies one or more hosts.
1320
- # @param [Hash{Symbol=>String}] opts An options hash
1321
- # @option opts [String] :puppet_agent_version The version of puppet-agent to install, defaults to 'latest'
1322
- # @option opts [String] :pe_ver The version of PE (will also use host['pe_ver']), defaults to '4.0'
1323
- # @option opts [String] :copy_base_local Directory where puppet-agent artifact
1324
- # will be stored locally
1325
- # (default: 'tmp/repo_configs')
1326
- # @option opts [String] :copy_dir_external Directory where puppet-agent
1327
- # artifact will be pushed to on the external machine
1328
- # (default: '/root')
1329
- # @option opts [String] :puppet_collection Defaults to 'PC1'
1330
- # @option opts [String] :pe_promoted_builds_url Base URL to pull artifacts from
1331
- #
1332
- # @note on windows, the +:ruby_arch+ host parameter can determine in addition
1333
- # to other settings whether the 32 or 64bit install is used
1334
- #
1335
- # @example
1336
- # install_puppet_agent_pe_promoted_repo_on(host, { :puppet_agent_version => '1.1.0.227', :pe_ver => '4.0.0-rc1'})
1337
- #
1338
- # @return nil
1339
- def install_puppet_agent_pe_promoted_repo_on(hosts, opts)
1340
- opts[:puppet_agent_version] ||= 'latest'
1341
-
1342
- block_on hosts do |host|
1343
- pe_ver = host[:pe_ver] || opts[:pe_ver] || '4.0.0-rc1'
1344
- opts = sanitize_opts(opts)
1345
- opts[:download_url] =
1346
- "#{opts[:pe_promoted_builds_url]}/puppet-agent/#{pe_ver}/#{opts[:puppet_agent_version]}/repos"
1347
- opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
1348
- opts[:copy_dir_external] ||= host.external_copy_base
1349
- opts[:puppet_collection] ||= puppet_collection_for(:puppet_agent, opts[:puppet_agent_version])
1350
- add_role(host, 'aio') # we are installing agent, so we want aio role
1351
- release_path = opts[:download_url]
1352
- variant, version, arch, codename = host['platform'].to_array
1353
- copy_dir_local = File.join(opts[:copy_base_local], variant)
1354
- onhost_copy_base = opts[:copy_dir_external]
1355
-
1356
- release_path_end, release_file, download_file =
1357
- host.pe_puppet_agent_promoted_package_info(
1358
- opts[:puppet_collection], opts
1359
- )
1360
- release_path << release_path_end
1361
-
1362
- onhost_copied_download = File.join(onhost_copy_base, download_file)
1363
- onhost_copied_file = File.join(onhost_copy_base, release_file)
1364
- fetch_http_file(release_path, download_file, copy_dir_local)
1365
- scp_to host, File.join(copy_dir_local, download_file), onhost_copy_base
1366
-
1367
- if variant == 'windows'
1368
- result = on host, "echo #{onhost_copied_file}"
1369
- onhost_copied_file = result.raw_output.chomp
1370
- opts = { debug: host[:pe_debug] || opts[:pe_debug] }
1371
- # couldn't pull this out, because it's relying on
1372
- # {Beaker::DSL::InstallUtils::WindowsUtils} methods,
1373
- # which I didn't want to attack right now. TODO
1374
- install_msi_on(host, onhost_copied_file, {}, opts)
1375
- else
1376
- host.pe_puppet_agent_promoted_package_install(
1377
- onhost_copy_base, onhost_copied_download,
1378
- onhost_copied_file, download_file, opts
1379
- )
1380
- end
1381
- configure_type_defaults_on(host)
1382
- end
1383
- end
1384
-
1385
1198
  # This method will install a pem file certificate on a windows host
1386
1199
  #
1387
1200
  # @param [Host] host A host object
@@ -1518,7 +1331,10 @@ module Beaker
1518
1331
  end
1519
1332
 
1520
1333
  # delete any residual files
1521
- on(host, 'find / -name "*puppet*" -print | xargs rm -rf')
1334
+ result = on(host, 'find / -name "*puppet*" -print | xargs rm -rf', accept_all_exit_codes: true)
1335
+ unless result.exit_code == 0
1336
+ logger.notify("Attempt to clean residual puppet files errored, but can maybe be ignored.\n #{result.stderr}")
1337
+ end
1522
1338
  end
1523
1339
  end
1524
1340
 
@@ -65,23 +65,6 @@ module Beaker
65
65
  end
66
66
  end
67
67
 
68
- # Given an agent_version, return the puppet collection associated with that agent version
69
- #
70
- # @param [String] agent_version version string or 'latest'
71
- # @deprecated This method returns 'PC1' as the latest puppet collection;
72
- # this is incorrect. Use {#puppet_collection_for} instead.
73
- def get_puppet_collection(agent_version = 'latest')
74
- collection = 'PC1'
75
- if agent_version != 'latest'
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'
80
- end
81
- end
82
- collection
83
- end
84
-
85
68
  # Determine the puppet collection that matches a given package version. The package
86
69
  # must be one of
87
70
  # * :puppet_agent (you can get this version from the `aio_agent_version_fact`)
@@ -1,3 +1,3 @@
1
1
  module BeakerPuppet
2
- VERSION = '2.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
data/release-prep.sh ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Update Gemfile.lock
4
+ docker run -t --rm \
5
+ -v $(pwd):/app \
6
+ ruby:3.1.4 \
7
+ /bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
8
+
9
+ docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
10
+ githubchangeloggenerator/github-changelog-generator:1.16.2 \
11
+ github_changelog_generator --future-release $(grep VERSION lib/beaker-puppet/version.rb |rev |cut -d "'" -f 2 |rev)
@@ -1,16 +1,30 @@
1
1
  test_name 'Install Puppet Agent Packages' do
2
- opts = {
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),
7
- }
2
+ agents.each do |agent|
3
+ path = ENV.fetch('DEV_BUILD_PATH', nil)
4
+ if path
5
+ raise ArgumentError, "The path #{path} does not exist" unless File.exist?(path)
6
+
7
+ basename = File.basename(path)
8
+ scp_to(agent, path, basename)
8
9
 
9
- install_puppet_agent_on(hosts, opts)
10
+ # configure locations for ruby, puppet, config files, etc
11
+ add_aio_defaults_on(agent)
12
+ agent.install_package(basename)
13
+ else
14
+ opts = {
15
+ nightly_builds_url: ENV.fetch('NIGHTLY_BUILDS_URL', nil),
16
+ dev_builds_url: ENV.fetch('DEV_BUILDS_URL', nil),
17
+ puppet_agent_version: ENV.fetch('SHA', nil),
18
+ puppet_collection: ENV.fetch('RELEASE_STREAM', nil),
19
+ }
20
+
21
+ install_puppet_agent_on(hosts, opts)
22
+ end
23
+ end
10
24
 
11
25
  # make sure install is sane, beaker has already added puppet and ruby
12
26
  # to PATH in ~/.ssh/environment
13
- agents.each do |agent|
27
+ agents.each do |agent| # rubocop:disable Style/CombinableLoops
14
28
  on agent, puppet('--version')
15
29
  ruby = ruby_command(agent)
16
30
  on agent, "#{ruby} --version"
@@ -7,15 +7,9 @@ test_name 'Validate Sign Cert' do
7
7
  skip_test 'not testing with puppetserver' unless @options['is_puppetserver']
8
8
  hostname = on(master, 'facter hostname').stdout.strip
9
9
  fqdn = on(master, 'facter fqdn').stdout.strip
10
- puppet_version = on(master, puppet('--version')).stdout.chomp
11
10
 
12
- if master.use_service_scripts?
13
- step 'Ensure puppet is stopped'
14
- # Passenger, in particular, must be shutdown for the cert setup steps to work,
15
- # but any running puppet master will interfere with webrick starting up and
16
- # potentially ignore the puppet.conf changes.
17
- on(master, puppet('resource', 'service', master['puppetservice'], 'ensure=stopped'))
18
- end
11
+ step 'Ensure puppet is stopped'
12
+ on(master, puppet('resource', 'service', master['puppetservice'], 'ensure=stopped'))
19
13
 
20
14
  step 'Clear SSL on all hosts'
21
15
  hosts.each do |host|
@@ -38,11 +32,10 @@ test_name 'Validate Sign Cert' do
38
32
  },
39
33
  }
40
34
 
41
- # In Puppet 6, we want to be using an intermediate CA
42
- on master, 'puppetserver ca setup' if !version_is_less(puppet_version, '5.99') && !master['use_existing_container']
35
+ on(master, 'puppetserver ca setup')
43
36
  with_puppet_running_on(master, master_opts) do
44
37
  step 'Agents: Run agent --test with autosigning enabled to get cert'
45
- on agents, puppet('agent --test'), acceptable_exit_codes: [0, 2]
38
+ on(agents, puppet('agent --test'), acceptable_exit_codes: [0, 2])
46
39
  end
47
40
  end
48
41
  end