simp-beaker-helpers 1.18.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fixtures.yml +8 -0
- data/.gitignore +8 -0
- data/.gitlab-ci.yml +163 -0
- data/.rspec +4 -0
- data/.rubocop.yml +546 -0
- data/.travis.yml +36 -0
- data/CHANGELOG.md +231 -0
- data/Gemfile +51 -0
- data/LICENSE +27 -0
- data/README.md +543 -0
- data/Rakefile +151 -0
- data/files/pki/clean.sh +1 -0
- data/files/pki/make.sh +101 -0
- data/files/pki/template_ca.cnf +259 -0
- data/files/pki/template_host.cnf +263 -0
- data/files/puppet-agent-versions.yaml +46 -0
- data/lib/simp/beaker_helpers.rb +1231 -0
- data/lib/simp/beaker_helpers/constants.rb +25 -0
- data/lib/simp/beaker_helpers/inspec.rb +328 -0
- data/lib/simp/beaker_helpers/snapshot.rb +156 -0
- data/lib/simp/beaker_helpers/ssg.rb +383 -0
- data/lib/simp/beaker_helpers/version.rb +5 -0
- data/lib/simp/beaker_helpers/windows.rb +16 -0
- data/lib/simp/rake/beaker.rb +269 -0
- data/simp-beaker-helpers.gemspec +38 -0
- data/spec/acceptance/nodesets/default.yml +32 -0
- data/spec/acceptance/suites/default/check_puppet_version_spec.rb +23 -0
- data/spec/acceptance/suites/default/enable_fips_spec.rb +23 -0
- data/spec/acceptance/suites/default/fixture_modules_spec.rb +22 -0
- data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +43 -0
- data/spec/acceptance/suites/default/nodesets +1 -0
- data/spec/acceptance/suites/default/pki_tests_spec.rb +55 -0
- data/spec/acceptance/suites/default/set_hieradata_on_spec.rb +33 -0
- data/spec/acceptance/suites/default/write_hieradata_to_spec.rb +33 -0
- data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +63 -0
- data/spec/acceptance/suites/fips_from_fixtures/metadata.yml +2 -0
- data/spec/acceptance/suites/fips_from_fixtures/nodesets +1 -0
- data/spec/acceptance/suites/offline/00_default_spec.rb +165 -0
- data/spec/acceptance/suites/offline/README +2 -0
- data/spec/acceptance/suites/offline/nodesets/default.yml +26 -0
- data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +25 -0
- data/spec/acceptance/suites/puppet_collections/metadata.yml +2 -0
- data/spec/acceptance/suites/puppet_collections/nodesets/default.yml +30 -0
- data/spec/acceptance/suites/snapshot/00_snapshot_test_spec.rb +82 -0
- data/spec/acceptance/suites/snapshot/10_general_usage_spec.rb +56 -0
- data/spec/acceptance/suites/snapshot/nodesets +1 -0
- data/spec/acceptance/suites/windows/00_default_spec.rb +119 -0
- data/spec/acceptance/suites/windows/metadata.yml +2 -0
- data/spec/acceptance/suites/windows/nodesets/default.yml +33 -0
- data/spec/acceptance/suites/windows/nodesets/win2016.yml +35 -0
- data/spec/acceptance/suites/windows/nodesets/win2019.yml +34 -0
- data/spec/lib/simp/beaker_helpers_spec.rb +216 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/spec_helper_acceptance.rb +25 -0
- metadata +243 -0
data/.travis.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
sudo: false
|
5
|
+
before_install:
|
6
|
+
- rm Gemfile.lock || true
|
7
|
+
bundler_args: "--without development --path .vendor"
|
8
|
+
notifications:
|
9
|
+
email: false
|
10
|
+
rvm:
|
11
|
+
- 2.4.4
|
12
|
+
env:
|
13
|
+
- SIMP_SKIP_NON_SIMPOS_TESTS=1
|
14
|
+
script:
|
15
|
+
- bundle exec rake spec
|
16
|
+
before_deploy:
|
17
|
+
- bundle exec rake clobber
|
18
|
+
- "export GEM_VERSION=`ruby -r ./lib/simp/beaker_helpers/version.rb -e 'puts Simp::BeakerHelpers::VERSION'`"
|
19
|
+
- '[[ $TRAVIS_TAG =~ ^${GEM_VERSION}$ ]]'
|
20
|
+
deploy:
|
21
|
+
- provider: rubygems
|
22
|
+
gemspec: simp-beaker-helpers.gemspec
|
23
|
+
gem: simp-beaker-helpers
|
24
|
+
api_key:
|
25
|
+
secure: "AlnBx0dBSxn+S97n0h14ltKUOA+6v0bc7QZPIcwGJV9nnf1hKH3pf9La1TVknEx7XgpAcM9jusQJ7hBlqvSq8z8SFF0bZk1EgSRIKc1cuYPLiGyUM2O7+AFHyCy3iCnPvKeoQmE/BJb5O1dGnbmSbf4A0fqLxA7jiHG1j7z+cnmJB1i67wovDfl13TsOXyBfbespWBMMc0BKAw56FPs9XggAk2cNusS3hd5tqW1AZPT2/xwt+d8ngkmO96u8QcichYRFQ+w+XW4H0w935wNg/dWiskJlt7TIYVAh4Ko5s2DZKf52Tne8TugALSn0LhRatpp7sw1FTTpteCW8UqK8uwGC2hM4pZViAOv4P1YObz2IPOZPriBl+cCayJdMKnotkUJliAMnw5TLiSWKLou+S0Pdj2h3fJZWdOEwRPMzIVoJtsOHG3GdNcPL6f7iU0vP/wr6FeR3uWa+fA7NHRi2Du955O8JpogjdrW08ahcAEwhtI3A4mrA08wN09axsrwr093uDRm/5h4FHyAhExJ0YiA/6kcPpUvILcLStyHe0RQDICQMdsQo2DSbnL65w3QjFa2fML2Shf9cRwX06+ia2BxozWzFD/6p3RiRtPxphnbFiUdjYSGWcwCcUgbJx9SW04lSSxOhpyItuXgxZqiybkzstXd6riu5zwg1R8TWk34="
|
26
|
+
on:
|
27
|
+
tags: true
|
28
|
+
rvm: 2.4.4
|
29
|
+
condition: "($SKIP_PUBLISH != true)"
|
30
|
+
- provider: releases
|
31
|
+
api_key:
|
32
|
+
secure: "I41p4aqjkrNDHJhZ5gWC4gzn7BVwEYRm5Q3PAxQRSIUDB/QTVgNqZx8YptkuIvSGpw8kIywyZg3NKdzGUO8aJJ0NlXapL7e9qQIigkYhdaCZjZFG5zIxdOFs4sVoz/6vnQT9JIcGWy7uS5xiNOulGvfEWU78+e+I9yPdT74RApve5VAVT/km5lV5ldRnwwehLnTx+volUlnOD8rwfizoVLqFTrfRfr4cVMF605UYyaiVxHF50hywFRZoAdVcMEhlLQnQXfz/ZsLMJLJm9eCpjQ989N0oX6theSLCcv7QtHcWMXydjWMcpuTfBZSFrwUVbC23uMOKTJVEWq5LMG3m2L6hP3//2gvUzGhOVLvoGuC+erboB7QoXdcoOgXY+dTZPMcPBxpArdDLWVQSLTvPs05QzpaUdRLVMC/kD1d1EudlEicgkNgNDBhBn3089nVmvKndbKLvj+23a5AQVVbs+8C0x+SJvTc9N2N+bmuH7jIJPrEvWK4xwcQa+g2M/EBv05jaEdSErlVa6B6UKCH0Lea9rpy1se9vn5OzpaaMCCJIpcpQqHDjo0PMAQXBSbqjKcBei6lR5fIFl5UO9gWP1v8PGPuCzGTBivQ92XlgV1TWXmdbJHwIuSbJx3Ali7Wp19RR4E4uHC+TPFssvgkh9ZLkORnWWS35wzzU1LkwWx0="
|
33
|
+
on:
|
34
|
+
tags: true
|
35
|
+
rvm: 2.4.4
|
36
|
+
condition: "($SKIP_PUBLISH != true)"
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
### 1.18.8 / 2020-07-14
|
2
|
+
* Allow the beaker version to be pinned by environment variable
|
3
|
+
|
4
|
+
### 1.18.7 / 2020-07-07
|
5
|
+
* Fix host reference bug when switching to FIPS mode
|
6
|
+
* Ensure that net-ssh 6+ can access older FIPS systems
|
7
|
+
|
8
|
+
### 1.18.6 / 2020-06-24
|
9
|
+
* Fix Vagrant snapshot issues
|
10
|
+
|
11
|
+
### 1.18.5 / 2020-06-24
|
12
|
+
* Allow Vagrant to connect to EL8+ hosts in FIPS mode
|
13
|
+
* Add EL8 support to the SSG scans
|
14
|
+
|
15
|
+
### 1.18.4 / 2020-03-31
|
16
|
+
* Fix capturing error messages when inspec fails to generate results
|
17
|
+
|
18
|
+
### 1.18.3 / 2020-02-24
|
19
|
+
* Fix the Windows library loading location.
|
20
|
+
* No longer attempt to load windows libraries by default unless the system is
|
21
|
+
actually Windows
|
22
|
+
|
23
|
+
### 1.18.2 / 2020-02-24
|
24
|
+
|
25
|
+
* The previous location for loading the Windows libraries would not work in a
|
26
|
+
`:before` block. This moves it into its own module space.
|
27
|
+
* Bump to the working version of beaker and beaker-puppet
|
28
|
+
|
29
|
+
### 1.18.1 / 2020-02-12
|
30
|
+
* Fix gemspec dependencies
|
31
|
+
* Fix the windows library loading location
|
32
|
+
|
33
|
+
### 1.18.0 / 2020-02-06
|
34
|
+
* Update Windows support
|
35
|
+
* Add require beaker-windows and note installation of gem if missing
|
36
|
+
* Add geotrust global CA certificate in fix_eratta_on
|
37
|
+
* Added convenience helper methods
|
38
|
+
* Add puppet_environment_path_on
|
39
|
+
* Add file_content_on which is multi-platform safe unlike the built-in
|
40
|
+
file_contents_on
|
41
|
+
* Add hiera_config_path_on
|
42
|
+
* Add get_hiera_config_on
|
43
|
+
* Add set_hiera_config_on
|
44
|
+
|
45
|
+
### 1.17.1 / 2019-11-01
|
46
|
+
* Only pull in the beaker rake tasks from the puppetlabs helpers
|
47
|
+
|
48
|
+
### 1.17.0 / 2019-10-22
|
49
|
+
* Allow users to perform exclusion filters on SSG results
|
50
|
+
* Allow users to pass Arrays of items to match for SSG results
|
51
|
+
|
52
|
+
### 1.16.2 / 2019-10-10
|
53
|
+
* Pull latest inspec package now that the upstream bug is fixed
|
54
|
+
|
55
|
+
### 1.16.1 / 2019-09-25
|
56
|
+
* Remove debugging pry that was accidentally left in
|
57
|
+
|
58
|
+
### 1.16.0 / 2019-09-23
|
59
|
+
* Added a sosreport function to gather SOS Reports from EL systems
|
60
|
+
|
61
|
+
### 1.15.2 / 2019-09-13
|
62
|
+
* Fix an issue where the inspec reports were not processed properly
|
63
|
+
|
64
|
+
### 1.15.1 / 2019-08-26
|
65
|
+
* Ensure that any user on the SUT can use the RedHat entitlements
|
66
|
+
|
67
|
+
### 1.15.0 / 2019-08-08
|
68
|
+
* Add the ability to handle registration of Red Hat hosts with the RHN.
|
69
|
+
|
70
|
+
### 1.14.6 / 2019-08-15
|
71
|
+
* Add Windows client support to the beaker helpers functions
|
72
|
+
* Added an `is_windows?(sut)` function
|
73
|
+
* Work around issues with calling `sut.puppet` on Windows SUTs
|
74
|
+
* Update `copy_fixture_modules_to` to support Windows (slow copy)
|
75
|
+
* Add Windows support to `puppet_modulepath_on`
|
76
|
+
|
77
|
+
### 1.14.5 / 2019-08-14
|
78
|
+
* Update the CentOS SSG hooks to properly work with CentOS 6
|
79
|
+
|
80
|
+
### 1.14.4 / 2019-07-26
|
81
|
+
* Bump the version of Highline to 2.0+ due to bugs in the latest 1.X series
|
82
|
+
|
83
|
+
### 1.14.3 / 2019-06-24
|
84
|
+
* Add RPM-GPG-KEY-SIMP-6 to the SIMP dependencies repo created
|
85
|
+
by install_simp_repo.
|
86
|
+
|
87
|
+
### 1.14.2 / 2019-05-16
|
88
|
+
* Move the minimum supported puppet version to Puppet 5 since Puppet 4 has been
|
89
|
+
removed from the download servers completely. Beaker may re-add support for
|
90
|
+
the new location so not removing the mappings at this time.
|
91
|
+
* Fixed a bug where a hash item was incorrect and not properly passing along
|
92
|
+
configuration items.
|
93
|
+
|
94
|
+
### 1.14.1 / 2019-04-15
|
95
|
+
* Handle license acceptance option needed for new versions of inspec.
|
96
|
+
|
97
|
+
### 1.14.0 / 2019-04-08
|
98
|
+
* Added function, install_simp_repo, to install the simp online repos.
|
99
|
+
The repos are defined in a hash in the function. All the repos
|
100
|
+
will be configured and enabled. To disable one or more of them pass
|
101
|
+
in an array of names of the repos to disable.
|
102
|
+
|
103
|
+
### 1.13.1 / 2019-02-02
|
104
|
+
* Ensure that SUTs have an FQDN set and not just a short hostname
|
105
|
+
* Work around issue where the SSG doesn't build the STIG for CentOS any longer.
|
106
|
+
* Add a work around for getting the docker SUT ID due to breaking changes in
|
107
|
+
the beaker-docker gem
|
108
|
+
|
109
|
+
### 1.13.0 / 2018-11-09
|
110
|
+
* Make the SSG reporting consistent with the InSpec reporting
|
111
|
+
* Thanks to Liz Nemsick for the original result processing code
|
112
|
+
|
113
|
+
### 1.12.2 / 2018-10-25
|
114
|
+
* Skip most of fix_errata_on on windows platforms
|
115
|
+
|
116
|
+
### 1.12.1 / 2018-10-24
|
117
|
+
* Fall back to SSH file copies automatically when rsync does not work due to
|
118
|
+
test cases that affect ssh directly and that will cause new sessions to fail.
|
119
|
+
|
120
|
+
### 1.12.0 / 2018-10-22
|
121
|
+
* When using suites, allow users to loop through multiple specified nodesets as
|
122
|
+
a colon delimited list or loop through all nodesets by passing 'ALL'.
|
123
|
+
* If 'ALL' is passed, the 'default' suite will be run first.
|
124
|
+
|
125
|
+
### 1.11.3 / 2018-10-22
|
126
|
+
* Made the inspec report less confusing overall by noting where checks are
|
127
|
+
overridden
|
128
|
+
* Fix errors in the previous ssh key copy
|
129
|
+
|
130
|
+
### 1.11.2 / 2018-10-11
|
131
|
+
* Copy ssh keys in home directories to simp standard '/etc/ssh/local_keys/'
|
132
|
+
to avoid error when certain simp puppet modules are applied
|
133
|
+
* Fix enable_fips_mode_on(), which no longer works on centos/7 vagrant boxes.
|
134
|
+
|
135
|
+
### 1.11.1 / 2018-10-03
|
136
|
+
* Deprecate the 'terminus' parameter in 'write_hieradata_to' and 'set_hieradata_on'
|
137
|
+
* Add 'copy_hiera_data_to' method to replace the one from beaker-hiera
|
138
|
+
* Add 'hiera_datadir' method to replace the one from beaker-hiera
|
139
|
+
* Change InSpec to use the 'reporter' option instead of 'format'
|
140
|
+
* Update the SSG to point to the new ComplianceAsCode repository
|
141
|
+
|
142
|
+
### 1.11.0 / 2018-10-01
|
143
|
+
* Add support for Beaker 4
|
144
|
+
|
145
|
+
### 1.10.14 / 2018-08-01
|
146
|
+
* Pinned `net-telnet` to `~> 0.1.1` for all releases due to dropping support
|
147
|
+
for Ruby less than 2.3 in `0.2.X`. This should be removed once we drop
|
148
|
+
support for Ruby 1.9 (late October 2018).
|
149
|
+
|
150
|
+
### 1.10.13 / 2018-07-24
|
151
|
+
* Update puppet to puppet-agent mapping table for puppet-agent 1.10.14
|
152
|
+
|
153
|
+
### 1.10.12 / 2018-07-09
|
154
|
+
* Forced all parallelization to `false` by default due to random issues with
|
155
|
+
Beaker
|
156
|
+
|
157
|
+
### 1.10.11 / 2018-06-25
|
158
|
+
* Pinned `fog-openstack` to `0.1.25` for all releases due to dropping support
|
159
|
+
for Ruby 1.9 in `0.1.26`. This should be removed once we drop support for
|
160
|
+
Ruby 1.9 (late October 2018)
|
161
|
+
* Added removal of `.vendor` directory which was preventing successful
|
162
|
+
deployment status in Travis CI
|
163
|
+
|
164
|
+
### 1.10.10 / 2018-06-22
|
165
|
+
* Version bump due to being released without a git tag
|
166
|
+
|
167
|
+
### 1.10.9 / 2018-06-22
|
168
|
+
* Ensure that the SSG is built from the latest tag instead of master
|
169
|
+
* Provide the option to pass a specific branch to the SSG builds
|
170
|
+
* Pin the suite base directory off of the global base directory instead of
|
171
|
+
local to wherever the system happens to be at the time.
|
172
|
+
|
173
|
+
### 1.10.8 / 2018-05-18
|
174
|
+
* New env var BEAKER_no_fix_interfaces, set to skip the fix that brings up all
|
175
|
+
vagrant interfaces
|
176
|
+
* Parallelized pre-test setup actions that are used across all hosts using `block_on`
|
177
|
+
* Add runtime dependency on `highline` for the `inspec` reporting
|
178
|
+
|
179
|
+
### 1.10.7 / 2018-05-11
|
180
|
+
* Updated README
|
181
|
+
* Changed acceptance tests to use `beaker:suites`
|
182
|
+
* Removed all Puppet 5+ mappings and updated the install method to figure out
|
183
|
+
what to use based on the available gems so that everything is now consistent
|
184
|
+
|
185
|
+
### 1.10.6 / 2018-05-07
|
186
|
+
* Added Simp::BeakerHelpers.tmpname method to work around the removal of
|
187
|
+
Dir::Tmpname in Ruby 2.5
|
188
|
+
|
189
|
+
### 1.10.5 / 2018-04-27
|
190
|
+
* Fix issue with direct copy to/from docker containers
|
191
|
+
* Add necessary package for SSG builds
|
192
|
+
* Added the downloaded inspec_deps directory to the clean list
|
193
|
+
|
194
|
+
### 1.10.4 / 2018-04-25
|
195
|
+
* Fix Inspec report failures
|
196
|
+
* Fix SSG build failures
|
197
|
+
* Allow the SSG remediation acceptance test to fail
|
198
|
+
|
199
|
+
### 1.10.3 / 2018-03-23
|
200
|
+
* Avoid warnings when using `puppet config print`
|
201
|
+
|
202
|
+
### 1.10.2 / 2018-03-04
|
203
|
+
* Reimplemented `pluginsync_on` with a Puppet manifest to completely mimic
|
204
|
+
a native pluginsync
|
205
|
+
- Syncs _all_ assets (e.g., augeas lenses) instead of just the facts
|
206
|
+
- Simpler
|
207
|
+
- Much faster, especially with many modules or SUTs
|
208
|
+
|
209
|
+
### 1.10.1 / 2018-02-13
|
210
|
+
* Updated the Puppet version mapping list for Puppet 5
|
211
|
+
* Fixed a bug in the way that the latest Puppet 5 version was being determined
|
212
|
+
|
213
|
+
### 1.10.0 / 2018-01-23
|
214
|
+
* Add support for Puppet 5
|
215
|
+
* Note: you need to set 'puppet_collection' to 'puppet5' to test Puppet 5 and
|
216
|
+
'aio' (or leave it out) to test Puppet less than 5
|
217
|
+
* Fix support for passing the 'ALL' suite to run all suites
|
218
|
+
* Updates per Rubocop
|
219
|
+
|
220
|
+
* Ensure that `rsync` is not used once `fips` is enabled on the SUT
|
221
|
+
* If `fips` is enabled on the SUT, but not the running host, rsync
|
222
|
+
connections have a high likelihood of failing
|
223
|
+
|
224
|
+
### 1.9.0 / 2018-01-01
|
225
|
+
* Ensure that all host IP addresses get added to the internally generated PKI
|
226
|
+
keys as subjectAltNames. Kubernetes needs this and it does not hurt to have
|
227
|
+
in place for testing.
|
228
|
+
|
229
|
+
### 1.8.10 / 2017-11-02
|
230
|
+
* Fix bug in which dracut was not run on CentOS6, when dracut-fips was
|
231
|
+
installed for a FIPS-enabled test.
|
data/Gemfile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# ------------------------------------------------------------------------------
|
2
|
+
# NOTE: SIMP Puppet rake tasks support ruby 2.1.9
|
3
|
+
# ------------------------------------------------------------------------------
|
4
|
+
gem_sources = ENV.fetch('GEM_SERVERS','https://rubygems.org').split(/[, ]+/)
|
5
|
+
|
6
|
+
gem_sources.each { |gem_source| source gem_source }
|
7
|
+
|
8
|
+
# read dependencies in from the gemspec
|
9
|
+
gemspec
|
10
|
+
|
11
|
+
# mandatory gems
|
12
|
+
gem 'bundler'
|
13
|
+
gem 'rake'
|
14
|
+
|
15
|
+
group :system_tests do
|
16
|
+
beaker_gem_options = ENV.fetch('BEAKER_GEM_OPTIONS', ['>= 4.17.0', '< 5.0.0'])
|
17
|
+
|
18
|
+
if "#{beaker_gem_options}".include?(':')
|
19
|
+
# Just pass in BEAKER_GEM_OPTIONS as a string that would represent the usual
|
20
|
+
# hash of options.
|
21
|
+
#
|
22
|
+
# Something like: BEAKER_GEM_OPTIONS=':git => "https://my.repo/beaker.git", :tag => "1.2.3"'
|
23
|
+
#
|
24
|
+
# No, this isn't robust, but it's not really an 'every day' sort of thing
|
25
|
+
# and safer than an `eval`
|
26
|
+
begin
|
27
|
+
gem 'beaker', Hash[
|
28
|
+
beaker_gem_options.split(',').map do |x| # Split passed options on k/v pairs
|
29
|
+
x.gsub('"', '').strip.split(/:\s|\s+=>\s+/) # Allow for either format hash keys
|
30
|
+
end.map do |k,v|
|
31
|
+
[
|
32
|
+
k.delete(':').to_sym, # Convert all keys to symbols
|
33
|
+
v.strip
|
34
|
+
]
|
35
|
+
end
|
36
|
+
] # Convert the whole thing to a valid Hash
|
37
|
+
rescue => e
|
38
|
+
raise "Invalid BEAKER_GEM_OPTIONS: '#{beaker_gem_options}' => '#{e}'"
|
39
|
+
end
|
40
|
+
else
|
41
|
+
gem 'beaker', beaker_gem_options
|
42
|
+
end
|
43
|
+
|
44
|
+
gem 'beaker-rspec'
|
45
|
+
gem 'beaker-windows'
|
46
|
+
gem 'net-ssh'
|
47
|
+
gem 'puppet', ENV.fetch('PUPPET_VERSION', '~> 5.0')
|
48
|
+
gem 'puppetlabs_spec_helper'
|
49
|
+
gem 'rubocop'
|
50
|
+
gem 'rubocop-rspec'
|
51
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
rubygem-simp-beaker-helpers - methods to help Beaker scaffolding SIMP tests
|
2
|
+
|
3
|
+
--
|
4
|
+
|
5
|
+
Per Section 105 of the Copyright Act of 1976, these works are not entitled to
|
6
|
+
domestic copyright protection under US Federal law.
|
7
|
+
|
8
|
+
The US Government retains the right to pursue copyright protections outside of
|
9
|
+
the United States.
|
10
|
+
|
11
|
+
The United States Government has unlimited rights in this software and all
|
12
|
+
derivatives thereof, pursuant to the contracts under which it was developed and
|
13
|
+
the License under which it falls.
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
18
|
+
you may not use this file except in compliance with the License.
|
19
|
+
You may obtain a copy of the License at
|
20
|
+
|
21
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
22
|
+
|
23
|
+
Unless required by applicable law or agreed to in writing, software
|
24
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
25
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
26
|
+
See the License for the specific language governing permissions and
|
27
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,543 @@
|
|
1
|
+
# simp-beaker-helpers
|
2
|
+
|
3
|
+
Methods to assist beaker acceptance tests for SIMP.
|
4
|
+
|
5
|
+
#### Table of Contents
|
6
|
+
|
7
|
+
<!-- vim-markdown-toc GFM -->
|
8
|
+
|
9
|
+
* [Overview](#overview)
|
10
|
+
* [Setup](#setup)
|
11
|
+
* [Beginning with simp-beaker-helpers](#beginning-with-simp-beaker-helpers)
|
12
|
+
* [Rake Tasks](#rake-tasks)
|
13
|
+
* [`rake beaker:suites`](#rake-beakersuites)
|
14
|
+
* [Suite Execution](#suite-execution)
|
15
|
+
* [Environment Variables](#environment-variables)
|
16
|
+
* [Global Suite Configuration](#global-suite-configuration)
|
17
|
+
* [Supported Config:](#supported-config)
|
18
|
+
* [Individual Suite Configuration](#individual-suite-configuration)
|
19
|
+
* [Supported Config:](#supported-config-1)
|
20
|
+
* [Nodeset Enhancements](#nodeset-enhancements)
|
21
|
+
* [YUM Repo Support](#yum-repo-support)
|
22
|
+
* [Methods](#methods)
|
23
|
+
* [`copy_to`](#copy_to)
|
24
|
+
* [`copy_fixture_modules_to`](#copy_fixture_modules_to)
|
25
|
+
* [`fix_errata_on`](#fix_errata_on)
|
26
|
+
* [`run_fake_pki_ca_on`](#run_fake_pki_ca_on)
|
27
|
+
* [`copy_pki_to`](#copy_pki_to)
|
28
|
+
* [`copy_keydist_to`](#copy_keydist_to)
|
29
|
+
* [`pfact_on`](#pfact_on)
|
30
|
+
* [`pluginsync_on`](#pluginsync_on)
|
31
|
+
* [`write_hieradata_to`](#write_hieradata_to)
|
32
|
+
* [`set_hieradata_on`](#set_hieradata_on)
|
33
|
+
* [`clear_temp_hieradata`](#clear_temp_hieradata)
|
34
|
+
* [`latest_puppet_agent_version_for(puppet_version)`](#latest_puppet_agent_version_forpuppet_version)
|
35
|
+
* [`install_puppet`](#install_puppet)
|
36
|
+
* [Environment variables](#environment-variables-1)
|
37
|
+
* [`BEAKER_fips`](#beaker_fips)
|
38
|
+
* [`BEAKER_fips_module_version`](#beaker_fips_module_version)
|
39
|
+
* [`BEAKER_spec_prep`](#beaker_spec_prep)
|
40
|
+
* [`BEAKER_SIMP_parallel`](#beaker_simp_parallel)
|
41
|
+
* [`BEAKER_stringify_facts`](#beaker_stringify_facts)
|
42
|
+
* [`BEAKER_use_fixtures_dir_for_modules`](#beaker_use_fixtures_dir_for_modules)
|
43
|
+
* [`BEAKER_no_fix_interfaces`](#beaker_no_fix_interfaces)
|
44
|
+
* [PUPPET_VERSION](#puppet_version)
|
45
|
+
* [BEAKER_RHSM_USER](#beaker_rhsm_user)
|
46
|
+
* [BEAKER_RHSM_PASS](#beaker_rhsm_pass)
|
47
|
+
* [BEAKER_inspec_version](#beaker_inspec_version)
|
48
|
+
* [Examples](#examples)
|
49
|
+
* [Prep OS, Generate and copy PKI certs to each SUT](#prep-os-generate-and-copy-pki-certs-to-each-sut)
|
50
|
+
* [Specify the version of Puppet to run in the SUTs](#specify-the-version-of-puppet-to-run-in-the-suts)
|
51
|
+
* [Experimental Features](#experimental-features)
|
52
|
+
* [Snapshot Support](#snapshot-support)
|
53
|
+
* [Running Tests with Snapshots](#running-tests-with-snapshots)
|
54
|
+
* [Adding Snapshots to your Tests](#adding-snapshots-to-your-tests)
|
55
|
+
* [Taking a Snapshot](#taking-a-snapshot)
|
56
|
+
* [Base Snapshots](#base-snapshots)
|
57
|
+
* [Restoring a Snapshot](#restoring-a-snapshot)
|
58
|
+
* [Listing Snapshots](#listing-snapshots)
|
59
|
+
* [License](#license)
|
60
|
+
|
61
|
+
<!-- vim-markdown-toc -->
|
62
|
+
|
63
|
+
## Overview
|
64
|
+
|
65
|
+
## Setup
|
66
|
+
|
67
|
+
### Beginning with simp-beaker-helpers
|
68
|
+
|
69
|
+
Add this to your project's `Gemfile`:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
gem 'simp-beaker-helpers'
|
73
|
+
```
|
74
|
+
|
75
|
+
Add this to your project's `spec/spec_helper_acceptance.rb`:
|
76
|
+
```ruby
|
77
|
+
require 'simp/beaker_helpers'
|
78
|
+
include Simp::BeakerHelpers
|
79
|
+
```
|
80
|
+
|
81
|
+
## Rake Tasks
|
82
|
+
|
83
|
+
New `rake` tasks are available to help you use `beaker` more effectively.
|
84
|
+
|
85
|
+
These can be included in your `Rakefile` by adding the following:
|
86
|
+
|
87
|
+
```
|
88
|
+
require 'simp/rake/beaker'
|
89
|
+
Simp::Rake::Beaker.new(File.dirname(__FILE__))
|
90
|
+
```
|
91
|
+
|
92
|
+
### `rake beaker:suites`
|
93
|
+
|
94
|
+
The 'beaker:suites' rake task provides the ability to run isolated test sets
|
95
|
+
with a full reset of the Beaker environment.
|
96
|
+
|
97
|
+
These are entirely isolated runs of Beaker and have been designed to be used
|
98
|
+
for situations where you need to eliminate all of the cruft from your previous
|
99
|
+
runs to perform a new type of test.
|
100
|
+
|
101
|
+
### Suite Execution
|
102
|
+
|
103
|
+
By default the only suite that will be executed is `default`. Since each suite
|
104
|
+
is executed in a new environment, spin up can take a lot of time. Therefore,
|
105
|
+
the default is to only run the default suite.
|
106
|
+
|
107
|
+
If there is a suite where the metadata contains `default_run` set to the
|
108
|
+
Boolean `true`, then that suite will be part of the default suite execution.
|
109
|
+
|
110
|
+
You can run all suites by setting the passed suite name to `ALL` (case
|
111
|
+
sensitive).
|
112
|
+
|
113
|
+
#### Environment Variables
|
114
|
+
|
115
|
+
* BEAKER_suite_runall
|
116
|
+
* Run all Suites
|
117
|
+
|
118
|
+
* BEAKER_suite_basedir
|
119
|
+
* The base directory where suites will be defined
|
120
|
+
* Default: spec/acceptance
|
121
|
+
|
122
|
+
#### Global Suite Configuration
|
123
|
+
|
124
|
+
A file `config.yml` can be placed in the `suites` directory to control certain
|
125
|
+
aspects of the suite run.
|
126
|
+
|
127
|
+
##### Supported Config:
|
128
|
+
|
129
|
+
```yaml
|
130
|
+
---
|
131
|
+
# Fail the entire suite at the first failure
|
132
|
+
'fail_fast' : <true|false> => Default: true
|
133
|
+
```
|
134
|
+
|
135
|
+
#### Individual Suite Configuration
|
136
|
+
|
137
|
+
Each suite may contain a YAML file, metadata.yml, which will be used to provide
|
138
|
+
information to the suite of tests.
|
139
|
+
|
140
|
+
##### Supported Config:
|
141
|
+
|
142
|
+
```yaml
|
143
|
+
---
|
144
|
+
'name' : '<User friendly name for the suite>'
|
145
|
+
|
146
|
+
# Run this suite by default
|
147
|
+
'default_run' : <true|false> => Default: false
|
148
|
+
```
|
149
|
+
|
150
|
+
## Nodeset Enhancements
|
151
|
+
|
152
|
+
### YUM Repo Support
|
153
|
+
|
154
|
+
Nodes in your nodesets will create YUM repository entries according to the
|
155
|
+
following Hash:
|
156
|
+
|
157
|
+
```yaml
|
158
|
+
---
|
159
|
+
yum_repos:
|
160
|
+
<repo_name>:
|
161
|
+
<yum_resource_parameter>: <value>
|
162
|
+
```
|
163
|
+
|
164
|
+
The `baseurl` and `gpgkey` parameters can also take an Array if you need to
|
165
|
+
point at more than one location.
|
166
|
+
|
167
|
+
This would look like the following:
|
168
|
+
|
169
|
+
```yaml
|
170
|
+
---
|
171
|
+
yum_repos:
|
172
|
+
<repo_name>:
|
173
|
+
baseurl:
|
174
|
+
- http://some.random.host
|
175
|
+
- https://some.other.random.host
|
176
|
+
gpgkey:
|
177
|
+
- https://my.gpg.host
|
178
|
+
- https://my.other.gpg.host
|
179
|
+
```
|
180
|
+
|
181
|
+
## Methods
|
182
|
+
|
183
|
+
#### `copy_to`
|
184
|
+
|
185
|
+
Abstracts copying files and directories in the most efficient manner possible.
|
186
|
+
|
187
|
+
* If your system is a ``docker`` container it uses ``docker cp``
|
188
|
+
* If your system is anything else:
|
189
|
+
* Attempts to use ``rsync`` if it is present on both sides
|
190
|
+
* Falls back to ``scp``
|
191
|
+
|
192
|
+
All copy semantics are consistent with what you would expect from ``scp_to``
|
193
|
+
|
194
|
+
#### `copy_fixture_modules_to`
|
195
|
+
|
196
|
+
Copies the local fixture modules (under `spec/fixtures/modules`) onto a list of
|
197
|
+
SUTs.
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
copy_fixture_modules_to( suts = hosts, opts = {} )
|
201
|
+
```
|
202
|
+
- **`suts`** = _(Array,String)_ list of SUTs to copy modules to
|
203
|
+
- **`opts`** = _(Hash)_ Options passed on to `copy_module_to()` for each SUT
|
204
|
+
|
205
|
+
By default, this will copy modules to the first path listed in each SUT's
|
206
|
+
`modulepath` and simulate a pluginsync so the Beaker DSL's `facter_on` will
|
207
|
+
still work.
|
208
|
+
|
209
|
+
If you need to use a non-default module path:
|
210
|
+
```ruby
|
211
|
+
# WARNING: this will use the same :target_module_dir for each SUT
|
212
|
+
copy_fixture_modules_to( hosts, {
|
213
|
+
:target_module_dir => '/path/to/my/modules',
|
214
|
+
})
|
215
|
+
```
|
216
|
+
|
217
|
+
If you want to disable pluginsync:
|
218
|
+
```ruby
|
219
|
+
# WARNING: `fact_on` will not see custom facts
|
220
|
+
copy_fixture_modules_to( hosts, {
|
221
|
+
:pluginsync => false
|
222
|
+
})
|
223
|
+
```
|
224
|
+
|
225
|
+
#### `fix_errata_on`
|
226
|
+
|
227
|
+
Apply any OS fixes we need on each SUT
|
228
|
+
`fix_errata_on( suts = hosts )`
|
229
|
+
|
230
|
+
|
231
|
+
#### `run_fake_pki_ca_on`
|
232
|
+
|
233
|
+
Generate a fake openssl CA + certs for each host on a given SUT and copy the
|
234
|
+
files back to a local directory.
|
235
|
+
|
236
|
+
**NOTE:** this needs to generate everything inside an SUT. It is assumed the
|
237
|
+
SUT will have the appropriate openssl in its environment.
|
238
|
+
|
239
|
+
`run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' )`
|
240
|
+
|
241
|
+
- **`ca_sut`** = the SUT to generate the CA & certs on
|
242
|
+
- **`suts`** = list of SUTs to generate certs for
|
243
|
+
- **`local_dir`** = local path where the CA+cert directory tree should copied back to
|
244
|
+
|
245
|
+
#### `copy_pki_to`
|
246
|
+
|
247
|
+
Copy a single SUT's PKI certs (with cacerts) onto the SUT. This simulates the result of `pki::copy` without requiring a full master and `simp-pki` module.
|
248
|
+
|
249
|
+
The directory structure copied to the SUT is:
|
250
|
+
```
|
251
|
+
SUT_BASE_DIR/
|
252
|
+
pki/
|
253
|
+
cacerts/cacerts.pem
|
254
|
+
public/fdqn.pub
|
255
|
+
private/fdqn.pem
|
256
|
+
|
257
|
+
```
|
258
|
+
|
259
|
+
`copy_pki_to(sut, local_pki_dir, sut_base_dir = '/etc/pki/simp-testing')`
|
260
|
+
|
261
|
+
|
262
|
+
#### `copy_keydist_to`
|
263
|
+
|
264
|
+
Copy a CA keydist/ directory of CA+host certs into an SUT.
|
265
|
+
|
266
|
+
This simulates the output of FakeCA's `gencerts_nopass.sh` into `keydist/` and is useful for constructing a Puppet master SUT that will distribute PKI keys via agent runs.
|
267
|
+
|
268
|
+
`copy_keydist_to( ca_sut = master )`
|
269
|
+
|
270
|
+
|
271
|
+
#### `pfact_on`
|
272
|
+
|
273
|
+
Look up a fact on a given SUT using the `puppet fact` face. This honors whatever facter-related settings the SUT's Puppet installation has been configured to use (i.e., `factpath`, `stringify_facts`, etc).
|
274
|
+
|
275
|
+
`pfact_on( sut, fact_name )`
|
276
|
+
|
277
|
+
|
278
|
+
#### `pluginsync_on`
|
279
|
+
|
280
|
+
Simulates a `pluginsync` (useful for deploying custom facts) on given SUTs.
|
281
|
+
|
282
|
+
`pluginsync_on( suts = hosts )`
|
283
|
+
|
284
|
+
#### `write_hieradata_to`
|
285
|
+
|
286
|
+
Writes a YAML file in the Hiera :datadir of a Beaker::Host.
|
287
|
+
|
288
|
+
**NOTE**: This is useless unless Hiera is configured to use the data file.
|
289
|
+
`Beaker::DSL::Helpers::Hiera#write_hiera_config_on` from [beaker-hiera](https://github.com/puppetlabs/beaker-hiera) may be used to configure Hiera.
|
290
|
+
|
291
|
+
`write_hieradata_to(host, hieradata, terminus = 'default')`
|
292
|
+
|
293
|
+
- **`host`** = _(Array,String,Symbol)_ One or more hosts to act upon
|
294
|
+
- **`hieradata`** = _(Hash)_ The full hiera data structure to write to the system
|
295
|
+
- **`terminus`** = _(String)_ The file basename minus the file extension in which to write the Hiera data
|
296
|
+
|
297
|
+
#### `set_hieradata_on`
|
298
|
+
|
299
|
+
Writes a YAML file in the Hiera :datdir of a Beaker::Host, then configures the host to use that file exclusively.
|
300
|
+
|
301
|
+
**NOTE**: This is authoritative; you cannot mix this with other Hiera data sources.
|
302
|
+
|
303
|
+
`set_hieradata_on(host, hieradata, terminus = 'default')`
|
304
|
+
|
305
|
+
- **`host`** = _(Array,String,Symbol)_ One or more hosts to act upon
|
306
|
+
- **`hieradata`** = _(Hash)_ The full hiera data structure to write to the system
|
307
|
+
- **`terminus`** = _(String)_ The file basename minus the file extension in which to write the Hiera data
|
308
|
+
|
309
|
+
#### `clear_temp_hieradata`
|
310
|
+
|
311
|
+
Clean up all temporary hiera data files; meant to be called from `after(:all)`
|
312
|
+
|
313
|
+
`clear_temp_hieradata`
|
314
|
+
|
315
|
+
#### `latest_puppet_agent_version_for(puppet_version)`
|
316
|
+
|
317
|
+
Finds the latest `puppet-agent` version based on the passed gem version and can
|
318
|
+
accept the usual Gem comparison syntax (e.g., '4.0', '=4.2', '~> 4.3.1', '5')
|
319
|
+
|
320
|
+
Returns the `puppet-agent` package version or `nil` if not found.
|
321
|
+
|
322
|
+
#### `install_puppet`
|
323
|
+
|
324
|
+
Performs an assessment of all set parameters and installs the correct
|
325
|
+
`puppet-agent` based on those parameters based on the following logic.
|
326
|
+
|
327
|
+
If the environment variable `BEAKER_PUPPET_AGENT_VERSION` or
|
328
|
+
`PUPPET_INSTALL_VERSION` or `PUPPET_VERSION` is set, it will use that value
|
329
|
+
to determine the `puppet-agent` version to install.
|
330
|
+
|
331
|
+
If it is unable to determine the `puppet-agent` version from any `*VERSION`
|
332
|
+
environment variables and the environment variable `BEAKER_PUPPET_COLLECTION`
|
333
|
+
is set, it will use this to determine which puppet collection to install from.
|
334
|
+
(Presently, this only works with Puppet 5.x and is set as `puppet5`.)
|
335
|
+
|
336
|
+
If it cannot determinte the `puppet-agent` version from any environment
|
337
|
+
variables, it will default the version to the value of
|
338
|
+
Simp::BeakerHelpers::DEFAULT_PUPPET_AGENT_VERSION, which is currently '1.10.4'.
|
339
|
+
|
340
|
+
## Environment variables
|
341
|
+
|
342
|
+
#### `BEAKER_fips`
|
343
|
+
|
344
|
+
_(Default: `no`)_ When set to `yes`, Beaker will enable [FIPS mode](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-Federal_Standards_And_Regulations-Federal_Information_Processing_Standard.html) on all SUTs before running tests.
|
345
|
+
|
346
|
+
**NOTE:** FIPS mode is only enabled on RedHat family hosts.
|
347
|
+
|
348
|
+
#### `BEAKER_fips_module_version`
|
349
|
+
|
350
|
+
_(Default: unset)_ Set to a version of the simp-fips Puppet module released
|
351
|
+
to Puppet Forge, when you want to specify the version of that module used to
|
352
|
+
implement enable FIPS. When unset, the latest version is used.
|
353
|
+
|
354
|
+
**NOTE:** This has no effect if the `simp-fips` module is already included in your fixtures.yml
|
355
|
+
|
356
|
+
#### `BEAKER_spec_prep`
|
357
|
+
|
358
|
+
_(Default: `yes`)_ Ensures that each fixture module is present under
|
359
|
+
`spec/fixtures/modules`. If any fixture modules are missing, it will run `rake
|
360
|
+
spec_prep` to populate the missing modules using `.fixtures.yml`. Note that
|
361
|
+
this will _not_ update modules that are already present under
|
362
|
+
`spec/fixtures/modules`.
|
363
|
+
|
364
|
+
#### `BEAKER_SIMP_parallel`
|
365
|
+
|
366
|
+
_(Default: `no`)_ Execute each SIMP host setup method such as
|
367
|
+
`Simp::BeakerHelpers::copy_fixure_modules_to` and `Simp::BeakerHelpers::fix_errata_on`
|
368
|
+
on all hosts in a node set in parallel. Uses parallelization provided by Beaker.
|
369
|
+
|
370
|
+
**NOTE:** Beaker's parallelization capability does not always work, so a word
|
371
|
+
to the wise is sufficient.
|
372
|
+
|
373
|
+
#### `BEAKER_stringify_facts`
|
374
|
+
#### `BEAKER_use_fixtures_dir_for_modules`
|
375
|
+
|
376
|
+
#### `BEAKER_no_fix_interfaces`
|
377
|
+
|
378
|
+
Set to skip code that makes sure all interfaces are up
|
379
|
+
|
380
|
+
#### PUPPET_VERSION
|
381
|
+
|
382
|
+
The `PUPPET_VERSION` environment variable will install the latest
|
383
|
+
`puppet-agent` package that provides that version of Puppet. This honors
|
384
|
+
`Gemfile`-style expressions like `"~> 4.8.0"`
|
385
|
+
|
386
|
+
`BEAKER_PUPPET_AGENT_VERSION` and `PUPPET_INSTALL_VERSION` are synonyms of
|
387
|
+
`PUPPET_VERSION`.
|
388
|
+
|
389
|
+
#### BEAKER_RHSM_USER
|
390
|
+
|
391
|
+
The username to use with Red Hat Subscription Manager when dealing with a RHEL host.
|
392
|
+
|
393
|
+
Will not be output to the screen.
|
394
|
+
|
395
|
+
#### BEAKER_RHSM_PASS
|
396
|
+
|
397
|
+
The password to use with Red Hat Subscription Manager when dealing with a RHEL host.
|
398
|
+
|
399
|
+
Will not be output to the screen.
|
400
|
+
|
401
|
+
Note: When using Subscription Manager, make sure your nodeset has the setting validation: false. Otherwise Beaker:Rspec
|
402
|
+
might try to install packages before subscription manager is configured.
|
403
|
+
|
404
|
+
#### BEAKER_inspec_version
|
405
|
+
|
406
|
+
The version of InSpec to use when running inspec tests. Currently hard-coded to
|
407
|
+
`4.16.14` due to a bug introduced in `4.16.15`.
|
408
|
+
|
409
|
+
Let to 'latest' to use the latest available in the upstream repos.
|
410
|
+
|
411
|
+
## Examples
|
412
|
+
|
413
|
+
### Prep OS, Generate and copy PKI certs to each SUT
|
414
|
+
This pattern serves to prepare component modules that use PKI
|
415
|
+
|
416
|
+
```ruby
|
417
|
+
# spec/spec_acceptance_helpers.rb
|
418
|
+
require 'beaker-rspec'
|
419
|
+
require 'tmpdir'
|
420
|
+
require 'simp/beaker_helpers'
|
421
|
+
include Simp::BeakerHelpers
|
422
|
+
|
423
|
+
unless ENV['BEAKER_provision'] == 'no'
|
424
|
+
hosts.each do |host|
|
425
|
+
# Install Puppet
|
426
|
+
if host.is_pe?
|
427
|
+
install_pe
|
428
|
+
else
|
429
|
+
install_puppet
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
|
435
|
+
RSpec.configure do |c|
|
436
|
+
# ensure that environment OS is ready on each host
|
437
|
+
fix_errata_on hosts
|
438
|
+
|
439
|
+
# Readable test descriptions
|
440
|
+
c.formatter = :documentation
|
441
|
+
|
442
|
+
# Configure all nodes in nodeset
|
443
|
+
c.before :suite do
|
444
|
+
begin
|
445
|
+
# Install modules and dependencies from spec/fixtures/modules
|
446
|
+
copy_fixture_modules_to( hosts )
|
447
|
+
Dir.mktmpdir do |cert_dir|
|
448
|
+
run_fake_pki_ca_on( default, hosts, cert_dir )
|
449
|
+
hosts.each{ |host| copy_pki_to( host, cert_dir, '/etc/pki/simp-testing' )}
|
450
|
+
end
|
451
|
+
rescue StandardError, ScriptError => e
|
452
|
+
require 'pry'; binding.pry if ENV['PRY']
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
```
|
457
|
+
|
458
|
+
### Specify the version of Puppet to run in the SUTs
|
459
|
+
|
460
|
+
```bash
|
461
|
+
# puppet-agent 1.8.3 will be installed in VMs
|
462
|
+
PUPPET_VERSION="~> 4.8.0" bundle exec rake beaker:suites
|
463
|
+
|
464
|
+
# puppet-agent 1.9.2 will be installed in VMs
|
465
|
+
PUPPET_INSTALL_VERSION=1.9.2 bundle exec rake beaker:suites
|
466
|
+
|
467
|
+
# The latest puppet 5 will be installed in VMs
|
468
|
+
PUPPET_VERSION="5" bundle exec rake beaker:suites
|
469
|
+
|
470
|
+
# puppet-agent 1.10.4 will be installed in VMs
|
471
|
+
bundle exec rake beaker:suites
|
472
|
+
```
|
473
|
+
|
474
|
+
## Experimental Features
|
475
|
+
|
476
|
+
### Snapshot Support
|
477
|
+
|
478
|
+
Rudimentary support for snapshotting VMs has been added. This currently only
|
479
|
+
works for local `vagrant` systems and relies on the underlying `vagrant
|
480
|
+
snapshot` command working for the underlying hypervisor. VirtualBox is highly
|
481
|
+
recommended and `libvirt` is known to not work due to limitiations in
|
482
|
+
`vagrant`.
|
483
|
+
|
484
|
+
This was added to attempt to be able to restart tests from given checkpoints
|
485
|
+
that encompass extremely long running test segments. This is particularly
|
486
|
+
relevant when you are trying to set up a large support infrastructure but need
|
487
|
+
to debug later stages of your tests over time.
|
488
|
+
|
489
|
+
#### Running Tests with Snapshots
|
490
|
+
|
491
|
+
To enable snapshots during your initial test runs, run your test as follows:
|
492
|
+
|
493
|
+
```bash
|
494
|
+
BEAKER_destroy=no BEAKER_simp_snapshot=yes rake beaker:suites
|
495
|
+
```
|
496
|
+
|
497
|
+
Then, on subsequent runs, run your test as follows:
|
498
|
+
|
499
|
+
```bash
|
500
|
+
BEAKER_provision=no BEAKER_destroy=no BEAKER_simp_snapshot=yes rake beaker:suites
|
501
|
+
```
|
502
|
+
#### Adding Snapshots to your Tests
|
503
|
+
|
504
|
+
The following demonstrates the general idea behind using snapshots. Note, the
|
505
|
+
decision to directly call the module methods was made to ensure that people
|
506
|
+
knew explicitly when this capability was being called since it affects the
|
507
|
+
underlying OS configuration.
|
508
|
+
|
509
|
+
##### Taking a Snapshot
|
510
|
+
|
511
|
+
`Simp::BeakerHelpers::Snapshot.save(sut, '<name of snapshot>')` will save a
|
512
|
+
snapshot with the given name. If the snapshot already exists, it will be
|
513
|
+
forceably overwritten.
|
514
|
+
|
515
|
+
|
516
|
+
##### Base Snapshots
|
517
|
+
|
518
|
+
Any time a snapshot is saved, if an initial base snapshot doesn't exist, one
|
519
|
+
will be created. You can restore back to the base snapshot using
|
520
|
+
`Simp::BeakerHelpers::Snapshot.restore_to_base(sut)`.
|
521
|
+
|
522
|
+
These are specifically created to ensure that we don't run into issues with
|
523
|
+
trying to remove the parent of all snapshots since some hypervisors do not
|
524
|
+
allow this.
|
525
|
+
|
526
|
+
##### Restoring a Snapshot
|
527
|
+
|
528
|
+
`Simp::BeakerHelpers::Snapshot.restore(sut, '<name of snapshot>)` will restore
|
529
|
+
to the named snapshot.
|
530
|
+
|
531
|
+
Attempting to restore to a snapshot that doesn't exist is an error.
|
532
|
+
|
533
|
+
##### Listing Snapshots
|
534
|
+
|
535
|
+
`Simp::BeakerHelpers::Snapshot.list(sut)` will return an Array of all snapshot
|
536
|
+
names for that system.
|
537
|
+
|
538
|
+
`Simp::BeakerHelpers::Snapshot.exist?(sut, '<name of snapshot>')` will return a
|
539
|
+
Boolean based on whether or not the snapshot with the given name is present on
|
540
|
+
the system.
|
541
|
+
|
542
|
+
## License
|
543
|
+
See [LICENSE](LICENSE)
|