beaker-answers 0.12.0 → 0.13.0

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
- Yzc1NGQ4ZmZiOTc3ZjQyYTc2NDQ0MjJhMzk0ZTg4MzRjYzBmNGQxZA==
4
+ NjEwZDM2NjVhN2I5NmExMTNiNDMzOTE3MDE0Nzk3ODJlMTJlNWYwYg==
5
5
  data.tar.gz: !binary |-
6
- ZjQyZDIzNjgwYzk3ZGJmZWQxY2YzNzJkZWFmYThmYjY3N2NmNjA1ZQ==
6
+ ZjVkNzMwZmVmY2ExMmZmMjEyYTFlOTUxM2VjM2M1OWJlNTRlZmIzNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWNkZmI1MTNhNDQ3MWQyY2Y5YmU4N2YwYjM4Mjg3MTQ5MzE4ZWFmYzJlNGIw
10
- ZDNlNjY3ZTQxZDJlM2VlZTMyMGUyNjY4MjQwNTRmYWY4OTRmMThmMTJlZmMz
11
- NGU5Yjk3Nzc5Mzg3MWUzYTdlMTMyNzlkNmFkNWVkMjk2ZDQ5Y2M=
9
+ ZDM5NDQ0NmQyMzA2ZDUxODY0NTBiZmM0N2ExNzJiNjJiOTRiYzE2NWE4NzE2
10
+ NWZlZDgzMDBiNDMxMTBkYzI1MzJmYTI4ZGUzOTY1N2I3YTllMmVhZGU5MTli
11
+ MDIyYzIwM2Y0MDVjNGUwYTI1NGM3OGMxOWRhOGEzYmQ3ZjUxOGE=
12
12
  data.tar.gz: !binary |-
