simp-beaker-helpers 1.8.3 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/simp/beaker_helpers/inspec.rb +2 -10
- data/lib/simp/beaker_helpers/ssg.rb +1 -1
- data/lib/simp/beaker_helpers/version.rb +1 -1
- data/lib/simp/beaker_helpers.rb +51 -19
- metadata +4 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74893a8d275ad181e28f562775399df8dcddaaa2
|
4
|
+
data.tar.gz: 52d6f7397bdf03fa1d76647816686fcb522ce47e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08a07f6733d21f52af60991cb5d5325cf0db75a441220c9a0e8164b47f2ec350a27dcf523c6a66faad2a1c1b20430fe3e9f96cca20120088a109cd9665f6986d
|
7
|
+
data.tar.gz: 37e6e038510a9551cd93974527f1f0a67921e191c5177d0aabb83df1ac00e4c506d3d6a83f2baa74749cf7f37e071fb3b505d264c476354e8fa08d165b8428d3
|
@@ -42,18 +42,10 @@ module Simp::BeakerHelpers
|
|
42
42
|
|
43
43
|
@result_file = File.join(output_dir, "#{@sut.hostname}-inspec-#{Time.now.to_i}")
|
44
44
|
|
45
|
-
|
46
|
-
%x(docker cp -L "#{local_profile}" "#{@sut.hostname}:#{@test_dir}")
|
47
|
-
else
|
48
|
-
scp_to(@sut, local_profile, @test_dir)
|
49
|
-
end
|
45
|
+
copy_to(@sut, local_profile, @profile_dir)
|
50
46
|
|
51
47
|
if File.exist?(local_deps)
|
52
|
-
|
53
|
-
%x(docker cp -L "#{local_deps}" "#{@sut.hostname}:#{@deps_root}")
|
54
|
-
else
|
55
|
-
scp_to(@sut, local_deps, @deps_root)
|
56
|
-
end
|
48
|
+
copy_to(@sut, local_deps, @deps_root)
|
57
49
|
end
|
58
50
|
|
59
51
|
# The results of the inspec scan in Hash form
|
@@ -132,7 +132,7 @@ module Simp::BeakerHelpers
|
|
132
132
|
ssg_release ||= Dir.glob('spec/fixtures/ssg_releases/*.bz2').last
|
133
133
|
|
134
134
|
if ssg_release
|
135
|
-
|
135
|
+
copy_to(@sut, ssg_release, @scap_working_dir)
|
136
136
|
|
137
137
|
on(@sut, %(mkdir -p scap-security-guide && tar -xj -C scap-security-guide --strip-components 1 -f #{ssg_release} && cp scap-security-guide/*ds.xml #{@scap_working_dir}))
|
138
138
|
else
|
data/lib/simp/beaker_helpers.rb
CHANGED
@@ -11,6 +11,34 @@ module Simp::BeakerHelpers
|
|
11
11
|
# oldest system that we support.
|
12
12
|
DEFAULT_PUPPET_AGENT_VERSION = '1.7.1'
|
13
13
|
|
14
|
+
# Figure out the best method to copy files to a host and use it
|
15
|
+
#
|
16
|
+
# Will create the directories leading up to the target if they don't exist
|
17
|
+
def copy_to(sut, src, dest, opts={})
|
18
|
+
unless @has_rsync
|
19
|
+
%x{which rsync 2>/dev/null}.strip
|
20
|
+
|
21
|
+
@has_rsync = $?.success?
|
22
|
+
end
|
23
|
+
|
24
|
+
sut.mkdir_p(File.dirname(dest))
|
25
|
+
|
26
|
+
if sut[:hypervisor] == 'docker'
|
27
|
+
exclude_list = []
|
28
|
+
if opts.has_key?(:ignore) && !opts[:ignore].empty?
|
29
|
+
opts[:ignore].each do |value|
|
30
|
+
exclude_list << "--exclude '#{value}'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
%x(tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}" | docker exec -i "#{sut.hostname}" tar -C "#{dest}" -xf -)
|
35
|
+
elsif @has_rsync
|
36
|
+
rsync_to(sut, src, dest, opts)
|
37
|
+
else
|
38
|
+
scp_to(sut, src, dest, opts)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
14
42
|
# use the `puppet fact` face to look up facts on an SUT
|
15
43
|
def pfact_on(sut, fact_name)
|
16
44
|
facts_json = on(sut,'puppet facts find xxx').output
|
@@ -121,19 +149,21 @@ module Simp::BeakerHelpers
|
|
121
149
|
mod_root = File.expand_path( "spec/fixtures/modules", File.dirname( fixtures_yml_path ))
|
122
150
|
|
123
151
|
Dir.chdir(mod_root) do
|
124
|
-
|
125
|
-
|
126
|
-
excludes = PUPPET_MODULE_INSTALL_IGNORE.map do |x|
|
127
|
-
x = "--exclude '*/#{x}'"
|
128
|
-
end.join(' ')
|
152
|
+
begin
|
153
|
+
tarfile = Dir::Tmpname.make_tmpname(['beaker','.tar'],nil)
|
129
154
|
|
130
|
-
|
155
|
+
excludes = PUPPET_MODULE_INSTALL_IGNORE.map do |x|
|
156
|
+
x = "--exclude '*/#{x}'"
|
157
|
+
end.join(' ')
|
131
158
|
|
132
|
-
|
159
|
+
%x(tar -ch #{excludes} -f #{tarfile} *)
|
133
160
|
|
134
|
-
|
161
|
+
copy_to(sut, tarfile, target_module_path, opts)
|
135
162
|
|
136
|
-
|
163
|
+
on(sut, "cd #{target_module_path} && tar -xf #{File.basename(tarfile)}")
|
164
|
+
ensure
|
165
|
+
FileUtils.remove_entry(tarfile, true)
|
166
|
+
end
|
137
167
|
end
|
138
168
|
end
|
139
169
|
end
|
@@ -351,14 +381,14 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
|
|
351
381
|
host_dir = '/root/pki'
|
352
382
|
fqdns = fact_on(hosts, 'fqdn')
|
353
383
|
|
354
|
-
|
355
|
-
Dir[ File.join(pki_dir, '*') ].each{|f|
|
384
|
+
ca_sut.mkdir_p(host_dir)
|
385
|
+
Dir[ File.join(pki_dir, '*') ].each{|f| copy_to( ca_sut, f, host_dir)}
|
356
386
|
|
357
387
|
# generate PKI certs for each SUT
|
358
388
|
Dir.mktmpdir do |dir|
|
359
389
|
pki_hosts_file = File.join(dir, 'pki.hosts')
|
360
390
|
File.open(pki_hosts_file, 'w'){|fh| fqdns.each{|fqdn| fh.puts fqdn}}
|
361
|
-
|
391
|
+
copy_to(ca_sut, pki_hosts_file, host_dir)
|
362
392
|
# generate certs
|
363
393
|
on(ca_sut, "cd #{host_dir}; cat #{host_dir}/pki.hosts | xargs bash make.sh")
|
364
394
|
end
|
@@ -391,14 +421,16 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
|
|
391
421
|
local_host_pki_tree = File.join(local_pki_dir,'pki','keydist',fqdn)
|
392
422
|
local_cacert = File.join(local_pki_dir,'pki','demoCA','cacert.pem')
|
393
423
|
|
394
|
-
|
395
|
-
|
396
|
-
|
424
|
+
sut.mkdir_p("#{sut_pki_dir}/public")
|
425
|
+
sut.mkdir_p("#{sut_pki_dir}/private")
|
426
|
+
sut.mkdir_p("#{sut_pki_dir}/cacerts")
|
427
|
+
copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pem", "#{sut_pki_dir}/private/")
|
428
|
+
copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pub", "#{sut_pki_dir}/public/")
|
397
429
|
|
398
|
-
|
430
|
+
copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/simp_auto_ca.pem")
|
399
431
|
|
400
432
|
# NOTE: to match pki::copy, 'cacert.pem' is copied to 'cacerts.pem'
|
401
|
-
|
433
|
+
copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/cacerts.pem")
|
402
434
|
|
403
435
|
# Need to hash all of the CA certificates so that apps can use them
|
404
436
|
# properly! This must happen on the host itself since it needs to match
|
@@ -429,7 +461,7 @@ done
|
|
429
461
|
host_keydist_dir = "#{modulepath.first}/pki/files/keydist"
|
430
462
|
end
|
431
463
|
on ca_sut, "rm -rf #{host_keydist_dir}/*"
|
432
|
-
|
464
|
+
ca_sut.mkdir_p(host_keydist_dir)
|
433
465
|
on ca_sut, "cp -pR /root/pki/keydist/. #{host_keydist_dir}/"
|
434
466
|
on ca_sut, "chgrp -R puppet #{host_keydist_dir}"
|
435
467
|
end
|
@@ -549,7 +581,7 @@ done
|
|
549
581
|
puts " ** pluginsync_on: '#{sut}'" if ENV['BEAKER_helpers_verbose']
|
550
582
|
fact_path = on(sut, %q(puppet config print factpath)).output.strip.split(':').first
|
551
583
|
on(sut, %q(puppet config print modulepath)).output.strip.split(':').each do |mod_path|
|
552
|
-
|
584
|
+
sut.mkdir_p(fact_path)
|
553
585
|
next if on(sut, "ls #{mod_path}/*/lib/facter 2>/dev/null ", :accept_all_exit_codes => true).exit_code != 0
|
554
586
|
on(sut, %Q(find #{mod_path}/*/lib/facter -type f -name '*.rb' -exec cp -a {} '#{fact_path}/' \\; ))
|
555
587
|
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.8.
|
4
|
+
version: 1.8.6
|
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: 2017-09-
|
12
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beaker
|
@@ -93,15 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.6.13
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: beaker helper methods for SIMP
|
100
|
-
test_files:
|
101
|
-
- spec/acceptance/enable_fips_spec.rb
|
102
|
-
- spec/acceptance/fixture_modules_spec.rb
|
103
|
-
- spec/acceptance/nodesets/default.yml
|
104
|
-
- spec/acceptance/pki_tests_spec.rb
|
105
|
-
- spec/acceptance/set_hieradata_on_spec.rb
|
106
|
-
- spec/acceptance/write_hieradata_to_spec.rb
|
107
|
-
- spec/spec_helper_acceptance.rb
|
100
|
+
test_files: []
|