simp-beaker-helpers 1.0.1 → 1.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +22 -1
  3. data/lib/simp/beaker_helpers.rb +71 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTk1ZjQ3NGYyNTNhZDYyY2QyYzU2MTJiMDAxMWE1ZjBmOTMzZWRlNg==
4
+ ODM2YjI2ODAyMWI3MjEzOTY3YWRlNTUyYjRmMDcyOGM2YzlmOWU1YQ==
5
5
  data.tar.gz: !binary |-
6
- MTcwMmM2MmY5NGU2MjkwYTE5MmMxMWQ3YTBjNTFlNzUzYzZkMzE5MA==
6
+ MmZhNDZiMGE2ODQ3YTAwNTA4OTE3Y2FjYzYxZjliNGM4NmE3NDZjZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGNiZjU1ZmY0MDA5ODRhYzYxYWI0NTNiOTE2NWM5Yjk0YjM1ODFjMmQ4MDEz
10
- OTg4ZWZiYmU5NzgxYmQ4ZTAzNWU3Y2M1NDE1ZjgxY2ViODRiY2FiZWU4ODM4
11
- NzhkZTkxZjc3OWU1YWU2Njg1MzQ2MTJiYzA3MGE1MDVkODVmZGU=
9
+ ZjM1MGNkZWQ0Nzg0N2M2YmY2MTk1YjI0ZmZkYzVlMWU5OGVmZDJmMDQ1NjU4
10
+ NWQ5MmU5ODE0OTAyN2NjNjRhNmE1NDM5OGY4NjM1NTMwNDc4MzNlNTg3ZjNl
11
+ ODBjYjgwNmU3YWE1MzFiN2NmZGM0OGRjNmFlMWJhYTQwOWUwYjU=
12
12
  data.tar.gz: !binary |-
13
- YWJlNGM4ZjFmZDI0ZDIxYTA0OTI2NThjMzk5NWZmNzZhZDA2NTI5ZGExMjM2
14
- MjE1YzBkMGVhYmZiNTc3NzViM2RjOWVhN2Q1NTMwOGJjY2JiOTgxMjVjYTU1
15
- N2E2OTU0YjU1Y2JlN2ZiMmYwMDBhYjU5MDVlZTlmMTcxZWZlMGY=
13
+ MGEzZTk1ZWZhOTQyNjczY2YzYTZmZDUzNGQwNTViMTFjYjlmMjAyZGU0Zjk5
14
+ YzQwM2UxNmRlNGM4M2M3NTBkMGY0NTgxOTJkOWUyYzM2NTFhMmJiNzQ4N2Y2
15
+ MmE1YzcyMmIwM2JjYTdjNzBiYmI2ZTllYjNiOWQ1Y2Y3YThiZTY=
data/README.md CHANGED
@@ -12,6 +12,8 @@ Methods to assist beaker acceptance tests for SIMP.
12
12
  * [`run_fake_pki_ca_on`](#run_fake_pki_ca_on)
13
13
  * [`copy_pki_to`](#copy_pki_to)
14
14
  * [`copy_keydist_to`](#copy_keydist_to)
15
+ * [`set_hieradata_on`](#set_hieradata_on)
16
+ * [`clear_temp_hieradata`](#clear_temp_hieradata)
15
17
  4. [Examples](#examples)
16
18
  * [Prep OS, Generate and copy PKI certs to each SUT](#prep-os-generate-and-copy-pki-certs-to-each-sut)
17
19
  5. [License](#license)
@@ -82,13 +84,32 @@ The directory structure copied to the SUT is:
82
84
 
83
85
  #### `copy_keydist_to`
84
86
 
85
- Copy a CA keydist/ directory of CA+host certs into an SUT
87
+ Copy a CA keydist/ directory of CA+host certs into an SUT
86
88
 
87
89
  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.
88
90
 
89
91
  `def copy_keydist_to( ca_sut = master )`
90
92
 
91
93
 
94
+ #### `set_hieradata_on`
95
+
96
+ Set the hiera data file on the provided host to the passed data structure
97
+
98
+ **NOTE**: This is authoritative; you cannot mix this with other hieradata copies
99
+
100
+ `set_hieradata_on(host, hieradata, data_file='default')`
101
+
102
+ - **host** = _(Array,String,Symbol)_ One or more hosts to act upon
103
+ - **hieradata** = _(Hash)_ The full hiera data structure to write to the system
104
+ - **data_file** = _(String)_ The filename (not path) of the hiera data
105
+
106
+ #### `clear_temp_hieradata`
107
+
108
+ Clean up all temporary hiera data files; meant to be called from `after(:all)`
109
+
110
+ `clear_temp_hieradata`
111
+
112
+
92
113
  ## Examples
93
114
 
94
115
  ### Prep OS, Generate and copy PKI certs to each SUT
@@ -1,7 +1,7 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
 
6
6
  # Locates .fixture.yml in or above this directory.
7
7
  def fixtures_yml_path
@@ -68,6 +68,11 @@ module Simp::BeakerHelpers
68
68
 
69
69
  # Apply known OS fixes we need to run Beaker on each SUT
70
70
  def fix_errata_on( suts = hosts )
71
+ # SIMP uses structured facts, therefore stringify_facts must be disabled
72
+ unless ENV['BEAKER_stringify_facts'] == 'yes'
73
+ on suts, 'puppet config set stringify_facts false'
74
+ end
75
+
71
76
  suts.each do |sut|
72
77
  # net-tools required for netstat utility being used by be_listening
73
78
  if fact_on(sut, 'osfamily') == 'RedHat' && fact_on(sut, 'operatingsystemmajrelease') == '7'
@@ -144,4 +149,69 @@ module Simp::BeakerHelpers
144
149
  on ca_sut, "cp -a /root/pki/keydist/ #{modulepath.first}/pki/files/"
145
150
  on ca_sut, "chgrp -R puppet #{modulepath.first}/pki/files/keydist"
146
151
  end
152
+
153
+ ## Inline Hiera Helpers ##
154
+ ## These will be integrated into core Beaker at some point ##
155
+
156
+ # Set things up for the inline hieradata functions 'set_hieradata_on'
157
+ # and 'clear_temp_hieradata'
158
+ #
159
+ #
160
+ require 'rspec'
161
+ RSpec.configure do |c|
162
+ c.before(:all) do
163
+ @temp_hieradata_dirs = @temp_hieradata_dirs || []
164
+ end
165
+
166
+ c.after(:all) do
167
+ clear_temp_hieradata
168
+ end
169
+ end
170
+
171
+ # Set the hiera data file on the provided host to the passed data structure
172
+ #
173
+ # Note: This is authoritative, you cannot mix this with other hieradata copies
174
+ #
175
+ # @param[Host, Array<Host>, String, Symbol] One or more hosts to act upon.
176
+ #
177
+ # @param[Hieradata, Hash] The full hiera data structure to write to the system.
178
+ #
179
+ # @param[Data_file, String] The filename (not path) of the hiera data
180
+ # YAML file to write to the system.
181
+ #
182
+ # @param[Hiera_config, Array<String>] The hiera config array to write
183
+ # to the system. Must contain the
184
+ # Data_file name as one element.
185
+ def set_hieradata_on(host, hieradata, data_file='default')
186
+ # Keep a record of all temporary directories that are created
187
+ #
188
+ # Should be cleaned by calling `clear_temp_hiera data` in after(:all)
189
+ #
190
+ # Omit this call to be able to delve into the hiera data that is
191
+ # being created
192
+ @temp_hieradata_dirs = @temp_hieradata_dirs || []
193
+
194
+ data_dir = Dir.mktmpdir('hieradata')
195
+ @temp_hieradata_dirs << data_dir
196
+
197
+ fh = File.open(File.join(data_dir,"#{data_file}.yaml"),'w')
198
+ fh.puts(hieradata.to_yaml)
199
+ fh.close
200
+
201
+ copy_hiera_data_to(host, data_dir)
202
+ write_hiera_config_on(host, Array(data_file))
203
+ end
204
+
205
+ # Clean up all temporary hiera data files.
206
+ #
207
+ # Meant to be called from after(:all)
208
+ def clear_temp_hieradata
209
+ if @temp_hieradata_dirs && !@temp_hieradata_dirs.empty?
210
+ @temp_hieradata_dirs.each do |data_dir|
211
+ if File.exists?(data_dir)
212
+ FileUtils.rm_r(data_dir)
213
+ end
214
+ end
215
+ end
216
+ end
147
217
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beaker