simp-beaker-helpers 1.18.9 → 1.19.0

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: 6af360e25b0c27681121e57724c9440c886489aab74d9bff7a96f32a2fb1805d
4
- data.tar.gz: b9e0ea633c7e5a274e868abd4203fc3c02861a396f043cdc6c682ca550beacfd
3
+ metadata.gz: 658d1ab2cfb6ff32a020283a3a754fd3d8d4eb50cc73b73286422ea5178d48d3
4
+ data.tar.gz: b6a7d451700d8ac207905a20014c405f2aa06731f281720dec6a49cae5d34d33
5
5
  SHA512:
6
- metadata.gz: 0430e3ab6942bc368478f64dfb8243d76975e25e48d78965d52c7c22b916c80c7ad509af4b63a646dad92d87587e6e5dcdf0a4650b6495e4c3e6138daa05c387
7
- data.tar.gz: e357315e04adadc555cb3ba8819e1a082c460a6c93c5842e3aa235c1d88faded4c2dea547b29c05689e5eb84de3ce76742d248c2645905f5756b9ddafd58592b
6
+ metadata.gz: 13d63f19f099f8ca503d447cf41d150c3d74710c9ceca8a1b7c8dad655d783bd534cc117dc326235b6eb4e7ef6306b1ba6864df0c8add83eaad1737d48cdbf38
7
+ data.tar.gz: fe95f26b05dfaeff5be470af3c79d3cb3d7a5fc82ac7dde590f5770647d8b058774cfbc8691a00c3323c4ad85608cac7085b0764f4293e68daec6a6889669af4
@@ -1,3 +1,12 @@
1
+ ### 1.19.0 / 2020-09-30
2
+ * Fixed:
3
+ * rsync handling has a better check to see if rsync actually works prior to
4
+ using it. The old method had the potential to try and use rsync even if it
5
+ no longer worked (FIPS flipped for example).
6
+ * Changed:
7
+ * Migrated from PackageCloud to the SIMP download server for updates moving
8
+ forward.
9
+
1
10
  ### 1.18.9 / 2020-08-04
2
11
  * Change windows 2012r2 VM to work around issues where the old image had
3
12
  duplicate ports trying to be opened
@@ -30,16 +30,38 @@ module Simp::BeakerHelpers
30
30
  ).output.strip == '1'
31
31
  end
32
32
 
33
+ def rsync_functional_on?(sut)
34
+ # We have to check if rsync *still* works otherwise
35
+ return false if (@rsync_functional == false)
36
+
37
+ require 'facter'
38
+ unless Facter::Util::Resolution.which('rsync')
39
+ @rsync_functional = false
40
+ return @rsync_functional
41
+ end
42
+
43
+ require 'tempfile'
44
+
45
+ testfile = Tempfile.new('rsync_check')
46
+ testfile.puts('test')
47
+ testfile.close
48
+
49
+ begin
50
+ rsync_to(sut, testfile.path, sut.system_temp_path)
51
+ rescue Beaker::Host::CommandFailure
52
+ @rsync_functional = false
53
+ return false
54
+ ensure
55
+ testfile.unlink
56
+ end
57
+
58
+ return true
59
+ end
60
+
33
61
  # Figure out the best method to copy files to a host and use it
34
62
  #
35
63
  # Will create the directories leading up to the target if they don't exist
36
64
  def copy_to(sut, src, dest, opts={})
37
- unless fips_enabled(sut) || @has_rsync
38
- %x{which rsync 2>/dev/null}.strip
39
-
40
- @has_rsync = !$?.nil? && $?.success?
41
- end
42
-
43
65
  sut.mkdir_p(File.dirname(dest))
44
66
 
45
67
  if sut[:hypervisor] == 'docker'
@@ -57,7 +79,7 @@ module Simp::BeakerHelpers
57
79
  container_id = sut.host_hash[:docker_container_id]
58
80
  end
59
81
  %x(tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}" | docker exec -i "#{container_id}" tar -C "#{dest}" -xf -)
60
- elsif @has_rsync && sut.check_for_command('rsync')
82
+ elsif rsync_functional_on?(sut)
61
83
  # This makes rsync_to work like beaker and scp usually do
62
84
  exclude_hack = %(__-__' -L --exclude '__-__)
63
85
 
@@ -584,7 +606,7 @@ module Simp::BeakerHelpers
584
606
  end
585
607
 
586
608
  def sosreport(sut, dest='sosreports')
587
- sut.install_package('sos')
609
+ on(sut, 'puppet resource package sos ensure=latest')
588
610
  on(sut, 'sosreport --batch')
589
611
 