13
- MjlhZmQ2MTc1NjE0N2Q2NzRjMzMwMjg4ZDEzZjdjOTY3NmI3ZGRhNmVmOTQz
14
- NWFhYjc0M2UwZDEwNDYwZWI5Nzg5ZjBmYTBlYjRjYjQ4OGE0ZGE5NGJkNjM3
15
- ZGE1YTM0NDUzNWI1YTI0MDFjYjI2MjY3YThhZmE5MmE1ZmQ0OWQ=
13
+ ODA5MGIyOWQxZGZhNDdkNWFiMTRlNWY2OTg4YTFjOTZlODgzNGZjNjM1MDIx
14
+ ODIxYzNhNThjM2VhNTA1NjM4ZDQ4NWVlNjQ2Y2E4MWE3YjkxOGY0MWQxYmMz
15
+ Mjk2NTEzZDU3NjAzZGM3OTllYjNlNjJjMjNhNmRiMDcxODFlMzk=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 28 Oct, 2016 (4e1716ad)](#LATEST)
3
+ * [LATEST - 9 Nov, 2016 (f415b5e1)](#LATEST)
4
+ * [0.12.0 - 28 Oct, 2016 (b18d96b7)](#0.12.0)
4
5
  * [0.11.0 - 22 Aug, 2016 (39591691)](#0.11.0)
5
6
  * [0.10.0 - 15 Aug, 2016 (30507062)](#0.10.0)
6
7
  * [0.9.0 - 1 Aug, 2016 (551ce473)](#0.9.0)
@@ -23,7 +24,69 @@
23
24
  * [0.1.0 - 26 Aug, 2015 (ef47972d)](#0.1.0)
24
25
 
25
26
  ## Details
26
- ### <a name = "LATEST">LATEST - 28 Oct, 2016 (4e1716ad)
27
+ ### <a name = "LATEST">LATEST - 9 Nov, 2016 (f415b5e1)
28
+
29
+ * (GEM) update beaker-answers version to 0.13.0 (f415b5e1)
30
+
31
+ * Merge pull request #28 from jpartlow/issue/2017.1.x/pe-17621-beaker-answers-generates-meep-node-roles (9becfcb3)
32
+
33
+
34
+ ```
35
+ Merge pull request #28 from jpartlow/issue/2017.1.x/pe-17621-beaker-answers-generates-meep-node-roles
36
+
37
+ (PE-17621) Beaker answers generates meep node roles
38
+ ```
39
+ * (PE-17621) Validate both old and new formats (138e7780)
40
+
41
+
42
+ ```
43
+ (PE-17621) Validate both old and new formats
44
+
45
+ in the corresponding PE version tests.
46
+ ```
47
+ * (PE-17621) Generate node_roles in 2017.1+ pe_conf (ea795b85)
48
+
49
+
50
+ ```
51
+ (PE-17621) Generate node_roles in 2017.1+ pe_conf
52
+
53
+ MEEP 2.0 introduces a node_roles hash in pe.conf for classification.
54
+ This supercedes using the puppet_enterprise host parameters as a de
55
+ facto classification. The Version20171 class maps existing beaker role
56
+ aliases to the new role strings used for classification in pe.conf.
57
+
58
+ So, from a MEEP 1.0 version pe.conf such as:
59
+
60
+ {
61
+ "puppet_enterprise::puppet_master_host": "master.net"
62
+ "puppet_enterprise::puppetdb_host": "puppetdb.net"
63
+ "puppet_enterprise::console_host": "console.net"
64
+ }
65
+
66
+ You now have a 2.0 version that looks like:
67
+
68
+ {
69
+ "node_roles": {
70
+ "pe_role::split::primary_master": ["master.net"]
71
+ "pe_role::split::puppetdb": ["puppetdb.net"]
72
+ "pe_role::split::console": ["console.net"]
73
+ }
74
+ }
75
+
76
+ See the pe_manager and pe_infrastructure modules for more details.
77
+ ```
78
+ * (PE-17621) Move shared examples into a separate file (30e27482)
79
+
80
+
81
+ ```
82
+ (PE-17621) Move shared examples into a separate file
83
+
84
+ ...included by default in spec_helper.rb. Without this, running the
85
+ version20163_spec.rb by itself fails.
86
+ ```
87
+ ### <a name = "0.12.0">0.12.0 - 28 Oct, 2016 (b18d96b7)
88
+
89
+ * (HISTORY) update beaker-answers history for gem release 0.12.0 (b18d96b7)
27
90
 
28
91
  * (GEM) update beaker-answers version to 0.12.0 (4e1716ad)
29
92
 
@@ -1,5 +1,5 @@
1
1
  module BeakerAnswers
2
2
  module Version
3
- STRING = '0.12.0'
3
+ STRING = '0.13.0'
4
4
  end
5
5
  end
@@ -9,5 +9,75 @@ module BeakerAnswers
9
9
  def self.pe_version_matcher
10
10
  /\A2017\.1/
11
11
  end
12
+
13
+ # This lists various aliases for different PE components that might
14
+ # be installed on a host.
15
+ #
16
+ # The first entry in the list is the canonical name for the
17
+ # component from the PuppetX::Puppetlabs::Meep::Config.pe_components()
18
+ # from the pe_infrastructure module.
19
+ #
20
+ # Secondary aliases are the various working names that have been used
21
+ # with beaker in CI to establish that a host has that component
22
+ # installed on it.
23
+ COMPONENTS = [
24
+ ["primary_master", "master"],
25
+ ["primary_master_replica"],
26
+ # the 'database' alias will be troublesome if/when we begin
27
+ # breaking out a managed database (as opposed to external)
28
+ # in future PE layouts.
29
+ ["puppetdb", "database"],
30
+ ["console", "classifier", "dashboard"],
31
+ ["compile_master"],
32
+ ["mco_hub", "hub"],
33
+ ["mco_broker", "spoke"],
34
+ ]
35
+
36
+ # @param host_role_aliases [Array<String>] list of strings to search for in
37
+ # each host's role array
38
+ # @return [Array<String>] of hostnames from @hosts that include at least
39
+ # one of the passed aliases
40
+ def all_hosts_with_component(host_role_aliases)
41
+ hosts = @hosts.select do |h|
42
+ !(Array(h['roles']) & host_role_aliases).empty?
43
+ end
44
+ hosts.map { |h| h.hostname }
45
+ end
46
+
47
+ # This used to generate the profile host parameters, but now generates a MEEP
48
+ # 2.0 node_roles hash mapping roles -> node certs based on the same host and
49
+ # role information.
50
+ def hiera_host_config
51
+ pe_conf = {
52
+ "node_roles" => {}
53
+ }
54
+ hosts_by_component = {}
55
+
56
+ COMPONENTS.each do |aliases|
57
+ meep_component_name = aliases.first
58
+ hosts_by_component[meep_component_name] = all_hosts_with_component(aliases)
59
+ end
60
+
61
+ # Reject console and puppetdb lists if they are the same as master
62
+ hosts_by_component.reject! do |component,hosts|
63
+ ["puppetdb", "console"].include?(component) &&
64
+ hosts_by_component["primary_master"].sort == hosts.sort
65
+ end
66
+
67
+ # Which is also sufficient to determine our architecture at the moment
68
+ architecture = (hosts_by_component.keys & ["puppetdb", "console"]).empty? ?
69
+ "monolithic" :
70
+ "split"
71
+
72
+ hosts_by_component.reduce(pe_conf) do |conf,entry|
73
+ component, hosts = entry
74
+ if !hosts.empty?
75
+ conf["node_roles"]["pe_role::#{architecture}::#{component}"] = hosts
76
+ end
77
+ conf
78
+ end
79
+
80
+ pe_conf
81
+ end
12
82
  end
13
83
  end
@@ -1,182 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'json'
3
3
 
4
- RSpec.shared_examples 'pe.conf' do
5
- let( :options ) { { :format => 'hiera' } }
6
- let( :answer_hiera ) { answers.answer_hiera }
7
- let( :default_password ) { '~!@#$%^*-/ aZ' }
8
- let( :gold_db_answers ) do
9
- {
10
- "puppet_enterprise::activity_database_user" => 'adsfglkj',
11
- "puppet_enterprise::classifier_database_user" => 'DFGhjlkj',
12
- "puppet_enterprise::orchestrator_database_user" => 'Orc3Str8R',
13
- "puppet_enterprise::puppetdb_database_user" => 'mYpdBu3r',
14
- "puppet_enterprise::rbac_database_user" => 'RbhNBklm',
15
- }
16
- end
17
- let( :gold_db_password_answers ) do
18
- {
19
- "puppet_enterprise::activity_database_password" => default_password,
20
- "puppet_enterprise::classifier_database_password" => default_password,
21
- "puppet_enterprise::orchestrator_database_password" => default_password,
22
- "puppet_enterprise::puppetdb_database_password" => default_password,
23
- "puppet_enterprise::rbac_database_password" => default_password,
24
- }
25
- end
26
- # This is a set of database parameters specified in host.cfg :answers
27
- # (for an external postgres, for instance)
28
- let( :overridden_database_parameters ) do
29
- {
30
- "puppet_enterprise::activity_database_name" => 'custom-activity',
31
- "puppet_enterprise::activity_database_user" => 'custom-activity-user',
32
- "puppet_enterprise::classifier_database_name" => 'custom-classifier',
33
- "puppet_enterprise::classifier_database_user" => 'custom-classifier-user',
34
- "puppet_enterprise::orchestrator_database_name" => 'custom-orchestrator',
35
- "puppet_enterprise::orchestrator_database_user" => 'custom-orchestrator-user',
36
- "puppet_enterprise::puppetdb_database_name" => 'custom-puppetdb',
37
- "puppet_enterprise::puppetdb_database_user" => 'custom-puppetdb-user',
38
- "puppet_enterprise::rbac_database_name" => 'custom-rbac',
39
- "puppet_enterprise::rbac_database_user" => 'custom-rbac-user',
40
- "puppet_enterprise::activity_database_password" => 'custom-activity-password',
41
- "puppet_enterprise::classifier_database_password" => 'custom-classifier-password',
42
- "puppet_enterprise::orchestrator_database_password" => 'custom-orchestrator-password',
43
- "puppet_enterprise::puppetdb_database_password" => 'custom-puppetdb-password',
44
- "puppet_enterprise::rbac_database_password" => 'custom-rbac-password',
45
- }
46
- end
47
- let( :overridding_parameters ) do
48
- {
49
- 'puppet_enterprise::certificate_authority_host' => 'enterpriseca.vm',
50
- 'puppet_enterprise::console_host' => 'enterpriseconsole.vm',
51
- 'console_admin_password' => 'testing123',
52
- }
53
- end
54
- let( :gold_answers_with_overrides ) { gold_role_answers.merge(overridding_parameters) }
55
-
56
- it 'should not have nil keys or values' do
57
- answer_hash.each_pair { |k, v|
58
- expect([k, v]).not_to include(nil)
59
- }
60
- end
61
-
62
- it 'has the just the role and values for default install' do
63
- expect(answer_hash).to eq(
64
- gold_role_answers
65
- )
66
- end
67
-
68
- context 'when include_legacy_database_defaults' do
69
- context 'is false' do
70
- let(:options) do
71
- {
72
- :format => 'hiera',
73
- :include_legacy_database_defaults => false,
74
- }
75
- end
76
-
77
- it 'has only the role values' do
78
- expect(answer_hash).to eq(gold_role_answers)
79
- end
80
-
81
- it 'also includes any explicitly added database parameters' do
82
- options.merge!(:answers => overridden_database_parameters)
83
- expect(answer_hash).to eq(
84
- gold_role_answers
85
- .merge(overridden_database_parameters)
86
- )
87
- end
88
- end
89
-
90
- context 'is true' do
91
- let(:options) do
92
- {
93
- :format => 'hiera',
94
- :include_legacy_database_defaults => true,
95
- }
96
- end
97
-
98
- it 'has the role values and database defaults' do
99
- expect(answer_hash).to eq(
100
- gold_role_answers
101
- .merge(gold_db_answers)
102
- )
103
- end
104
-
105
- it 'overrides defaults with explicitly added database parameters' do
106
- options.merge!(:answers => overridden_database_parameters)
107
- expect(answer_hash).to eq(
108
- gold_role_answers
109
- .merge(overridden_database_parameters)
110
- )
111
- end
112
- end
113
- end
114
-
115
- it 'generates valid json if #answer_hiera is called' do
116
- expect(answer_hiera).not_to be_empty
117
- expect { JSON.load(answer_hiera) }.not_to raise_error
118
- expect(answer_hiera).to match "puppet_enterprise::puppet_master_host.*:.*#{basic_hosts[0].hostname}"
119
- end
120
-
121
- context 'with legacy answers present' do
122
- let(:string_answer) { { 'q_puppet_enterpriseconsole_auth_password' => 'password' } }
123
- let(:symbol_answer) { { :q_puppet_enterpriseconsole_auth_password => 'password' } }
124
- let(:answers) { BeakerAnswers::Answers.create(ver, hosts, options) }
125
-
126
- context 'when key is a string' do
127
- let(:options) { { :format => 'hiera' }.merge(:answers => string_answer) }
128
-
129
- it 'raises a TypeError' do
130
- expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/)
131
- end
132
- end
133
-
134
- context 'when key is a symbol' do
135
- let(:options) { { :format => 'hiera' }.merge(:answers => symbol_answer) }
136
-
137
- it 'raises a TypeError' do
138
- expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/)
139
- end
140
- end
141
- end
142
-
143
- context 'when overriding answers' do
144
- let( :options ) do
145
- {
146
- :format => 'hiera',
147
- :answers => {
148
- 'puppet_enterprise' => { 'certificate_authority_host' => 'enterpriseca.vm' },
149
- 'puppet_enterprise::console_host' => 'enterpriseconsole.vm',
150
- 'console_admin_password' => 'testing123',
151
- }
152
- }
153
- end
154
-
155
- it 'matches expected answers' do
156
- expect(answer_hash).to eq(gold_answers_with_overrides)
157
- end
158
- end
159
-
160
- context 'when overriding answers using symbolic keys' do
161
- let( :options ) do
162
- {
163
- :format => 'hiera',
164
- :answers => {
165
- :puppet_enterprise => {
166
- :certificate_authority_host => 'enterpriseca.vm',
167
- :console_host => 'enterpriseconsole.vm',
168
- },
169
- :console_admin_password => 'testing123',
170
- }
171
- }
172
- end
173
-
174
- it 'matches expected answers' do
175
- expect(answer_hash).to eq(gold_answers_with_overrides)
176
- end
177
- end
178
- end
179
-
180
4
  describe BeakerAnswers::Version20162 do
181
5
  let( :ver ) { '2016.2.0' }
182
6
  let( :options ) { StringifyHash.new }
@@ -202,6 +26,7 @@ describe BeakerAnswers::Version20162 do
202
26
  end
203
27
 
204
28
  include_examples 'pe.conf'
29
+ include_examples 'valid MEEP 1.0 pe.conf'
205
30
  end
206
31
 
207
32
  context 'for a split install' do
@@ -216,6 +41,7 @@ describe BeakerAnswers::Version20162 do
216
41
  end
217
42
 
218
43
  include_examples 'pe.conf'
44
+ include_examples 'valid MEEP 1.0 pe.conf'
219
45
  end
220
46
  end
221
47
  end
@@ -25,6 +25,7 @@ describe BeakerAnswers::Version20163 do
25
25
  end
26
26
 
27
27
  include_examples 'pe.conf'
28
+ include_examples 'valid MEEP 1.0 pe.conf'
28
29
  end
29
30
 
30
31
  context 'for a split install' do
@@ -38,6 +39,7 @@ describe BeakerAnswers::Version20163 do
38
39
  end
39
40
 
40
41
  include_examples 'pe.conf'
42
+ include_examples 'valid MEEP 1.0 pe.conf'
41
43
  end
42
44
  end
43
45
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe BeakerAnswers::Version20171 do
5
+ let( :ver ) { '2017.1.0' }
6
+ let( :options ) { StringifyHash.new }
7
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => ver } ) }
8
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
9
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
10
+ basic_hosts[2]['roles'] = ['database', 'agent']
11
+ basic_hosts }
12
+ let( :answers ) { BeakerAnswers::Answers.create(ver, hosts, options) }
13
+ let( :answer_hash ) { answers.answers }
14
+
15
+ context 'when generating a hiera config' do
16
+ context 'for a monolithic install' do
17
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => ver }, 1 ) }
18
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent', 'dashboard', 'database']
19
+ basic_hosts }
20
+ let( :gold_role_answers ) do
21
+ {
22
+ "console_admin_password" => default_password,
23
+ "node_roles" => {
24
+ "pe_role::monolithic::primary_master" => [basic_hosts[0].hostname],
25
+ }
26
+ }
27
+ end
28
+
29
+ it "accepts overrides to node_roles from beaker conf answers"
30
+
31
+ include_examples 'pe.conf'
32
+ include_examples 'valid MEEP 2.0 pe.conf'
33
+ end
34
+
35
+ context 'for a split install' do
36
+ let( :gold_role_answers ) do
37
+ {
38
+ "console_admin_password" => default_password,
39
+ "node_roles" => {
40
+ "pe_role::split::primary_master" => [basic_hosts[0].hostname],
41
+ "pe_role::split::console" => [basic_hosts[1].hostname],
42
+ "pe_role::split::puppetdb" => [basic_hosts[2].hostname],
43
+ }
44
+ }
45
+ end
46
+
47
+ include_examples 'pe.conf'
48
+ include_examples 'valid MEEP 2.0 pe.conf'
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,186 @@
1
+ RSpec.shared_examples 'pe.conf' do
2
+ let( :options ) { { :format => 'hiera' } }
3
+ let( :answer_hiera ) { answers.answer_hiera }
4
+ let( :default_password ) { '~!@#$%^*-/ aZ' }
5
+ let( :gold_db_answers ) do
6
+ {
7
+ "puppet_enterprise::activity_database_user" => 'adsfglkj',
8
+ "puppet_enterprise::classifier_database_user" => 'DFGhjlkj',
9
+ "puppet_enterprise::orchestrator_database_user" => 'Orc3Str8R',
10
+ "puppet_enterprise::puppetdb_database_user" => 'mYpdBu3r',
11
+ "puppet_enterprise::rbac_database_user" => 'RbhNBklm',
12
+ }
13
+ end
14
+ let( :gold_db_password_answers ) do
15
+ {
16
+ "puppet_enterprise::activity_database_password" => default_password,
17
+ "puppet_enterprise::classifier_database_password" => default_password,
18
+ "puppet_enterprise::orchestrator_database_password" => default_password,
19
+ "puppet_enterprise::puppetdb_database_password" => default_password,
20
+ "puppet_enterprise::rbac_database_password" => default_password,
21
+ }
22
+ end
23
+ # This is a set of database parameters specified in host.cfg :answers
24
+ # (for an external postgres, for instance)
25
+ let( :overridden_database_parameters ) do
26
+ {
27
+ "puppet_enterprise::activity_database_name" => 'custom-activity',
28
+ "puppet_enterprise::activity_database_user" => 'custom-activity-user',
29
+ "puppet_enterprise::classifier_database_name" => 'custom-classifier',
30
+ "puppet_enterprise::classifier_database_user" => 'custom-classifier-user',
31
+ "puppet_enterprise::orchestrator_database_name" => 'custom-orchestrator',
32
+ "puppet_enterprise::orchestrator_database_user" => 'custom-orchestrator-user',
33
+ "puppet_enterprise::puppetdb_database_name" => 'custom-puppetdb',
34
+ "puppet_enterprise::puppetdb_database_user" => 'custom-puppetdb-user',
35
+ "puppet_enterprise::rbac_database_name" => 'custom-rbac',
36
+ "puppet_enterprise::rbac_database_user" => 'custom-rbac-user',
37
+ "puppet_enterprise::activity_database_password" => 'custom-activity-password',
38
+ "puppet_enterprise::classifier_database_password" => 'custom-classifier-password',
39
+ "puppet_enterprise::orchestrator_database_password" => 'custom-orchestrator-password',
40
+ "puppet_enterprise::puppetdb_database_password" => 'custom-puppetdb-password',
41
+ "puppet_enterprise::rbac_database_password" => 'custom-rbac-password',
42
+ }
43
+ end
44
+ let( :overridding_parameters ) do
45
+ {
46
+ 'puppet_enterprise::certificate_authority_host' => 'enterpriseca.vm',
47
+ 'puppet_enterprise::console_host' => 'enterpriseconsole.vm',
48
+ 'console_admin_password' => 'testing123',
49
+ }
50
+ end
51
+ let( :gold_answers_with_overrides ) { gold_role_answers.merge(overridding_parameters) }
52
+
53
+ it 'should not have nil keys or values' do
54
+ answer_hash.each_pair { |k, v|
55
+ expect([k, v]).not_to include(nil)
56
+ }
57
+ end
58
+
59
+ it 'has just the role and values for default install' do
60
+ expect(answer_hash).to eq(
61
+ gold_role_answers
62
+ )
63
+ end
64
+
65
+ context 'when include_legacy_database_defaults' do
66
+ context 'is false' do
67
+ let(:options) do
68
+ {
69
+ :format => 'hiera',
70
+ :include_legacy_database_defaults => false,
71
+ }
72
+ end
73
+
74
+ it 'has only the role values' do
75
+ expect(answer_hash).to eq(gold_role_answers)
76
+ end
77
+
78
+ it 'also includes any explicitly added database parameters' do
79
+ options.merge!(:answers => overridden_database_parameters)
80
+ expect(answer_hash).to eq(
81
+ gold_role_answers
82
+ .merge(overridden_database_parameters)
83
+ )
84
+ end
85
+ end
86
+
87
+ context 'is true' do
88
+ let(:options) do
89
+ {
90
+ :format => 'hiera',
91
+ :include_legacy_database_defaults => true,
92
+ }
93
+ end
94
+
95
+ it 'has the role values and database defaults' do
96
+ expect(answer_hash).to eq(
97
+ gold_role_answers
98
+ .merge(gold_db_answers)
99
+ )
100
+ end
101
+
102
+ it 'overrides defaults with explicitly added database parameters' do
103
+ options.merge!(:answers => overridden_database_parameters)
104
+ expect(answer_hash).to eq(
105
+ gold_role_answers
106
+ .merge(overridden_database_parameters)
107
+ )
108
+ end
109
+ end
110
+ end
111
+
112
+ context 'with legacy answers present' do
113
+ let(:string_answer) { { 'q_puppet_enterpriseconsole_auth_password' => 'password' } }
114
+ let(:symbol_answer) { { :q_puppet_enterpriseconsole_auth_password => 'password' } }
115
+ let(:answers) { BeakerAnswers::Answers.create(ver, hosts, options) }
116
+
117
+ context 'when key is a string' do
118
+ let(:options) { { :format => 'hiera' }.merge(:answers => string_answer) }
119
+
120
+ it 'raises a TypeError' do
121
+ expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/)
122
+ end
123
+ end
124
+
125
+ context 'when key is a symbol' do
126
+ let(:options) { { :format => 'hiera' }.merge(:answers => symbol_answer) }
127
+
128
+ it 'raises a TypeError' do
129
+ expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/)
130
+ end
131
+ end
132
+ end
133
+
134
+ context 'when overriding answers' do
135
+ let( :options ) do
136
+ {
137
+ :format => 'hiera',
138
+ :answers => {
139
+ 'puppet_enterprise' => { 'certificate_authority_host' => 'enterpriseca.vm' },
140
+ 'puppet_enterprise::console_host' => 'enterpriseconsole.vm',
141
+ 'console_admin_password' => 'testing123',
142
+ }
143
+ }
144
+ end
145
+
146
+ it 'matches expected answers' do
147
+ expect(answer_hash).to eq(gold_answers_with_overrides)
148
+ end
149
+ end
150
+
151
+ context 'when overriding answers using symbolic keys' do
152
+ let( :options ) do
153
+ {
154
+ :format => 'hiera',
155
+ :answers => {
156
+ :puppet_enterprise => {
157
+ :certificate_authority_host => 'enterpriseca.vm',
158
+ :console_host => 'enterpriseconsole.vm',
159
+ },
160
+ :console_admin_password => 'testing123',
161
+ }
162
+ }
163
+ end
164
+
165
+ it 'matches expected answers' do
166
+ expect(answer_hash).to eq(gold_answers_with_overrides)
167
+ end
168
+ end
169
+ end
170
+
171
+ RSpec.shared_examples "valid MEEP 2.0 pe.conf" do
172
+ it 'generates valid MEEP 2.0 json if #answer_hiera is called' do
173
+ expect(answer_hiera).not_to be_empty
174
+ expect { JSON.load(answer_hiera) }.not_to raise_error
175
+ expect(answer_hiera).to match(%r{"node_roles"\s*:\s*\{})
176
+ expect(answer_hiera).to match(%r{"pe_role::\w+::primary_master"\s*:\s*\[\s*"#{basic_hosts[0].hostname}"\s*\]}m)
177
+ end
178
+ end
179
+
180
+ RSpec.shared_examples "valid MEEP 1.0 pe.conf" do
181
+ it 'generates valid MEEP 1.0 json if #answer_hiera is called' do
182
+ expect(answer_hiera).not_to be_empty
183
+ expect { JSON.load(answer_hiera) }.not_to raise_error
184
+ expect(answer_hiera).to match(%r{"puppet_enterprise::puppet_master_host"\s*:\s*"#{basic_hosts[0].hostname}"}m)
185
+ end
186
+ end
@@ -1,6 +1,7 @@
1
1
  require 'simplecov'
2
2
  require 'beaker-answers'
3
3
  require 'helpers'
4
+ require 'shared/context.rb'
4
5
 
5
6
  require 'rspec/its'
6
7
 
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.12.0
4
+ version: 0.13.0
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-10-28 00:00:00.000000000 Z
12
+ date: 2016-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -222,7 +222,9 @@ files:
222
222
  - spec/beaker-answers/upgrade_spec.rb
223
223
  - spec/beaker-answers/versions/version20162_spec.rb
224
224
  - spec/beaker-answers/versions/version20163_spec.rb
225
+ - spec/beaker-answers/versions/version20171_spec.rb
225
226
  - spec/helpers.rb
227
+ - spec/shared/context.rb
226
228
  - spec/spec_helper.rb
227
229
  homepage: https://github.com/puppetlabs/beaker-answers
228
230
  licenses: