beaker-answers 0.4.0 → 0.4.1

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
- ODMyZWM0NjM4ZmZlZGI0MWU1MDYzYWNlNGEyN2Y4ZGNkOWFhNGU2Mw==
4
+ N2E3NGQwNjgwMWZjOWY1MDVjNWU3MWI5MjNmN2NhZDgzNjU5Mjk5ZA==
5
5
  data.tar.gz: !binary |-
6
- YmZhOWYwOTg5OTc4ODFjN2Q1YTQxN2M4YjNhNGY5OWVjYjc2MjA2Yw==
6
+ ZmI5ODg4YWNhYTNkZmVhOTRjNDBiMjhkOThjNjZjMzU3MjVkMWU5Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWI0ZDlhM2JlNTE5MWU4MzFkMmNhNzU0YTcwZjhhMWYxYzlhMjUzZjM3YTM1
10
- MTAwODYwM2RmOGZjYjlmNzgwM2MyMzYxZTFkMzRhMmQ5NDQ0MDU2OTg0NTMx
11
- MmE4Y2ZmZDhhYWQ3ODY5Zjk5MzJjMjg5NDIxZDMwODhiYzY5YTE=
9
+ ZGQ1MmM3ZTE1YTlhNTM0ZWY5OTFlMjNhN2JlZTM0OWNhNzMzZDJhZTllZDli
10
+ YmMyYTVlZTBiMTQ3MTk4ZWQxOWRiYjhhMDdjYTNmZWIxZTVlNTcwZjlkMjgy
11
+ YzhjODZjZGVhOTUzMjJkYjM4MzkyZjc2OTI0NTk3OTNkZGY3ZTU=
12
12
  data.tar.gz: !binary |-
13
- NGViOGVjZGU2MzNhYzY2NDZiMzM5OGU4MDA1NzdkZWQ1YTYwNjRmYmU5M2Ey
14
- YjU4NDJlNmEwNDc4NDU5MjcxNGQ3N2Q2MDc1OGUwOWM0MWFiZTgxMzc4MTg1
15
- NzcwY2Q1MTQyNmJmMjIzNDViOTJhZjY5MzE5NDBlZWJjZmVkZTk=
13
+ MzczOWY2ZWJlY2Q5ZmU1NTViY2RkOTg0YjE0YTVkNDQwNGY3NGVkZWYzZTA5
14
+ ZWM0ZmUxYTY5MmNlMzkzMmYzYmI2ODYzOTc4MDAzMDE5ZjQzZjRmNzQ5ZGM4
15
+ YzExNDkyODY1OWIzYWIyMGYxNDM4NmM1NDNiYjE1YTY0ODAxYTc=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 12 Feb, 2016 (3577bbf2)](#LATEST)
3
+ * [LATEST - 28 Apr, 2016 (32ef620e)](#LATEST)
4
+ * [0.4.0 - 12 Feb, 2016 (96d0d7cf)](#0.4.0)
4
5
  * [0.3.2 - 10 Nov, 2015 (f699c033)](#0.3.2)
5
6
  * [0.3.1 - 2 Nov, 2015 (e5922067)](#0.3.1)
6
7
  * [0.3.0 - 22 Oct, 2015 (0c56067d)](#0.3.0)
@@ -10,7 +11,36 @@
10
11
  * [0.1.0 - 26 Aug, 2015 (ef47972d)](#0.1.0)
11
12
 
12
13
  ## Details
13
- ### <a name = "LATEST">LATEST - 12 Feb, 2016 (3577bbf2)
14
+ ### <a name = "LATEST">LATEST - 28 Apr, 2016 (32ef620e)
15
+
16
+ * (GEM) update beaker-answers version to 0.4.1 (32ef620e)
17
+
18
+ * Merge pull request #11 from tvpartytonight/BKR-763 (554f0405)
19
+
20
+
21
+ ```
22
+ Merge pull request #11 from tvpartytonight/BKR-763
23
+
24
+ (BKR-763) Supply only necessary answers on upgrade
25
+ ```
26
+ * (BKR-763) Supply only necessary answers on upgrade (5b1e9782)
27
+
28
+
29
+ ```
30
+ (BKR-763) Supply only necessary answers on upgrade
31
+
32
+ Previous to this commit, answer files were generated in full during
33
+ upgrade scenarios; this does not match the user workflow or what is
34
+ documented for upgrades, so we should only supply answers needed. The
35
+ answers `create` method now checks the `:type` in options and creates a
36
+ separate branch of `Answers` named `Upgrade`.
37
+
38
+ This change only affects PE 3.8 and higher; all lower versions will
39
+ continue to produce an entire answers file.
40
+ ```
41
+ ### <a name = "0.4.0">0.4.0 - 12 Feb, 2016 (96d0d7cf)
42
+
43
+ * (HISTORY) update beaker-answers history for gem release 0.4.0 (96d0d7cf)
14
44
 
15
45
  * (GEM) update beaker-answers version to 0.4.0 (3577bbf2)
16
46
 
@@ -4,6 +4,7 @@ module BeakerAnswers
4
4
  class Answers
5
5
 
6
6
  DEFAULT_ANSWERS = StringifyHash.new.merge({
7
+ :q_install => 'y',
7
8
  :q_puppet_enterpriseconsole_auth_user_email => 'admin@example.com',
8
9
  :q_puppet_enterpriseconsole_auth_password => '~!@#$%^*-/ aZ',
9
10
  :q_puppet_enterpriseconsole_smtp_port => 25,
@@ -47,6 +48,12 @@ module BeakerAnswers
47
48
  BeakerAnswers.constants.select {|c| BeakerAnswers.const_get(c).is_a?(Class) && BeakerAnswers.const_get(c).respond_to?(:pe_version_matcher)}
48
49
  end
49
50
 
51
+ # Determine the list of supported upgrade PE versions, return as an array
52
+ # @return [Array<String>] An array of the supported versions
53
+ def self.supported_upgrade_versions
54
+ BeakerAnswers.constants.select {|c| BeakerAnswers.const_get(c).is_a?(Class) && BeakerAnswers.const_get(c).respond_to?(:upgrade_version_matcher)}
55
+ end
56
+
50
57
  # When given a Puppet Enterprise version, a list of hosts and other
51
58
  # qualifying data this method will return the appropriate object that can be used
52
59
  # to generate answer file data.
@@ -58,6 +65,15 @@ module BeakerAnswers
58
65
  # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
59
66
  # data.
60
67
  def self.create version, hosts, options
68
+ # if :upgrade is detected, then we return the simpler upgrade answers
69
+ if options[:type] == :upgrade
70
+ self.supported_upgrade_versions.each do |upgrade_version_class|
71
+ if BeakerAnswers.const_get(upgrade_version_class).send(:upgrade_version_matcher) =~ version
72
+ return BeakerAnswers.const_get(upgrade_version_class).send(:new, version, hosts, options)
73
+ end
74
+ end
75
+ warn 'Only upgrades to version 3.8 and above generate specific upgrade answers. Defaulting to full answers.'
76
+ end
61
77
 
62
78
  # finds all potential version classes
63
79
  # discovers new version classes as they are added, no more crazy case statement
@@ -1,5 +1,5 @@
1
1
  module BeakerAnswers
2
2
  module Version
3
- STRING = '0.4.0'
3
+ STRING = '0.4.1'
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ module BeakerAnswers
2
+ # In the case of upgrades, we lay down a much simpler file
3
+ class Upgrade < Answers
4
+
5
+ def self.upgrade_version_matcher
6
+ /\A2015\.[123]|\A2016\.[1234]/
7
+ end
8
+
9
+ def generate_answers
10
+ the_answers = {}
11
+ @hosts.each do |host|
12
+ the_answers[host.name] = {:q_install => answer_for(@options, :q_install)}
13
+ # merge custom host answers if available
14
+ the_answers[host.name] = the_answers[host.name].merge(host[:custom_answers]) if host[:custom_answers]
15
+ end
16
+ the_answers
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ module BeakerAnswers
2
+ # In the case of upgrades, we lay down a much simpler file
3
+ class Upgrade38 < Upgrade
4
+
5
+ def self.upgrade_version_matcher
6
+ /\A3\.8/
7
+ end
8
+
9
+ def generate_answers
10
+ the_answers = super
11
+ the_answers.map do |hostname, answers|
12
+ # First check to see if there is a host option for this setting
13
+ # and skip to the next object if it is already defined.
14
+ if the_answers[hostname][:q_enable_future_parser]
15
+ next
16
+ # Check now if it was set in the global options.
17
+ elsif @options[:answers] && @options[:answers][:q_enable_future_parser]
18
+ the_answers[hostname][:q_enable_future_parser] = @options[:answers][:q_enable_future_parser]
19
+ next
20
+ # If we didn't set it on a per host or global option basis, set it to
21
+ # 'y' here. We could have possibly set it in the DEFAULT_ANSWERS, but it
22
+ # is unclear what kind of effect that might have on all the other answers
23
+ # that rely on it defaulting to 'n'.
24
+ else
25
+ the_answers[hostname][:q_enable_future_parser] = 'y'
26
+ end
27
+ end
28
+ the_answers
29
+ end
30
+ end
31
+ end
@@ -29,6 +29,35 @@ describe BeakerAnswers do
29
29
  end
30
30
  end
31
31
 
32
+ context 'when we are upgrading to a version > 3.8' do
33
+ supported_general_upgrade_versions = [ '2015.1.0',
34
+ '2016.1.0',
35
+ '2016.2.1']
36
+ supported_general_upgrade_versions.each do |version|
37
+ it "the version #{version} generates general upgrade answers" do
38
+ @ver = version
39
+ options[:type] = :upgrade
40
+ expect( answers ).to be_a_kind_of BeakerAnswers::Upgrade
41
+ end
42
+ end
43
+ end
44
+
45
+ it 'generates upgrade38 answers when type is upgrade and the version 3.8' do
46
+ @ver = '3.8.3'
47
+ options[:type] = :upgrade
48
+ expect( answers ).to be_a_kind_of BeakerAnswers::Upgrade38
49
+ end
50
+
51
+ it 'generates 2016.2 answers for 2016.2 hosts' do
52
+ @ver = '2016.2.0'
53
+ expect( answers ).to be_a_kind_of BeakerAnswers::Version20162
54
+ end
55
+
56
+ it 'generates 2016.1 answers for 2016.1 hosts' do
57
+ @ver = '2016.1.0'
58
+ expect( answers ).to be_a_kind_of BeakerAnswers::Version20161
59
+ end
60
+
32
61
  it 'generates 2015.3 answers for 2015.3 hosts' do
33
62
  @ver = '2015.3.0'
34
63
  expect( answers ).to be_a_kind_of BeakerAnswers::Version20153
@@ -319,6 +348,99 @@ describe BeakerAnswers::Version40 do
319
348
  end
320
349
  end
321
350
 
351
+ describe BeakerAnswers::Upgrade do
352
+
353
+ let( :options ) { StringifyHash.new }
354
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
355
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
356
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
357
+ basic_hosts[2]['roles'] = ['database', 'agent']
358
+ basic_hosts }
359
+ let( :answers ) { BeakerAnswers::Answers.create(@ver, hosts, options.merge({:type => :upgrade}) ) }
360
+
361
+ before :each do
362
+ @ver = '2015.3'
363
+ @answers = answers.answers
364
+ end
365
+
366
+ context 'when per host custom answers are provided for the master and dashboard' do
367
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
368
+ basic_hosts[0][:custom_answers] = { :q_custom0 => '0LOOK' }
369
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
370
+ basic_hosts[1][:custom_answers] = { :q_custom1 => 'LOOKLOOK',
371
+ :q_custom2 => "LOOK3"}
372
+ basic_hosts[2]['roles'] = ['database', 'agent']
373
+ basic_hosts }
374
+
375
+ it 'adds those custom answers to the master' do
376
+ expect( @answers['vm1'][:q_custom0] ).to be === '0LOOK'
377
+ expect( @answers['vm1'][:q_install] ).to eq('y')
378
+ expect( @answers['vm1'].size).to eq(2)
379
+ end
380
+
381
+ it 'adds custom answers to the dashboard' do
382
+ expect( @answers['vm2'][:q_custom1] ).to be === 'LOOKLOOK'
383
+ expect( @answers['vm2'][:q_custom2] ).to be === 'LOOK3'
384
+ expect( @answers['vm2'][:q_install] ).to eq('y')
385
+ expect( @answers['vm2'].size).to eq(3)
386
+ end
387
+
388
+ it 'does not add custom answers for the database' do
389
+ expect(@answers['vm3'][:q_install]).to eq('y')
390
+ expect(@answers['vm3'].length).to eq(1)
391
+ end
392
+ end
393
+
394
+ context 'when no custom answers are provided' do
395
+ it "each answer should have only one key for :q_install" do
396
+ @answers.each do |vmname, answer|
397
+ expect(answer[:q_install]).to eq('y')
398
+ expect(answer.length).to eq(1)
399
+ end
400
+ end
401
+ end
402
+ end
403
+
404
+ describe BeakerAnswers::Upgrade38 do
405
+
406
+ let( :options ) { StringifyHash.new }
407
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
408
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
409
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
410
+ basic_hosts[2]['roles'] = ['database', 'agent']
411
+ basic_hosts }
412
+ let( :answers ) { BeakerAnswers::Answers.create(@ver, hosts, options.merge({:type => :upgrade}) ) }
413
+
414
+ before :each do
415
+ @ver = '3.8'
416
+ @answers = answers.answers
417
+ end
418
+
419
+ context 'when no special answers are provided' do
420
+ it "each answer should have only two keys" do
421
+ @answers.each do |vmname, answer|
422
+ expect(answer[:q_install]).to eq('y')
423
+ expect(answer[:q_enable_future_parser]).to eq('y')
424
+ expect(answer.length).to eq(2)
425
+ end
426
+ end
427
+ end
428
+
429
+ context 'when we set :q_enable_future_parser in global options' do
430
+ let( :options ) {
431
+ options = StringifyHash.new
432
+ options[:answers] = { :q_enable_future_parser => 'thefutureparser!!!'}
433
+ options
434
+ }
435
+ it 'sets that parser option from the global options' do
436
+ @answers.each do |vmname, answer|
437
+ expect(answer[:q_enable_future_parser]).to eq('thefutureparser!!!')
438
+ end
439
+ end
440
+
441
+ end
442
+ end
443
+
322
444
  describe BeakerAnswers::Version20153 do
323
445
  let( :options ) { StringifyHash.new }
324
446
  let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-answers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-12 00:00:00.000000000 Z
12
+ date: 2016-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -186,6 +186,8 @@ files:
186
186
  - lib/beaker-answers.rb
187
187
  - lib/beaker-answers/answers.rb
188
188
  - lib/beaker-answers/version.rb
189
+ - lib/beaker-answers/versions/upgrade.rb
190
+ - lib/beaker-answers/versions/upgrade38.rb
189
191
  - lib/beaker-answers/versions/version20.rb
190
192
  - lib/beaker-answers/versions/version20153.rb
191
193
  - lib/beaker-answers/versions/version20161.rb