590
612
  files = on(sut, 'ls /var/tmp/sosreport* /tmp/sosreport* 2>/dev/null', :accept_all_exit_codes => true).output.lines.map(&:strip)
@@ -1170,62 +1192,70 @@ done
1170
1192
  run_puppet_install_helper(install_info[:puppet_install_type], install_info[:puppet_install_version])
1171
1193
  end
1172
1194
 
1173
- # Configure all SIMP repos on a host and enable all but those listed in the disable list
1195
+ # Configure all SIMP repos on a host and disable all repos in the disable Array
1174
1196
  #
1175
- # @param sut Host on which to configure SIMP repos
1176
- # @param disable List of SIMP repos to disable
1177
- # @raise if disable contains an invalid repo name.
1197
+ # @param sut [Beaker::Host] Host on which to configure SIMP repos
1198
+ # @param disable [Array[String]] List of repos to disable
1199
+ # @raise [StandardError] if disable contains an invalid repo name.
1178
1200
  #
1179
1201
  # Examples:
1180
1202
  # install_simp_repos( myhost ) # install all the repos an enable them.
1181
1203
  # install_simp_repos( myhost, ['simp']) # install the repos but disable the simp repo.
1182
1204
  #
1183
- # Current set of valid SIMP repo names:
1184
- # 'simp'
1185
- # 'simp_deps'
1205
+ # Valid repo names include any repository available on the system.
1186
1206
  #
1187
- def install_simp_repos(sut, disable = [] )
1188
- repos = {
1189
- 'simp' => {
1190
- :baseurl => 'https://packagecloud.io/simp-project/6_X/el/$releasever/$basearch',
1191
- :gpgkey => ['https://raw.githubusercontent.com/NationalSecurityAgency/SIMP/master/GPGKEYS/RPM-GPG-KEY-SIMP',
1192
- 'https://download.simp-project.com/simp/GPGKEYS/RPM-GPG-KEY-SIMP-6'
1193
- ],
1194
- :gpgcheck => 1,
1195
- :sslverify => 1,
1196
- :sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
1197
- :metadata_expire => 300
1198
- },
1199
- 'simp_deps' => {
1200
- :baseurl => 'https://packagecloud.io/simp-project/6_X_Dependencies/el/$releasever/$basearch',
1201
- :gpgkey => ['https://raw.githubusercontent.com/NationalSecurityAgency/SIMP/master/GPGKEYS/RPM-GPG-KEY-SIMP',
1202
- 'https://download.simp-project.com/simp/GPGKEYS/RPM-GPG-KEY-SIMP-6',
1203
- 'https://yum.puppet.com/RPM-GPG-KEY-puppetlabs',
1204
- 'https://yum.puppet.com/RPM-GPG-KEY-puppet',
1205
- 'https://apt.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-96',
1206
- 'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
1207
- 'https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana',
1208
- 'https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-$releasever'
1209
- ],
1210
- :gpgcheck => 1,
1211
- :sslverify => 1,
1212
- :sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
1213
- :metadata_expire => 300
1214
- }
1215
- }
1216
- # Verify that the repos passed to disable are in the list of valid repos
1217
- disable.each { |d|
1218
- unless repos.has_key?(d)
1219
- raise("ERROR: install_simp_repo - disable contains invalid SIMP repo '#{d}'.")
1207
+ # For backwards compatibility purposes, the following translations are
1208
+ # automatically performed:
1209
+ #
1210
+ # * 'simp'
1211
+ # * 'simp-community-simp'
1212
+ #
1213
+ # * 'simp_deps'
1214
+ # * 'simp-community-epel'
1215
+ # * 'simp-community-postgres'
1216
+ # * 'simp-community-puppet'
1217
+ #
1218
+ def install_simp_repos(sut, disable = [])
1219
+ # NOTE: Do *NOT* use puppet in this method since it may not be available yet
1220
+
1221
+ if on(sut, 'rpm -q yum-utils', :accept_all_exit_codes => true).exit_code != 0
1222
+ on(sut, 'yum -y install yum-utils')
1223
+ end
1224
+
1225
+ if on(sut, 'rpm -q simp-release-community', :accept_all_exit_codes => true).exit_code != 0
1226
+ on(sut, 'yum -y install "https://download.simp-project.com/simp-release-community.rpm"')
1227
+ end
1228
+
1229
+ to_disable = disable.dup
1230
+
1231
+ unless to_disable.empty?
1232
+ if to_disable.include?('simp')
1233
+ to_disable.delete('simp')
1234
+ to_disable << 'simp-community-simp'
1220
1235
  end
1221
- }
1222
- repo_manifest = ''
1223
- repos.each { | repo, metadata|
1224
- metadata[:enabled] = disable.include?(repo) ? 0 : 1
1225
- repo_manifest << create_yum_resource(repo, metadata)
1226
- }
1227
- apply_manifest_on(sut, repo_manifest, :catch_failures => true)
1228
- end
1229
- end
1230
1236
 
1237
+ if to_disable.include?('simp_deps')
1238
+ to_disable.delete('simp_deps')
1239
+ to_disable << 'simp-community-epel'
1240
+ to_disable << 'simp-community-postgres'
1241
+ to_disable << 'simp-community-puppet'
1242
+ end
1231
1243
 
1244
+ # NOTE: This --enablerepo enables the repos for listing and is inherited
1245
+ # from YUM. This does not actually "enable" the repos, that would require
1246
+ # the "--enable" option (from yum-config-manager) :-D.
1247
+ available_repos = on(sut, %{yum-config-manager --enablerepo="*"}).stdout.lines.grep(/\A\[(.+)\]\Z/){|x| $1}
1248
+
1249
+ invalid_repos = (to_disable - available_repos)
1250
+
1251
+ # Verify that the repos passed to disable are in the list of valid repos
1252
+ unless invalid_repos.empty?
1253
+ logger.warn(%{WARN: install_simp_repo - requested repos to disable do not exist on the target system '#{invalid_repos.join("', '")}'.})
1254
+ end
1255
+
1256
+ (to_disable - invalid_repos).each do |repo|
1257
+ on(sut, %{yum-config-manager --disable "#{repo}"})
1258
+ end
1259
+ end
1260
+ end
1261
+ end
@@ -1,5 +1,5 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.18.9'
4
+ VERSION = '1.19.0'
5
5
  end
@@ -2,42 +2,36 @@ require 'spec_helper_acceptance'
2
2
 
3
3
  hosts.each do |host|
4
4
  describe '#write_hieradata_to' do
5
+ expect_failures = false
6
+ if hosts_with_role(hosts, 'el8').include?(host)
7
+ expect_failures = true
8
+ end
5
9
 
6
10
  it 'should install yum utils' do
7
11
  host.install_package('yum-utils')
8
12
  end
9
13
 
10
- context 'defailt settings' do
14
+ context 'default settings' do
11
15
  before(:all) { install_simp_repos(host) }
12
16
 
13
- it 'creates the repo' do
14
- on host, 'test -f /etc/yum.repos.d/simp.repo'
15
- on host, 'test -f /etc/yum.repos.d/simp_deps.repo'
16
- end
17
-
18
17
  it 'enables the correct repos' do
19
- simp6info = on(host, '/usr/bin/yum repolist -v simp | grep ^Repo-status').stdout.strip
20
- expect(simp6info).to match(/.*Repo-status.*enabled.*/)
21
- simp6depsinfo = on(host, 'yum repolist -v simp_deps| grep ^Repo-status').stdout.strip
22
- expect(simp6depsinfo).to match(/.*Repo-status.*enabled.*/)
18
+ skip "#{host} is not supported yet" if expect_failures
19
+ on(host, 'yum -y list simp')
20
+ on(host, 'yum -y list postgresql96')
23
21
  end
24
22
  end
25
23
 
26
24
  context 'when passed a disabled list ' do
27
- before(:all) { install_simp_repos(host, ['simp'] ) }
25
+ before(:all) { install_simp_repos(host, ['simp-community-simp'] ) }
28
26
 
29
- it 'creates the repo' do
30
- on host, 'test -f /etc/yum.repos.d/simp.repo'
31
- on host, 'test -f /etc/yum.repos.d/simp_deps.repo'
27
+ it 'enables the correct repos' do
28
+ skip "#{host} is not supported yet" if expect_failures
29
+ on(host, 'yum -y list postgresql96')
32
30
  end
33
31
 
34
- it 'enables the correct repos' do
35
- simp6info = on(host, 'yum repolist -v simp | grep ^Repo-status').stdout.strip
36
- expect(simp6info).to match(/.*Repo-status.*disabled.*/)
37
- simp6depsinfo = on(host, 'yum repolist -v simp_deps| grep ^Repo-status').stdout.strip
38
- expect(simp6depsinfo).to match(/.*Repo-status.*enabled.*/)
32
+ it 'disables the correct repos' do
33
+ on(host, 'yum -y list simp', :acceptable_exit_codes => [1])
39
34
  end
40
35
  end
41
-
42
36
  end
43
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.9
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-25 00:00:00.000000000 Z
12
+ date: 2020-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker