beaker-puppet 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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'
@@ -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.0'
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
@@ -19,7 +19,7 @@ agents.each do |agent|
19
19
  on(agent, "rm -rf '#{default_dir}'")
20
20
 
21
21
  arch = agent[:ruby_arch] || 'x86'
22
- gem_arch = arch == 'x64' ? 'x64-mingw32' : 'x86-mingw32'
22
+ gem_arch = (arch == 'x64') ? 'x64-mingw32' : 'x86-mingw32'
23
23
  url = "#{base_url}/puppet-#{gem_version}-#{gem_arch}.gem"
24
24
  else
25
25
  url = "#{base_url}/puppet-#{gem_version}.gem"