simp-beaker-helpers 1.0.10 → 1.0.11

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTBmNTc3N2ZjYWQ2MzliZDEwNjk1YzJhNGRkYjQ3NzQ5OTA5YjdmNw==
4
+ OTBhZjRkNWY5MGMxNmE4ZTRkNDI2YmQyYThmNTU3NWY1Y2U5ZDM5Yg==
5
5
  data.tar.gz: !binary |-
6
- MjhkNmEwYTAyNDU3OTc1OWI4ODVmZjJjZmU1YTI3NjNiNjMwYzI1Yg==
6
+ MDc0YmJlOTZkYjZkNWJjNmUxNWRjNmE1YTEyNjUzOTEyMWU2MTg0Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Zjc2NzE3OTMxZjYwMjAzMjQ5NzQyODQ3MGVjMzkyYjE4MDI0NTIwODQ0YTQ4
10
- Nzg3Yjc5ZTA4MzE1MDY0NWU1YTg1ODZlZmUxZWRiMDhmOGQwMmZkYzY5MjM0
11
- N2NmYjU2YWMwY2M2ZjFiMWEwZjRhOGQ2ZDQyYTdjOTc2MDhlOWY=
9
+ NTA1YjIyMTA2ZmRlMDQ5ZDMyZGFmNWRiMTdmZWQwZGJjZmZkYzQ5MWI5MWYw
10
+ NWRkMzNmOTVkNTMwOTJlMDg4NjUxMDNlNGYwYjNiOGYyNWQ4NDEyYWViZDNh
11
+ NDA5N2RiM2UxODQwN2U5MDE5NzA3OGQzOGEzNWE3Y2I2OWYxODU=
12
12
  data.tar.gz: !binary |-
13
- MTkwMWU3MzFiMDVjYTdiNmU4YWZjNWZlYTZlMmI3NDQ5Nzg4NmZkZWE4ZWM4
14
- NmRkZDAwMjVmMTQ3MjA1ZGMzMjViNjFiZTFjYmEyMzZlOTIwYzk2NGQ2ZWZm
15
- N2MyOThlNzIwMjc5MGRhMGViYjczMGJmMTMxYzg2ZjQ4NGNkZDU=
13
+ ZjI5MmE3YTc4MDAzMGEwMjYzOGQxMjBhMTAzOTJjZWEyMzcyMGIxOWQwNjk4
14
+ ZTM4YTU2NGM0MTRjYmViMzk0M2RlN2Q1YjY2ZDAwMWQyZGQxMmRkOThjZjRi
15
+ Yjk5YjUwNjYyZDRhNDFkZjk2ZGVhNTM5OWYzYzhlZDY1MTk0ZDI=
data/.gitignore CHANGED
@@ -3,3 +3,5 @@
3
3
  Gemfile.lock
4
4
  .bundle/
5
5
  *.old
6
+ .vagrant
7
+ /log
data/.travis.yml CHANGED
@@ -2,12 +2,6 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
 
5
- # to provide the cracklib-check
6
- sudo: required
7
- before_install:
8
- - sudo apt-get update -qq
9
- - sudo apt-get install -y libcrack2
10
-
11
5
  rvm:
12
6
  - 1.9.3
13
7
  - 2.0.0
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
- # Allow a comma or space-delimited list of gem servers
2
- if simp_gem_server = ENV.fetch( 'SIMP_GEM_SERVERS', 'https://rubygems.org' )
3
- simp_gem_server.split( / |,/ ).each{ |gem_server|
4
- source gem_server
5
- }
6
- end
1
+ # Variables:
2
+ #
3
+ # SIMP_GEM_SERVERS | a space/comma delimited list of rubygem servers
4
+ # PUPPET_VERSION | specifies the version of the puppet gem to load
5
+ puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['~>3']
6
+ gem_sources = ENV.key?('SIMP_GEM_SERVERS') ? ENV['SIMP_GEM_SERVERS'].split(/[, ]+/) : ['https://rubygems.org']
7
+ gem_sources.each { |gem_source| source gem_source }
7
8
 
8
9
  # read dependencies in from the gemspec
9
10
  gemspec
@@ -11,9 +12,6 @@ gemspec
11
12
  # mandatory gems
12
13
  gem 'bundler'
13
14
  gem 'rake'
14
- gem 'puppetlabs_spec_helper'
15
- gem 'puppet'
16
-
17
15
 
18
16
  group :system_tests do
19
17
  gem 'pry'
@@ -22,4 +20,7 @@ group :system_tests do
22
20
  # NOTE: Workaround because net-ssh 2.10 is busting beaker
23
21
  # lib/ruby/1.9.1/socket.rb:251:in `tcp': wrong number of arguments (5 for 4) (ArgumentError)
24
22
  gem 'net-ssh', '~> 2.9.0'
23
+ gem 'puppetlabs_spec_helper'
24
+ gem 'puppet', puppetversion
25
+
25
26
  end
data/README.md CHANGED
@@ -9,12 +9,16 @@ Methods to assist beaker acceptance tests for SIMP.
9
9
  3. [Methods](#methods)
10
10
  * [`copy_fixture_modules_to`](#copy_fixture_modules_to)
11
11
  * [`fix_errata_on`](#fix_errata_on)
12
- * [`run_fake_pki_ca_on`](#run_fake_pki_ca_on)
13
- * [`copy_pki_to`](#copy_pki_to)
14
- * [`copy_keydist_to`](#copy_keydist_to)
15
- * [`pluginsync_on`](#pluginsync_on)
16
- * [`set_hieradata_on`](#set_hieradata_on)
17
- * [`clear_temp_hieradata`](#clear_temp_hieradata)
12
+ * PKI
13
+ * [`run_fake_pki_ca_on`](#run_fake_pki_ca_on)
14
+ * [`copy_pki_to`](#copy_pki_to)
15
+ * [`copy_keydist_to`](#copy_keydist_to)
16
+ * Custom facts
17
+ * [`pfact_on`](#pfact_on)
18
+ * [`pluginsync_on`](#pluginsync_on)
19
+ * Hiera
20
+ * [`set_hieradata_on`](#set_hieradata_on)
21
+ * [`clear_temp_hieradata`](#clear_temp_hieradata)
18
22
  4. [Environment variables](#environment-variables)
19
23
  * [`BEAKER_fips`](#beaker_fips)
20
24
  * [`BEAKER_spec_prep`](#beaker_spec_prep)
@@ -50,6 +54,7 @@ Copies the local fixture modules (under `spec/fixtures/modules`) onto a list of
50
54
  `copy_fixture_modules_to( suts = hosts )`
51
55
 
52
56
 
57
+
53
58
  #### `fix_errata_on`
54
59
 
55
60
  Apply any OS fixes we need on each SUT
@@ -96,6 +101,13 @@ This simulates the output of FakeCA's `gencerts_nopass.sh` into `keydist/` and i
96
101
  `copy_keydist_to( ca_sut = master )`
97
102
 
98
103
 
104
+ #### `pfact_on`
105
+
106
+ Look up a face on a given SUT's using the `puppet fact` face. This honors whatever facter-related settings the SUT's Puppet has been configured to use (i.e., `factpath`, `stringify_facts`, etc).
107
+
108
+ `pfact_on( sut, fact_name )`
109
+
110
+
99
111
  #### `pluginsync_on`
100
112
 
101
113
  Simulates a custom fact pluginsync on given SUTs
data/Rakefile CHANGED
@@ -46,12 +46,6 @@ SIMP_RPM_BUILD when set, alters the gem produced by pkg:gem to be RPM-safe.
46
46
  }
47
47
  end
48
48
 
49
- #desc 'run all RSpec tests'
50
- #task :spec do
51
- # Dir.chdir @rakefile_dir
52
- # sh 'bundle exec rspec spec'
53
- #end
54
-
55
49
  desc %q{run all RSpec tests (alias of 'spec')}
56
50
  task :test => :spec
57
51
 
@@ -1,7 +1,15 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.0.10'
4
+ VERSION = '1.0.11'
5
+
6
+ # use the `puppet fact` face to look up facts on an SUT
7
+ def pfact_on(sut, fact_name)
8
+ facts_json = on(sut,'puppet facts find xxx').output
9
+ facts = JSON.parse(facts_json).fetch( 'values' )
10
+ facts.fetch(fact_name)
11
+ end
12
+
5
13
 
6
14
  # Locates .fixture.yml in or above this directory.
7
15
  def fixtures_yml_path
@@ -67,18 +75,20 @@ module Simp::BeakerHelpers
67
75
  STDERR.puts ' ** copy_fixture_modules_to' if ENV['BEAKER_helpers_verbose']
68
76
  ensure_fixture_modules
69
77
 
70
- suts.each do |sut|
71
- STDERR.puts " ** copy_fixture_modules_to: '#{sut}'" if ENV['BEAKER_helpers_verbose']
72
- # allow spec_prep to provide modules (to support isolated networks)
73
- unless ENV['BEAKER_use_fixtures_dir_for_modules'] == 'no'
74
- pupmods_in_fixtures_yml.each do |pupmod|
75
- STDERR.puts " ** copy_fixture_modules_to: '#{sut}': '#{pupmod}'" if ENV['BEAKER_helpers_verbose']
76
- mod_root = File.expand_path( "spec/fixtures/modules/#{pupmod}", File.dirname( fixtures_yml_path ))
77
- copy_module_to( sut, {:source => mod_root, :module_name => pupmod} )
78
+ unless ENV['BEAKER_copy_fixtures'] == 'no'
79
+ suts.each do |sut|
80
+ STDERR.puts " ** copy_fixture_modules_to: '#{sut}'" if ENV['BEAKER_helpers_verbose']
81
+ # allow spec_prep to provide modules (to support isolated networks)
82
+ unless ENV['BEAKER_use_fixtures_dir_for_modules'] == 'no'
83
+ pupmods_in_fixtures_yml.each do |pupmod|
84
+ STDERR.puts " ** copy_fixture_modules_to: '#{sut}': '#{pupmod}'" if ENV['BEAKER_helpers_verbose']
85
+ mod_root = File.expand_path( "spec/fixtures/modules/#{pupmod}", File.dirname( fixtures_yml_path ))
86
+ copy_module_to( sut, {:source => mod_root, :module_name => pupmod} )
87
+ end
78
88
  end
79
89
  end
80
- STDERR.puts ' ** copy_fixture_modules_to: finished' if ENV['BEAKER_helpers_verbose']
81
90
  end
91
+ STDERR.puts ' ** copy_fixture_modules_to: finished' if ENV['BEAKER_helpers_verbose']
82
92
 
83
93
  # sync custom facts from the new modules to each SUT's factpath
84
94
  pluginsync_on(suts) if pluginsync
@@ -147,12 +157,21 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
147
157
 
148
158
  # Apply known OS fixes we need to run Beaker on each SUT
149
159
  def fix_errata_on( suts = hosts )
150
- # SIMP uses structured facts, therefore stringify_facts must be disabled
151
- unless ENV['BEAKER_stringify_facts'] == 'yes'
152
- on suts, 'puppet config set stringify_facts false'
153
- end
154
160
 
155
161
  suts.each do |sut|
162
+ # SIMP uses structured facts, therefore stringify_facts must be disabled
163
+ unless ENV['BEAKER_stringify_facts'] == 'yes'
164
+ on sut, 'puppet config set stringify_facts false'
165
+ end
166
+
167
+ # Occasionally we run across something similar to BKR-561, so to ensure we
168
+ # at least have the host defaults:
169
+ #
170
+ # :hieradatadir is used as a canary here; it isn't the only missing key
171
+ unless sut.host_hash.key? :hieradatadir
172
+ configure_type_defaults_on(sut)
173
+ end
174
+
156
175
  if fact_on(sut, 'osfamily') == 'RedHat'
157
176
  # net-tools required for netstat utility being used by be_listening
158
177
  if fact_on(sut, 'operatingsystemmajrelease') == '7'
@@ -162,6 +181,7 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
162
181
  apply_manifest_on(sut, pp, :catch_failures => false)
163
182
  end
164
183
  end
184
+
165
185
  end
166
186
 
167
187
  # Configure and reboot SUTs into FIPS mode
@@ -169,10 +189,8 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
169
189
  enable_fips_mode_on(suts)
170
190
  end
171
191
 
172
- suts.each do |sut|
173
- # Clean up YUM prior to starting our test runs.
174
- on( sut, 'yum clean all' )
175
- end
192
+ # Clean up YUM prior to starting our test runs.
193
+ on(suts, 'yum clean all')
176
194
  end
177
195
 
178
196
 
@@ -273,17 +291,17 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
273
291
  #
274
292
  # Note: This is authoritative, you cannot mix this with other hieradata copies
275
293
  #
276
- # @param[Host, Array<Host>, String, Symbol] One or more hosts to act upon.
294
+ # @param[sut, Array<Host>, String, Symbol] One or more hosts to act upon.
277
295
  #
278
- # @param[Hieradata, Hash] The full hiera data structure to write to the system.
296
+ # @param[heradata, Hash || String] The full hiera data structure to write to the system.
279
297
  #
280
- # @param[Data_file, String] The filename (not path) of the hiera data
298
+ # @param[data_file, String] The filename (not path) of the hiera data
281
299
  # YAML file to write to the system.
282
300
  #
283
- # @param[Hiera_config, Array<String>] The hiera config array to write
301
+ # @param[hiera_config, Array<String>] The hiera config array to write
284
302
  # to the system. Must contain the
285
303
  # Data_file name as one element.
286
- def set_hieradata_on(host, hieradata, data_file='default')
304
+ def set_hieradata_on(sut, hieradata, data_file='default')
287
305
  # Keep a record of all temporary directories that are created
288
306
  #
289
307
  # Should be cleaned by calling `clear_temp_hiera data` in after(:all)
@@ -296,19 +314,24 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
296
314
  @temp_hieradata_dirs << data_dir
297
315
 
298
316
  fh = File.open(File.join(data_dir,"#{data_file}.yaml"),'w')
299
- fh.puts(hieradata.to_yaml)
317
+ if hieradata.kind_of? String
318
+ fh.puts(hieradata)
319
+ else
320
+ fh.puts(hieradata.to_yaml)
321
+ end
322
+
300
323
  fh.close
301
324
 
302
325
  # If there is already a directory on the system, the SCP below will
303
326
  # add the local directory to the existing directory instead of
304
327
  # replacing the contents.
305
328
  apply_manifest_on(
306
- host,
307
- "file { '#{hiera_datadir(host)}': ensure => 'absent', force => true, recurse => true }"
329
+ sut,
330
+ "file { '#{hiera_datadir(sut)}': ensure => 'absent', force => true, recurse => true }"
308
331
  )
309
332
 
310
- copy_hiera_data_to(host, data_dir)
311
- write_hiera_config_on(host, Array(data_file))
333
+ copy_hiera_data_to(sut, data_dir)
334
+ write_hiera_config_on(sut, Array(data_file))
312
335
  end
313
336
 
314
337
 
@@ -0,0 +1,14 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ context 'pfact_on operations' do
4
+ before(:all) do
5
+ copy_fixture_modules_to( hosts )
6
+ pluginsync_on( [master] )
7
+ end
8
+
9
+ describe "pfact_on(master,'root_home')" do
10
+ it 'should return value of root_home' do
11
+ expect( pfact_on(master, 'root_home')).to_not be_nil
12
+ end
13
+ end
14
+ end
@@ -3,8 +3,6 @@ require 'tmpdir'
3
3
 
4
4
 
5
5
  context 'PKI operations' do
6
- #test_name 'SIMP beaker helper PKI operations'
7
- begin
8
6
 
9
7
  context 'after run_fake_pki_ca_on(master,hosts)' do
10
8
  before(:all) do
@@ -64,7 +62,4 @@ begin
64
62
  end
65
63
  end
66
64
 
67
- rescue Exception => e
68
- require 'pry'; binding.pry
69
- end
70
65
  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.0.10
4
+ version: 1.0.11
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: 2015-10-27 00:00:00.000000000 Z
12
+ date: 2015-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker
@@ -52,6 +52,7 @@ files:
52
52
  - spec/acceptance/nodesets/centos-7-x64.yml
53
53
  - spec/acceptance/nodesets/centos-combined-x64.yaml
54
54
  - spec/acceptance/nodesets/default.yml
55
+ - spec/acceptance/pfacter_spec.rb
55
56
  - spec/acceptance/pki_tests_spec.rb
56
57
  - spec/spec_helper_acceptance.rb
57
58
  homepage: https://github.com/simp/rubygem-simp-beaker-helpers
@@ -84,5 +85,7 @@ test_files:
84
85
  - spec/acceptance/nodesets/centos-7-x64.yml
85
86
  - spec/acceptance/nodesets/centos-combined-x64.yaml
86
87
  - spec/acceptance/nodesets/default.yml
88
+ - spec/acceptance/pfacter_spec.rb
87
89
  - spec/acceptance/pki_tests_spec.rb
88
90
  - spec/spec_helper_acceptance.rb
91
+ has_rdoc: