simp-beaker-helpers 1.13.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/simp/beaker_helpers.rb +89 -30
- data/lib/simp/beaker_helpers/version.rb +1 -1
- data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +43 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4a7b9000c37c88b4151d82a3fdea8cdc75c2300ba994a5070605b37d4dca1d8
|
4
|
+
data.tar.gz: c38e03db1419d9b56493655de5e304d796dbe8a85c5f98c3f2a5d62b49eb72e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7224ee90b064a2ce1dc12550e15f1ec7c77d60dd59d7c7679a9649e734dfaf4df1d0365aaa70b4d72e0518cda3f67c63c84290ef5468fbc7cb3e51568991ed5e
|
7
|
+
data.tar.gz: f16f0db7a9e546f9d30933f2e05c751ead09654bcd7c976c28f862e93ca09866dd1f739a3a630625e7a64f6b6e22f3f3bfacb82f3bb64f4decb0523edbce7cb7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 1.14.0 / 2019-04-08
|
2
|
+
* Added function, install_simp_repo, to install the simp online repos.
|
3
|
+
The repos are defined in a hash in the function. All the repos
|
4
|
+
will be configured and enabled. To disable one or more of them pass
|
5
|
+
in an array of names of the repos to disable.
|
6
|
+
|
1
7
|
### 1.13.1 / 2019-02-02
|
2
8
|
* Ensure that SUTs have an FQDN set and not just a short hostname
|
3
9
|
* Work around issue where the SSG doesn't build the STIG for CentOS any longer.
|
data/lib/simp/beaker_helpers.rb
CHANGED
@@ -294,7 +294,6 @@ module Simp::BeakerHelpers
|
|
294
294
|
end
|
295
295
|
end
|
296
296
|
|
297
|
-
|
298
297
|
# Collect all 'yum_repos' entries from the host nodeset.
|
299
298
|
# The acceptable format is as follows:
|
300
299
|
# yum_repos:
|
@@ -304,6 +303,19 @@ module Simp::BeakerHelpers
|
|
304
303
|
# - <URL to GPGKEY1>
|
305
304
|
# - <URL to GPGKEY2>
|
306
305
|
def enable_yum_repos_on( suts = hosts )
|
306
|
+
parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
|
307
|
+
block_on(suts, :run_in_parallel => parallel) do |sut|
|
308
|
+
if sut['yum_repos']
|
309
|
+
sut['yum_repos'].each_pair do |repo, metadata|
|
310
|
+
repo_manifest = create_yum_resource( repo, metadata)
|
311
|
+
|
312
|
+
apply_manifest_on(sut, repo_manifest, :catch_failures => true)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def create_yum_resource( repo, metadata )
|
307
319
|
repo_attrs = [
|
308
320
|
:assumeyes,
|
309
321
|
:bandwidth,
|
@@ -344,38 +356,29 @@ module Simp::BeakerHelpers
|
|
344
356
|
:timeout
|
345
357
|
]
|
346
358
|
|
347
|
-
|
348
|
-
block_on(suts, :run_in_parallel => parallel) do |sut|
|
349
|
-
if sut['yum_repos']
|
350
|
-
sut['yum_repos'].each_pair do |repo, metadata|
|
351
|
-
repo_manifest = %(yumrepo { #{repo}:)
|
352
|
-
|
353
|
-
repo_manifest_opts = []
|
354
|
-
|
355
|
-
# Legacy Support
|
356
|
-
urls = !metadata[:url].nil? ? metadata[:url] : metadata[:baseurl]
|
357
|
-
if urls
|
358
|
-
repo_manifest_opts << 'baseurl => ' + '"' + Array(urls).flatten.join('\n ').gsub('$','\$') + '"'
|
359
|
-
end
|
359
|
+
repo_manifest = %(yumrepo { #{repo}:)
|
360
360
|
|
361
|
-
|
362
|
-
gpgkeys = !metadata[:gpgkeys].nil? ? metadata[:gpgkeys] : metadata[:gpgkey]
|
363
|
-
if gpgkeys
|
364
|
-
repo_manifest_opts << 'gpgkey => ' + '"' + Array(gpgkeys).flatten.join('\n ').gsub('$','\$') + '"'
|
365
|
-
end
|
361
|
+
repo_manifest_opts = []
|
366
362
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
363
|
+
# Legacy Support
|
364
|
+
urls = !metadata[:url].nil? ? metadata[:url] : metadata[:baseurl]
|
365
|
+
if urls
|
366
|
+
repo_manifest_opts << 'baseurl => ' + '"' + Array(urls).flatten.join('\n ').gsub('$','\$') + '"'
|
367
|
+
end
|
372
368
|
|
373
|
-
|
369
|
+
# Legacy Support
|
370
|
+
gpgkeys = !metadata[:gpgkeys].nil? ? metadata[:gpgkeys] : metadata[:gpgkey]
|
371
|
+
if gpgkeys
|
372
|
+
repo_manifest_opts << 'gpgkey => ' + '"' + Array(gpgkeys).flatten.join('\n ').gsub('$','\$') + '"'
|
373
|
+
end
|
374
374
|
|
375
|
-
|
375
|
+
repo_attrs.each do |attr|
|
376
|
+
if metadata[attr]
|
377
|
+
repo_manifest_opts << "#{attr} => '#{metadata[attr]}'"
|
376
378
|
end
|
377
379
|
end
|
378
|
-
|
380
|
+
|
381
|
+
repo_manifest = repo_manifest + %(\n#{repo_manifest_opts.join(",\n")}) + "\n}\n"
|
379
382
|
end
|
380
383
|
|
381
384
|
def linux_errata( sut )
|
@@ -562,7 +565,6 @@ module Simp::BeakerHelpers
|
|
562
565
|
end
|
563
566
|
end
|
564
567
|
|
565
|
-
|
566
568
|
# Copy a single SUT's PKI certs (with cacerts) onto an SUT.
|
567
569
|
#
|
568
570
|
# This simulates the result of pki::copy
|
@@ -656,7 +658,6 @@ done
|
|
656
658
|
end
|
657
659
|
end
|
658
660
|
|
659
|
-
|
660
661
|
## Inline Hiera Helpers ##
|
661
662
|
## These will be integrated into core Beaker at some point ##
|
662
663
|
|
@@ -681,7 +682,6 @@ done
|
|
681
682
|
end
|
682
683
|
end
|
683
684
|
|
684
|
-
|
685
685
|
# Writes a YAML file in the Hiera :datadir of a Beaker::Host.
|
686
686
|
#
|
687
687
|
# @note This is useless unless Hiera is configured to use the data file.
|
@@ -946,4 +946,63 @@ done
|
|
946
946
|
|
947
947
|
run_puppet_install_helper(install_info[:puppet_install_type], install_info[:puppet_install_version])
|
948
948
|
end
|
949
|
+
|
950
|
+
# Configure all SIMP repos on a host and enable all but those listed in the disable list
|
951
|
+
#
|
952
|
+
# @param sut Host on which to configure SIMP repos
|
953
|
+
# @param disable List of SIMP repos to disable
|
954
|
+
# @raise if disable contains an invalid repo name.
|
955
|
+
#
|
956
|
+
# Examples:
|
957
|
+
# install_simp_repos( myhost ) # install all the repos an enable them.
|
958
|
+
# install_simp_repos( myhost, ['simp']) # install the repos but disable the simp repo.
|
959
|
+
#
|
960
|
+
# Current set of valid SIMP repo names:
|
961
|
+
# 'simp'
|
962
|
+
# 'simp_deps'
|
963
|
+
#
|
964
|
+
def install_simp_repos(sut, disable = [] )
|
965
|
+
|
966
|
+
repos = {
|
967
|
+
'simp' => {
|
968
|
+
:baseurl => 'https://packagecloud.io/simp-project/6_X/el/$releasever/$basearch',
|
969
|
+
:gpgkey => ['https://raw.githubusercontent.com/NationalSecurityAgency/SIMP/master/GPGKEYS/RPM-GPG-KEY-SIMP',
|
970
|
+
'https://download.simp-project.com/simp/GPGKEYS/RPM-GPG-KEY-SIMP-6'
|
971
|
+
],
|
972
|
+
:gpgcheck => 1,
|
973
|
+
:sslverify => 1,
|
974
|
+
:sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
|
975
|
+
:metadata_expire => 300
|
976
|
+
},
|
977
|
+
'simp_deps' => {
|
978
|
+
:baseurl => 'https://packagecloud.io/simp-project/6_X_Dependencies/el/$releasever/$basearch',
|
979
|
+
:gpgkey => ['https://raw.githubusercontent.com/NationalSecurityAgency/SIMP/master/GPGKEYS/RPM-GPG-KEY-SIMP',
|
980
|
+
'https://yum.puppet.com/RPM-GPG-KEY-puppetlabs',
|
981
|
+
'https://yum.puppet.com/RPM-GPG-KEY-puppet',
|
982
|
+
'https://apt.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-96',
|
983
|
+
'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
|
984
|
+
'https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana',
|
985
|
+
'https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-$releasever'
|
986
|
+
],
|
987
|
+
:gpgcheck => 1,
|
988
|
+
:sslverify => 1,
|
989
|
+
:sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
|
990
|
+
:metadata_expire => 300
|
991
|
+
}
|
992
|
+
}
|
993
|
+
# Verify that the repos passed to disable are in the list of valid repos
|
994
|
+
disable.each { |d|
|
995
|
+
unless repos.has_key?(d)
|
996
|
+
raise("ERROR: install_simp_repo - disable contains invalid SIMP repo '#{d}'.")
|
997
|
+
end
|
998
|
+
}
|
999
|
+
repo_manifest = ''
|
1000
|
+
repos.each { | repo, metadata|
|
1001
|
+
metadata[:enabled] = disable.include?(repo) ? 0 : 1
|
1002
|
+
repo_manifest << create_yum_resource(repo, metadata)
|
1003
|
+
}
|
1004
|
+
apply_manifest_on(sut, repo_manifest, :catch_failures => true)
|
1005
|
+
end
|
949
1006
|
end
|
1007
|
+
|
1008
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
|
3
|
+
hosts.each do |host|
|
4
|
+
describe '#write_hieradata_to' do
|
5
|
+
|
6
|
+
it 'should install yum utils' do
|
7
|
+
host.install_package('yum-utils')
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'defailt settings' do
|
11
|
+
before(:all) { install_simp_repos(host) }
|
12
|
+
|
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
|
+
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.*/)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when passed a disabled list ' do
|
27
|
+
before(:all) { install_simp_repos(host, ['simp'] ) }
|
28
|
+
|
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'
|
32
|
+
end
|
33
|
+
|
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.*/)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
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.
|
4
|
+
version: 1.14.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: 2019-
|
12
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beaker
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- spec/acceptance/suites/default/check_puppet_version_spec.rb
|
170
170
|
- spec/acceptance/suites/default/enable_fips_spec.rb
|
171
171
|
- spec/acceptance/suites/default/fixture_modules_spec.rb
|
172
|
+
- spec/acceptance/suites/default/install_simp_deps_repo_spec.rb
|
172
173
|
- spec/acceptance/suites/default/nodesets
|
173
174
|
- spec/acceptance/suites/default/pki_tests_spec.rb
|
174
175
|
- spec/acceptance/suites/default/set_hieradata_on_spec.rb
|