simp-beaker-helpers 1.21.2 → 1.21.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c454a97bb3100de8137245a8f4e328451e4048665c482db961c668cb820c972
4
- data.tar.gz: 1aed320014ebd403f631faeb3f29484f6cc55a4441a4e499beab7409e289f101
3
+ metadata.gz: 876c4f6b1c6dfe6c9230d0c127e6dabdd3cc77c372e0d6def7e42606ecd35cc6
4
+ data.tar.gz: 062201bba85a2199e442d907b30aae6e2674db29de2c21c7bc49e5ef5dd7c117
5
5
  SHA512:
6
- metadata.gz: b1df4f0b7411eead1d2c0d49f4f16d7a4f5dde7162ce91cb3fcba07018382508e56a8e16fdd65f06ee0b74fa2f4e6d036a7ea7f1d3c292964ce4face723bbb04
7
- data.tar.gz: 82fb880cc4c7c975aa7a4b44134ec88f6d34d7a30431914c22b2616e54880b00ec647221779dda3d12e2b3f99923af49d3ce49a03efa20d04d318db3457189a4
6
+ metadata.gz: 8469baf544e003f9450a6c0b5639a2112c36961846e06faf6222878b5a1f0d6eb5663fd3c921d6b2117174cfdcf74863da67c40364c34a3818a5eb1204a94901
7
+ data.tar.gz: 2810e22a457f9daf3d91e355d2ead18e1b3dd5aaecbebc8f516930968cc937b1a9322750d305591db47d3f2d0d25cd8895c9189c16ee71f9505756eb447015b0
@@ -1,3 +1,11 @@
1
+ ### 1.21.3 / 2021-01-20
2
+ * Fixed:
3
+ * Allow all methods that can safely take SUT arrays to do so
4
+ * Ensure that pfact_on returns a Hash if appropriate
5
+ * Fix container support in copy_to
6
+ * Added:
7
+ * Explicitly support podman local and remote in copy_to
8
+
1
9
  ### 1.21.2 / 2021-01-15
2
10
  * Fixed version mismatch. 1.21.1 was tagged with an incorrect version
3
11
  in version.rb.
@@ -18,27 +18,30 @@ module Simp::BeakerHelpers
18
18
  "simp-beaker-helpers-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}.tmp"
19
19
  end
20
20
 
21
- def install_latest_package_on(sut, package_name, package_source=nil, opts={})
21
+ def install_latest_package_on(suts, package_name, package_source=nil, opts={})
22
22
  default_opts = {
23
23
  max_retries: 3,
24
24
  retry_interval: 10
25
25
  }
26
26
 
27
- package_source = package_name unless package_source
27
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
28
+ block_on(suts, :run_in_parallel => parallel) do |sut|
29
+ package_source = package_name unless package_source
28
30
 
29
- if sut.check_for_package(package_name)
30
- sut.upgrade_package(
31
- package_source,
32
- '',
33
- default_opts.merge(opts)
34
- )
35
- else
36
- sut.install_package(
37
- package_source,
38
- '',
39
- nil,
40
- default_opts.merge(opts)
41
- )
31
+ if sut.check_for_package(package_name)
32
+ sut.upgrade_package(
33
+ package_source,
34
+ '',
35
+ default_opts.merge(opts)
36
+ )
37
+ else
38
+ sut.install_package(
39
+ package_source,
40
+ '',
41
+ nil,
42
+ default_opts.merge(opts)
43
+ )
44
+ end
42
45
  end
43
46
  end
44
47
 
@@ -104,7 +107,30 @@ module Simp::BeakerHelpers
104
107
  else
105
108
  container_id = sut.host_hash[:docker_container_id]
106
109
  end
107
- %x(tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}" | docker exec -i "#{container_id}" tar -C "#{dest}" -xf -)
110
+
111
+ if ENV['BEAKER_docker_cmd']
112
+ docker_cmd = ENV['BEAKER_docker_cmd']
113
+ else
114
+ docker_cmd = 'docker'
115
+
116
+ if ::Docker.version['Components'].any?{|x| x['Name'] =~ /podman/i}
117
+ docker_cmd = 'podman'
118
+
119
+ if ENV['CONTAINER_HOST']
120
+ docker_cmd = 'podman --remote'
121
+ elsif ENV['DOCKER_HOST']
122
+ docker_cmd = "podman --remote --url=#{ENV['DOCKER_HOST']}"
123
+ end
124
+ end
125
+ end
126
+
127
+ unless directory_exists_on(sut, dest)
128
+ dest = File.dirname(dest)
129
+ sut.mkdir_p(dest)
130
+ end
131
+
132
+ %x(tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}" | #{docker_cmd} exec -i "#{container_id}" tar -C "#{dest}" -xf -)
133
+
108
134
  elsif rsync_functional_on?(sut)
109
135
  # This makes rsync_to work like beaker and scp usually do
110
136
  exclude_hack = %(__-__' -L --exclude '__-__)
@@ -142,9 +168,10 @@ module Simp::BeakerHelpers
142
168
  def pfact_on(sut, fact_name)
143
169
  require 'ostruct'
144
170
 
171
+ found_fact = nil
145
172
  # If puppet is not installed, there are no puppet facts to fetch
146
173
  if sut.which('puppet').empty?
147
- fact_on(sut, fact_name, :silent => true)
174
+ found_fact = fact_on(sut, fact_name)
148
175
  else
149
176
  facts_json = nil
150
177
  begin
@@ -163,11 +190,13 @@ module Simp::BeakerHelpers
163
190
 
164
191
  found_fact = facts.dig(*(fact_name.split('.')))
165
192
 
166
- # Fall back to the behavior in fact_on
167
- found_fact = '' if found_fact.nil?
168
-
169
- return found_fact
193
+ # If we did not find a fact, we should use the upstream function since
194
+ # puppet may be installed via a gem or through some other means.
195
+ found_fact = fact_on(sut, fact_name) if found_fact.nil?
170
196
  end
197
+
198
+ # Ensure that Hashes return as Hash objects
199
+ found_fact.is_a?(OpenStruct) ? found_fact.marshal_dump : found_fact
171
200
  end
172
201
 
173
202
  # Returns the modulepath on the SUT, as an Array
@@ -349,13 +378,16 @@ module Simp::BeakerHelpers
349
378
  file_exists_on(sut, '/etc/crypto-policies/config')
350
379
  end
351
380
 
352
- def munge_ssh_crypto_policies(sut, key_types=['ssh-rsa'])
353
- if has_crypto_policies(sut)
354
- install_latest_package_on(sut, 'crypto-policies', nil, :accept_all_exit_codes => true)
381
+ def munge_ssh_crypto_policies(suts, key_types=['ssh-rsa'])
382
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
383
+ block_on(suts, :run_in_parallel => parallel) do |sut|
384
+ if has_crypto_policies(sut)
385
+ install_latest_package_on(sut, 'crypto-policies', nil, :accept_all_exit_codes => true)
355
386
 
356
- # Since we may be doing this prior to having a box flip into FIPS mode, we
357
- # need to find and modify *all* of the affected policies
358
- on( sut, %{sed --follow-symlinks -i 's/\\(HostKeyAlgorithms\\|PubkeyAcceptedKeyTypes\\)\\(.\\)/\\1\\2#{key_types.join(',')},/g' $( grep -L ssh-rsa $( find /etc/crypto-policies /usr/share/crypto-policies -type f -a \\( -name '*.txt' -o -name '*.config' \\) -exec grep -l PubkeyAcceptedKeyTypes {} \\; ) ) })
387
+ # Since we may be doing this prior to having a box flip into FIPS mode, we
388
+ # need to find and modify *all* of the affected policies
389
+ on( sut, %{sed --follow-symlinks -i 's/\\(HostKeyAlgorithms\\|PubkeyAcceptedKeyTypes\\)\\(.\\)/\\1\\2#{key_types.join(',')},/g' $( grep -L ssh-rsa $( find /etc/crypto-policies /usr/share/crypto-policies -type f -a \\( -name '*.txt' -o -name '*.config' \\) -exec grep -l PubkeyAcceptedKeyTypes {} \\; ) ) })
390
+ end
359
391
  end
360
392
  end
361
393
 
@@ -365,7 +397,10 @@ module Simp::BeakerHelpers
365
397
  puts ' -- (use BEAKER_fips=no to disable)'
366
398
  parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
367
399
 
400
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
368
401
  block_on(suts, :run_in_parallel => parallel) do |sut|
402
+ next if sut[:hypervisor] == 'docker'
403
+
369
404
  if is_windows?(sut)
370
405
  puts " -- SKIPPING #{sut} because it is windows"
371
406
  next
@@ -514,155 +549,167 @@ module Simp::BeakerHelpers
514
549
  # Enable EPEL if appropriate to do so and the system is online
515
550
  #
516
551
  # Can be disabled by setting BEAKER_enable_epel=no
517
- def enable_epel_on(sut)
518
- if ONLINE && (ENV['BEAKER_stringify_facts'] != 'no')
519
- os_info = fact_on(sut, 'os')
520
- os_maj_rel = os_info['release']['major']
521
-
522
- # This is based on the official EPEL docs https://fedoraproject.org/wiki/EPEL
523
- if ['RedHat', 'CentOS'].include?(os_info['name'])
524
- install_latest_package_on(
525
- sut,
526
- 'epel-release',
527
- "https://dl.fedoraproject.org/pub/epel/epel-release-latest-#{os_maj_rel}.noarch.rpm",
528
- )
529
-
530
- if os_info['name'] == 'RedHat'
531
- if os_maj_rel == '7'
532
- on sut, %{subscription-manager repos --enable "rhel-*-optional-rpms"}
533
- on sut, %{subscription-manager repos --enable "rhel-*-extras-rpms"}
534
- on sut, %{subscription-manager repos --enable "rhel-ha-for-rhel-*-server-rpms"}
535
- end
552
+ def enable_epel_on(suts)
553
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
554
+ block_on(suts, :run_in_parallel => parallel) do |sut|
555
+ if ONLINE && (ENV['BEAKER_stringify_facts'] != 'no')
556
+ os_info = fact_on(sut, 'os')
557
+ os_maj_rel = os_info['release']['major']
558
+
559
+ # This is based on the official EPEL docs https://fedoraproject.org/wiki/EPEL
560
+ if ['RedHat', 'CentOS'].include?(os_info['name'])
561
+ install_latest_package_on(
562
+ sut,
563
+ 'epel-release',
564
+ "https://dl.fedoraproject.org/pub/epel/epel-release-latest-#{os_maj_rel}.noarch.rpm",
565
+ )
566
+
567
+ if os_info['name'] == 'RedHat'
568
+ if os_maj_rel == '7'
569
+ on sut, %{subscription-manager repos --enable "rhel-*-optional-rpms"}
570
+ on sut, %{subscription-manager repos --enable "rhel-*-extras-rpms"}
571
+ on sut, %{subscription-manager repos --enable "rhel-ha-for-rhel-*-server-rpms"}
572
+ end
536
573
 
537
- if os_maj_rel == '8'
538
- on sut, %{subscription-manager repos --enable "codeready-builder-for-rhel-8-#{os_info['architecture']}-rpms"}
574
+ if os_maj_rel == '8'
575
+ on sut, %{subscription-manager repos --enable "codeready-builder-for-rhel-8-#{os_info['architecture']}-rpms"}
576
+ end
539
577
  end
540
- end
541
578
 
542
- if os_info['name'] == 'CentOS'
543
- if os_maj_rel == '8'
544
- # 8.0 fallback
545
- on sut, %{dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled PowerTools}
579
+ if os_info['name'] == 'CentOS'
580
+ if os_maj_rel == '8'
581
+ # 8.0 fallback
582
+ install_latest_package_on(sut, 'dnf-plugins-core')
583
+ on sut, %{dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled PowerTools}
584
+ end
546
585
  end
547
586
  end
548
587
  end
549
588
  end
550
589
  end
551
590
 
552
- def update_package_from_centos_stream(sut, package_name)
553
- sut.install_package('centos-release-stream') unless sut.check_for_package('centos-release-stream')
554
- install_latest_package_on(sut, package_name)
555
- sut.uninstall_package('centos-release-stream')
591
+ def update_package_from_centos_stream(suts, package_name)
592
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
593
+ block_on(suts, :run_in_parallel => parallel) do |sut|
594
+ sut.install_package('centos-release-stream') unless sut.check_for_package('centos-release-stream')
595
+ install_latest_package_on(sut, package_name)
596
+ sut.uninstall_package('centos-release-stream')
597
+ end
556
598
  end
557
599
 
558
- def linux_errata( sut )
559
- # We need to be able to flip between server and client without issue
560
- on sut, 'puppet resource group puppet gid=52'
561
- on sut, 'puppet resource user puppet comment="Puppet" gid="52" uid="52" home="/var/lib/puppet" managehome=true'
600
+ def linux_errata( suts )
601
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
602
+ block_on(suts, :run_in_parallel => parallel) do |sut|
603
+ # We need to be able to flip between server and client without issue
604
+ on sut, 'puppet resource group puppet gid=52'
605
+ on sut, 'puppet resource user puppet comment="Puppet" gid="52" uid="52" home="/var/lib/puppet" managehome=true'
562
606
 
563
- os_info = fact_on(sut, 'os')
607
+ os_info = fact_on(sut, 'os')
564
608
 
565
- # Make sure we have a domain on our host
566
- current_domain = fact_on(sut, 'domain').strip
567
- hostname = fact_on(sut, 'hostname').strip
609
+ # Make sure we have a domain on our host
610
+ current_domain = fact_on(sut, 'domain').strip
611
+ hostname = fact_on(sut, 'hostname').strip
568
612
 
569
- if current_domain.empty?
570
- new_fqdn = hostname + '.beaker.test'
613
+ if current_domain.empty?
614
+ new_fqdn = hostname + '.beaker.test'
571
615
 
572
- on(sut, "sed -i 's/#{hostname}.*/#{new_fqdn} #{hostname}/' /etc/hosts")
573
- on(sut, "echo '#{new_fqdn}' > /etc/hostname", :accept_all_exit_codes => true)
574
- on(sut, "hostname #{new_fqdn}", :accept_all_exit_codes => true)
616
+ on(sut, "sed -i 's/#{hostname}.*/#{new_fqdn} #{hostname}/' /etc/hosts")
617
+ on(sut, "echo '#{new_fqdn}' > /etc/hostname", :accept_all_exit_codes => true)
618
+ on(sut, "hostname #{new_fqdn}", :accept_all_exit_codes => true)
575
619
 
576
- if sut.file_exist?('/etc/sysconfig/network')
577
- on(sut, "sed -s '/HOSTNAME=/d' /etc/sysconfig/network")
578
- on(sut, "echo 'HOSTNAME=#{new_fqdn}' >> /etc/sysconfig/network")
620
+ if sut.file_exist?('/etc/sysconfig/network')
621
+ on(sut, "sed -s '/HOSTNAME=/d' /etc/sysconfig/network")
622
+ on(sut, "echo 'HOSTNAME=#{new_fqdn}' >> /etc/sysconfig/network")
623
+ end
579
624
  end
580
- end
581
625
 
582
- if fact_on(sut, 'domain').strip.empty?
583
- fail("Error: hosts must have an FQDN, got domain='#{current_domain}'")
584
- end
626
+ if fact_on(sut, 'domain').strip.empty?
627
+ fail("Error: hosts must have an FQDN, got domain='#{current_domain}'")
628
+ end
585
629
 
586
- # This may not exist in docker so just skip the whole thing
587
- if sut.file_exist?('/etc/ssh')
588
- # SIMP uses a central ssh key location so we prep that spot in case we
589
- # flip to the SIMP SSH module.
590
- on(sut, 'mkdir -p /etc/ssh/local_keys')
591
- on(sut, 'chown -R root:root /etc/ssh/local_keys')
592
- on(sut, 'chmod 755 /etc/ssh/local_keys')
593
-
594
- user_info = on(sut, 'getent passwd').stdout.lines
595
-
596
- # Hash of user => home_dir
597
- # Exclude silly directories
598
- # * /
599
- # * /dev/*
600
- # * /s?bin
601
- # * /proc
602
- user_info = Hash[
603
- user_info.map do |u|
604
- u.strip!
605
- u = u.split(':')
606
- u[5] =~ %r{^(/|/dev/.*|/s?bin/?.*|/proc/?.*)$} ? [nil] : [u[0], u[5]]
607
- end
608
- ]
630
+ # This may not exist in docker so just skip the whole thing
631
+ if sut.file_exist?('/etc/ssh')
632
+ # SIMP uses a central ssh key location so we prep that spot in case we
633
+ # flip to the SIMP SSH module.
634
+ on(sut, 'mkdir -p /etc/ssh/local_keys')
635
+ on(sut, 'chown -R root:root /etc/ssh/local_keys')
636
+ on(sut, 'chmod 755 /etc/ssh/local_keys')
637
+
638
+ user_info = on(sut, 'getent passwd').stdout.lines
639
+
640
+ # Hash of user => home_dir
641
+ # Exclude silly directories
642
+ # * /
643
+ # * /dev/*
644
+ # * /s?bin
645
+ # * /proc
646
+ user_info = Hash[
647
+ user_info.map do |u|
648
+ u.strip!
649
+ u = u.split(':')
650
+ u[5] =~ %r{^(/|/dev/.*|/s?bin/?.*|/proc/?.*)$} ? [nil] : [u[0], u[5]]
651
+ end
652
+ ]
609
653
 
610
- user_info.keys.each do |user|
611
- src_file = "#{user_info[user]}/.ssh/authorized_keys"
612
- tgt_file = "/etc/ssh/local_keys/#{user}"
654
+ user_info.keys.each do |user|
655
+ src_file = "#{user_info[user]}/.ssh/authorized_keys"
656
+ tgt_file = "/etc/ssh/local_keys/#{user}"
613
657
 
614
- on(sut, %{if [ -f "#{src_file}" ]; then cp -a -f "#{src_file}" "#{tgt_file}" && chmod 644 "#{tgt_file}"; fi}, :silent => true)
658
+ on(sut, %{if [ -f "#{src_file}" ]; then cp -a -f "#{src_file}" "#{tgt_file}" && chmod 644 "#{tgt_file}"; fi}, :silent => true)
659
+ end
615
660
  end
616
- end
617
661
 
618
- # SIMP uses structured facts, therefore stringify_facts must be disabled
619
- unless ENV['BEAKER_stringify_facts'] == 'yes'
620
- on sut, 'puppet config set stringify_facts false'
621
- end
662
+ # SIMP uses structured facts, therefore stringify_facts must be disabled
663
+ unless ENV['BEAKER_stringify_facts'] == 'yes'
664
+ on sut, 'puppet config set stringify_facts false'
665
+ end
622
666
 
623
- # Occasionally we run across something similar to BKR-561, so to ensure we
624
- # at least have the host defaults:
625
- #
626
- # :hieradatadir is used as a canary here; it isn't the only missing key
627
- unless sut.host_hash.key? :hieradatadir
628
- configure_type_defaults_on(sut)
629
- end
667
+ # Occasionally we run across something similar to BKR-561, so to ensure we
668
+ # at least have the host defaults:
669
+ #
670
+ # :hieradatadir is used as a canary here; it isn't the only missing key
671
+ unless sut.host_hash.key? :hieradatadir
672
+ configure_type_defaults_on(sut)
673
+ end
630
674
 
631
- if os_info['family'] == 'RedHat'
632
- # OS-specific items
633
- if os_info['name'] == 'RedHat'
634
- RSpec.configure do |c|
635
- c.before(:all) do
636
- rhel_rhsm_subscribe(sut)
637
- end
675
+ if os_info['family'] == 'RedHat'
676
+ # OS-specific items
677
+ if os_info['name'] == 'RedHat'
678
+ RSpec.configure do |c|
679
+ c.before(:all) do
680
+ rhel_rhsm_subscribe(sut)
681
+ end
638
682
 
639
- c.after(:all) do
640
- rhel_rhsm_unsubscribe(sut)
683
+ c.after(:all) do
684
+ rhel_rhsm_unsubscribe(sut)
685
+ end
641
686
  end
642
687
  end
643
- end
644
688
 
645
- if ['CentOS','RedHat','OracleLinux'].include?(os_info['name'])
646
- enable_yum_repos_on(sut)
647
- enable_epel_on(sut)
689
+ if ['CentOS','RedHat','OracleLinux'].include?(os_info['name'])
690
+ enable_yum_repos_on(sut)
691
+ enable_epel_on(sut)
648
692
 
649
- # net-tools required for netstat utility being used by be_listening
650
- if os_info['release']['major'].to_i >= 7
651
- pp = <<-EOS
652
- package { 'net-tools': ensure => installed }
653
- EOS
654
- apply_manifest_on(sut, pp, :catch_failures => false)
655
- end
693
+ # net-tools required for netstat utility being used by be_listening
694
+ if os_info['release']['major'].to_i >= 7
695
+ pp = <<-EOS
696
+ package { 'net-tools': ensure => installed }
697
+ EOS
698
+ apply_manifest_on(sut, pp, :catch_failures => false)
699
+ end
656
700
 
657
- if (os_info['name'] == 'CentOS') && (os_info['release']['major'].to_i >= 8)
658
- if os_info['release']['minor'].to_i == 3
659
- update_package_from_centos_stream(sut, 'kernel')
660
- sut.reboot
701
+ unless sut[:hypervisor] == 'docker'
702
+ if (os_info['name'] == 'CentOS') && (os_info['release']['major'].to_i >= 8)
703
+ if os_info['release']['minor'].to_i == 3
704
+ update_package_from_centos_stream(sut, 'kernel')
705
+ sut.reboot
706
+ end
707
+ end
661
708
  end
662
- end
663
709
 
664
- # Clean up YUM prior to starting our test runs.
665
- on(sut, 'yum clean all')
710
+ # Clean up YUM prior to starting our test runs.
711
+ on(sut, 'yum clean all')
712
+ end
666
713
  end
667
714
  end
668
715
  end
@@ -671,85 +718,100 @@ module Simp::BeakerHelpers
671
718
  #
672
719
  # Must set BEAKER_RHSM_USER and BEAKER_RHSM_PASS environment variables or pass them in as
673
720
  # parameters
674
- def rhel_rhsm_subscribe(sut, *opts)
721
+ def rhel_rhsm_subscribe(suts, *opts)
675
722
  require 'securerandom'
676
723
 
677
- rhsm_opts = {
678
- :username => ENV['BEAKER_RHSM_USER'],
679
- :password => ENV['BEAKER_RHSM_PASS'],
680
- :system_name => "#{sut}_beaker_#{Time.now.to_i}_#{SecureRandom.uuid}",
681
- :repo_list => {
682
- '7' => [
683
- 'rhel-7-server-extras-rpms',
684
- 'rhel-7-server-optional-rpms',
685
- 'rhel-7-server-rh-common-rpms',
686
- 'rhel-7-server-rpms',
687
- 'rhel-7-server-supplementary-rpms'
688
- ],
689
- '8' => [
690
- 'rhel-8-for-x86_64-baseos-rpms',
691
- 'rhel-8-for-x86_64-supplementary-rpms'
692
- ]
724
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
725
+ block_on(suts, :run_in_parallel => parallel) do |sut|
726
+ rhsm_opts = {
727
+ :username => ENV['BEAKER_RHSM_USER'],
728
+ :password => ENV['BEAKER_RHSM_PASS'],
729
+ :system_name => "#{sut}_beaker_#{Time.now.to_i}_#{SecureRandom.uuid}",
730
+ :repo_list => {
731
+ '7' => [
732
+ 'rhel-7-server-extras-rpms',
733
+ 'rhel-7-server-optional-rpms',
734
+ 'rhel-7-server-rh-common-rpms',
735
+ 'rhel-7-server-rpms',
736
+ 'rhel-7-server-supplementary-rpms'
737
+ ],
738
+ '8' => [
739
+ 'rhel-8-for-x86_64-baseos-rpms',
740
+ 'rhel-8-for-x86_64-supplementary-rpms'
741
+ ]
742
+ }
693
743
  }
694
- }
695
744
 
696
- if opts && opts.is_a?(Hash)
697
- rhsm_opts.merge!(opts)
698
- end
745
+ if opts && opts.is_a?(Hash)
746
+ rhsm_opts.merge!(opts)
747
+ end
699
748
 
700
- os = fact_on(sut, 'operatingsystem').strip
701
- os_release = fact_on(sut, 'operatingsystemmajrelease').strip
749
+ os = fact_on(sut, 'operatingsystem').strip
750
+ os_release = fact_on(sut, 'operatingsystemmajrelease').strip
702
751
 
703
- if os == 'RedHat'
704
- unless rhsm_opts[:username] && rhsm_opts[:password]
705
- fail("You must set BEAKER_RHSM_USER and BEAKER_RHSM_PASS environment variables to register RHEL systems")
706
- end
752
+ if os == 'RedHat'
753
+ unless rhsm_opts[:username] && rhsm_opts[:password]
754
+ fail("You must set BEAKER_RHSM_USER and BEAKER_RHSM_PASS environment variables to register RHEL systems")
755
+ end
707
756
 
708
- sub_status = on(sut, 'subscription-manager status', :accept_all_exit_codes => true)
709
- unless sub_status.exit_code == 0
710
- logger.info("Registering #{sut} via subscription-manager")
711
- on(sut, %{subscription-manager register --auto-attach --name='#{rhsm_opts[:system_name]}' --username='#{rhsm_opts[:username]}' --password='#{rhsm_opts[:password]}'}, :silent => true)
712
- end
757
+ sub_status = on(sut, 'subscription-manager status', :accept_all_exit_codes => true)
758
+ unless sub_status.exit_code == 0
759
+ logger.info("Registering #{sut} via subscription-manager")
760
+ on(sut, %{subscription-manager register --auto-attach --name='#{rhsm_opts[:system_name]}' --username='#{rhsm_opts[:username]}' --password='#{rhsm_opts[:password]}'}, :silent => true)
761
+ end
713
762
 
714
- if rhsm_opts[:repo_list][os_release]
715
- rhel_repo_enable(sut, rhsm_opts[:repo_list][os_release])
716
- else
717
- logger.warn("simp-beaker-helpers:#{__method__} => Default repos for RHEL '#{os_release}' not found")
718
- end
763
+ if rhsm_opts[:repo_list][os_release]
764
+ rhel_repo_enable(sut, rhsm_opts[:repo_list][os_release])
765
+ else
766
+ logger.warn("simp-beaker-helpers:#{__method__} => Default repos for RHEL '#{os_release}' not found")
767
+ end
719
768
 
720
- # Ensure that all users can access the entitlements since we don't know
721
- # who we'll be running jobs as (often not root)
722
- on(sut, 'chmod -R ugo+rX /etc/pki/entitlement', :accept_all_exit_codes => true)
769
+ # Ensure that all users can access the entitlements since we don't know
770
+ # who we'll be running jobs as (often not root)
771
+ on(sut, 'chmod -R ugo+rX /etc/pki/entitlement', :accept_all_exit_codes => true)
772
+ end
723
773
  end
724
774
  end
725
775
 
726
- def sosreport(sut, dest='sosreports')
727
- install_latest_package_on(sut, 'sos')
728
- on(sut, 'sosreport --batch')
776
+ def sosreport(suts, dest='sosreports')
777
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
778
+ block_on(suts, :run_in_parallel => parallel) do |sut|
779
+ install_latest_package_on(sut, 'sos')
780
+ on(sut, 'sosreport --batch')
729
781
 
730
- files = on(sut, 'ls /var/tmp/sosreport* /tmp/sosreport* 2>/dev/null', :accept_all_exit_codes => true).output.lines.map(&:strip)
782
+ files = on(sut, 'ls /var/tmp/sosreport* /tmp/sosreport* 2>/dev/null', :accept_all_exit_codes => true).output.lines.map(&:strip)
731
783
 
732
- FileUtils.mkdir_p(dest)
784
+ FileUtils.mkdir_p(dest)
733
785
 
734
- files.each do |file|
735
- scp_from(sut, file, File.absolute_path(dest))
786
+ files.each do |file|
787
+ scp_from(sut, file, File.absolute_path(dest))
788
+ end
736
789
  end
737
790
  end
738
791
 
739
- def rhel_repo_enable(sut, repos)
740
- Array(repos).each do |repo|
741
- on(sut, %{subscription-manager repos --enable #{repo}})
792
+ def rhel_repo_enable(suts, repos)
793
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
794
+ block_on(suts, :run_in_parallel => parallel) do |sut|
795
+ Array(repos).each do |repo|
796
+ on(sut, %{subscription-manager repos --enable #{repo}})
797
+ end
742
798
  end
743
799
  end
744
800
 
745
- def rhel_repo_disable(sut, repos)
746
- Array(repos).each do |repo|
747
- on(sut, %{subscription-manager repos --disable #{repo}}, :accept_all_exit_codes => true)
801
+ def rhel_repo_disable(suts, repos)
802
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
803
+ block_on(suts, :run_in_parallel => parallel) do |sut|
804
+ Array(repos).each do |repo|
805
+ on(sut, %{subscription-manager repos --disable #{repo}}, :accept_all_exit_codes => true)
806
+ end
748
807
  end
749
808
  end
750
809
 
751
- def rhel_rhsm_unsubscribe(sut)
752
- on(sut, %{subscription-manager unregister}, :accept_all_exit_codes => true)
810
+ def rhel_rhsm_unsubscribe(suts)
811
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
812
+ block_on(suts, :run_in_parallel => parallel) do |sut|
813
+ on(sut, %{subscription-manager unregister}, :accept_all_exit_codes => true)
814
+ end
753
815
  end
754
816
 
755
817
  # Apply known OS fixes we need to run Beaker on each SUT
@@ -823,6 +885,9 @@ module Simp::BeakerHelpers
823
885
 
824
886
  host_entry = { fqdn => [] }
825
887
 
888
+ # Add the short name because containers can't change the hostname
889
+ host_entry[fqdn] << host.name if (host[:hypervisor] == 'docker')
890
+
826
891
  # Ensure that all interfaces are active prior to collecting data
827
892
  activate_interfaces(host) unless ENV['BEAKER_no_fix_interfaces']
828
893
 
@@ -836,7 +901,7 @@ module Simp::BeakerHelpers
836
901
  host_entry[fqdn] << ipaddress.strip
837
902
 
838
903
  unless host_entry[fqdn].empty?
839
- suts_network_info[fqdn] = host_entry[fqdn]
904
+ suts_network_info[fqdn] = host_entry[fqdn].sort.uniq
840
905
  end
841
906
  end
842
907
  end
@@ -865,6 +930,7 @@ module Simp::BeakerHelpers
865
930
  end
866
931
 
867
932
  copy_to(ca_sut, pki_hosts_file, host_dir)
933
+
868
934
  # generate certs
869
935
  on(ca_sut, "cd #{host_dir}; cat #{host_dir}/pki.hosts | xargs bash make.sh")
870
936
  end
@@ -899,8 +965,8 @@ module Simp::BeakerHelpers
899
965
  sut.mkdir_p("#{sut_pki_dir}/public")
900
966
  sut.mkdir_p("#{sut_pki_dir}/private")
901
967
  sut.mkdir_p("#{sut_pki_dir}/cacerts")
902
- copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pem", "#{sut_pki_dir}/private/")
903
- copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pub", "#{sut_pki_dir}/public/")
968
+ copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pem", "#{sut_pki_dir}/private/")
969
+ copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pub", "#{sut_pki_dir}/public/")
904
970
 
905
971
  copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/simp_auto_ca.pem")
906
972
 
@@ -911,6 +977,7 @@ module Simp::BeakerHelpers
911
977
  # properly! This must happen on the host itself since it needs to match
912
978
  # the native hashing algorithms.
913
979
  hash_cmd = <<~EOM.strip
980
+ PATH=/opt/puppetlabs/puppet/bin:$PATH; \
914
981
  cd #{sut_pki_dir}/cacerts; \
915
982
  for x in *; do \
916
983
  if [ ! -h "$x" ]; then \
@@ -1,5 +1,5 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.21.2'
4
+ VERSION = '1.21.3'
5
5
  end
@@ -0,0 +1,36 @@
1
+ HOSTS:
2
+ el7:
3
+ roles:
4
+ - el7
5
+ - master
6
+ platform: el-7-x86_64
7
+ hypervisor: docker
8
+ image: simpproject/simp_build_centos7
9
+ docker_cmd: '/usr/sbin/sshd -D -E /var/log/sshd.log'
10
+
11
+ el8:
12
+ roles:
13
+ - el8
14
+ platform: el-8-x86_64
15
+ hypervisor: docker
16
+ image: simpproject/simp_build_centos8
17
+ docker_cmd: '["/sbin/init"]'
18
+
19
+ CONFIG:
20
+ docker_preserve_image: true
21
+ log_level: verbose
22
+ type: aio
23
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
24
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
25
+ <% end -%>
26
+ ssh:
27
+ keepalive: true
28
+ keepalive_interval: 10
29
+ host_key:
30
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:host_key].join("\n#{' '*6}- ") %>
31
+ kex:
32
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:kex].join("\n#{' '*6}- ") %>
33
+ encryption:
34
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:encryption].join("\n#{' '*6}- ") %>
35
+ hmac:
36
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:hmac].join("\n#{' '*6}- ") %>
@@ -5,7 +5,7 @@ hosts.each do |host|
5
5
  context "on #{host}" do
6
6
  puppet_collection = host.options[:puppet_collection]
7
7
 
8
- client_puppet_version = on(host, 'puppet --version').output.strip
8
+ client_puppet_version = on(host, 'puppet --version').stdout.strip
9
9
 
10
10
  if puppet_collection =~ /puppet(\d+)/
11
11
  puppet_collection_version = $1
@@ -37,4 +37,10 @@ context 'after copy_fixture_modules_to( hosts )' do
37
37
  expect(pfact_on(master, 'fips_enabled')).to eq expected
38
38
  end
39
39
  end
40
+
41
+ describe "pfact_on returns a hash" do
42
+ it 'should return a Hash' do
43
+ expect(pfact_on(master, 'os')).to be_a(Hash)
44
+ end
45
+ end
40
46
  end
@@ -1 +1 @@
1
- ../../nodesets
1
+ spec/acceptance/suites/default/../../nodesets
@@ -1 +1 @@
1
- ../../nodesets
1
+ spec/acceptance/suites/fips_from_fixtures/../../nodesets
@@ -1 +1 @@
1
- ../../nodesets
1
+ spec/acceptance/suites/snapshot/../../nodesets
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.2
4
+ version: 1.21.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
8
8
  - Trevor Vaughan
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-15 00:00:00.000000000 Z
12
+ date: 2021-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker
@@ -188,6 +188,7 @@ files:
188
188
  - lib/simp/rake/beaker.rb
189
189
  - simp-beaker-helpers.gemspec
190
190
  - spec/acceptance/nodesets/default.yml
191
+ - spec/acceptance/nodesets/docker.yml
191
192
  - spec/acceptance/nodesets/ubuntu.yml
192
193
  - spec/acceptance/suites/default/check_puppet_version_spec.rb
193
194
  - spec/acceptance/suites/default/enable_fips_spec.rb
@@ -221,7 +222,7 @@ licenses:
221
222
  - Apache-2.0
222
223
  metadata:
223
224
  issue_tracker: https://simp-project.atlassian.net
224
- post_install_message:
225
+ post_install_message:
225
226
  rdoc_options: []
226
227
  require_paths:
227
228
  - lib
@@ -236,12 +237,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
237
  - !ruby/object:Gem::Version
237
238
  version: '0'
238
239
  requirements: []
239
- rubygems_version: 3.0.9
240
- signing_key:
240
+ rubyforge_project:
241
+ rubygems_version: 2.7.10
242
+ signing_key:
241
243
  specification_version: 4
242
244
  summary: beaker helper methods for SIMP
243
245
  test_files:
244
246
  - spec/acceptance/nodesets/default.yml
247
+ - spec/acceptance/nodesets/docker.yml
245
248
  - spec/acceptance/nodesets/ubuntu.yml
246
249
  - spec/acceptance/suites/default/check_puppet_version_spec.rb
247
250
  - spec/acceptance/suites/default/enable_fips_spec.rb