beaker-answers 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mjg4YzhjMzFmZjY3NGU5NjZhNDU0ZDZiODYyMDc4NjgyYWY3OTIzNQ==
4
+ NGExODA0NjAzYmM2NzRmOGI4NzY2YmE2NjQ1MzRlODhmNzU5NjA2YQ==
5
5
  data.tar.gz: !binary |-
6
- YzhmMWU5YjlhNzAxOTIxZDk1M2ZlMTNhZWFjNTQzZWE1ZTE5Mjk0YQ==
6
+ NWY0ODA1NTU4NTgxYTMwMDE4MDBhNTUwYWE5NGY4NjBlZmY2ZWVhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjNjNzAzM2I2Y2Q5ZDczNTU1NTk0NjIxY2EwNjZiYzg3ZWQ1MDhmNmYyNDAx
10
- OGRkODkyOGYzMjQ1ZmJkZDFiNTVhMTY1ZWQ2MzE1OTZmODNlZjczMWJlNjk3
11
- MWFiZWI1MjBlODNmMDcxNjA4ZTM5NjViMDI0N2YxMWVmYTdjYTg=
9
+ ZWU4N2E0NDg4NDFlMjY4YzQ3ZmU2MWVhMjg4NjcyYzE5NDllZTliZTk1MjM3
10
+ YmEyNjg1ZGYyMDA0NjMwNWFmMWYwMGQ1ZjIwNjE3NzUwNzdkZjFmZDc4Mzll
11
+ MGUzNTJmMTY3OGI0NTFiNTAyMjMxOGNmNjk4MWU0ZDhiZTZmMTc=
12
12
  data.tar.gz: !binary |-
13
- ZmFhMzNjZjNkMTNjYzhmMjQxY2VlMzczMGI4YTdjYTIyNjBmZDQ0OGE3ZGQz
14
- YjViNWYxMzczZGFmNmQ1MGI1NDRkZmQ3MmMzNjY5YjY4MDNhMjkwNDkzMmVh
15
- NGMwZWRjNmNlMWVhNGI5M2NmYjQ0ZjA1ZmUxYmVmN2FiOWVhZGQ=
13
+ ZDYzNGY3YTIzYTQ2NzVkYTc2OTBiOGVhZTg0YTNjYTU3ZTNkNTlhZGU2YTJl
14
+ ZTAzMjJkMGM0NzQ5ZWRhN2ZmNjg5YWI4NDViOWY0YTFhMjIwMGZiMGVlNzU3
15
+ NjQ5N2FhY2MxMjE1MjQyZmI4Mjg3YzhjODdlOThhNjNmOTk0Zjg=
@@ -82,6 +82,19 @@ module BeakerAnswers
82
82
  pe_conf["#{ns}::puppetdb_host"] = puppetdb.hostname
83
83
  end
84
84
 
85
+ if the_host_with_role('pe_postgres', raise_error=false)
86
+ pe_conf["#{ns}::database_host"] = the_host_with_role('pe_postgres', raise_error=false).hostname
87
+ if options[:pe_postgresql_options]
88
+ if options[:pe_postgresql_options][:security] == 'cert'
89
+ postgres_cert_answers(pe_conf, '1.0')
90
+ elsif options[:pe_postgresql_options][:security] == 'password'
91
+ postgres_password_answers(pe_conf, '1.0')
92
+ end
93
+ else
94
+ postgres_password_answers(pe_conf, '1.0')
95
+ end
96
+ end
97
+
85
98
  pe_conf
86
99
  end
87
100
 
@@ -119,6 +132,18 @@ module BeakerAnswers
119
132
  conf
120
133
  end
121
134
 
135
+ #Set the PE managed postgres roles/answers
136
+ if the_host_with_role('pe_postgres', raise_error=false)
137
+ pe_conf["puppet_enterprise::profile::database"] = the_host_with_role('pe_postgres', raise_error=false).hostname
138
+ if options[:pe_postgresql_options][:security]
139
+ if options[:pe_postgresql_options][:security] == 'cert'
140
+ postgres_cert_answers(pe_conf, "2.0")
141
+ elsif options[:pe_postgresql_options][:security] == 'password'
142
+ postgres_password_answers(pe_conf, "2.0")
143
+ end
144
+ end
145
+ end
146
+
122
147
  # Collect a uniq array of all host platforms modified to pe_repo class format
123
148
  platforms = hosts.map do |h|
124
149
  platform = h['platform']
@@ -149,18 +174,41 @@ module BeakerAnswers
149
174
  # one host is found to have the provided role.
150
175
  #
151
176
  # @param [String] role The host returned will have this role in its role list
177
+ # @param [String] raise_error defaults to true if you want this method to return
178
+ # an error if there are no hosts, or if there are too many hosts
152
179
  # @return [Host] The single host with the desired role in its roles list
153
180
  # @raise [ArgumentError] Raised if more than one host has the given role
154
181
  # defined, or if no host has the role defined.
155
- def the_host_with_role(role)
182
+ def the_host_with_role(role, raise_error=true)
156
183
  found_hosts = hosts.select do |h|
157
184
  Array(h['roles']).include?(role.to_s)
158
185
  end
159
186
 
160
- if found_hosts.length == 0 or found_hosts.length > 1
187
+ if (found_hosts.length == 0 or found_hosts.length > 1) && (raise_error)
161
188
  raise ArgumentError, "There should be one host with #{role} defined, found #{found_hosts.length} matching hosts (#{found_hosts})"
162
189
  end
163
190
  found_hosts.first
164
191
  end
192
+
193
+ def postgres_cert_answers(pe_conf, meep_schema_version)
194
+ case meep_schema_version
195
+ when '1.0','2.0'
196
+ pe_conf["puppet_enterprise::database_ssl"] = true
197
+ pe_conf["puppet_enterprise::database_cert_auth"] = true
198
+ end
199
+ pe_conf
200
+ end
201
+
202
+ def postgres_password_answers(pe_conf, meep_schema_version)
203
+ case meep_schema_version
204
+ when '1.0','2.0'
205
+ pe_conf["puppet_enterprise::activity_database_password"] = "PASSWORD"
206
+ pe_conf["puppet_enterprise::classifier_database_password"] = "PASSWORD"
207
+ pe_conf["puppet_enterprise::orchestrator_database_password"] = "PASSWORD"
208
+ pe_conf["puppet_enterprise::puppetdb_database_password"] = "PASSWORD"
209
+ pe_conf["puppet_enterprise::rbac_database_password"] = "PASSWORD"
210
+ end
211
+ pe_conf
212
+ end
165
213
  end
166
214
  end
@@ -1,5 +1,5 @@
1
1
  module BeakerAnswers
2
2
  module Version
3
- STRING = '0.18.0'
3
+ STRING = '0.19.0'
4
4
  end
5
5
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'BeakerAnswers::PeConf' do
4
4
  let(:basic_hosts) { make_hosts({'pe_ver' => ver }, host_count) }
5
+ let(:host) { Beaker::Host.create('host', {}, make_host_opts('host', options.merge(platform))) }
5
6
 
6
7
  RSpec.shared_examples 'pe.conf configuration' do
7
8
  context 'monolithic' do
@@ -21,6 +22,41 @@ describe 'BeakerAnswers::PeConf' do
21
22
  end
22
23
  end
23
24
 
25
+ context 'pe_postgres_cert' do
26
+ let(:host_count) { 2 }
27
+ let(:hosts) do
28
+ basic_hosts[0][:pe_postgresql_options] = {:security=>"cert"}
29
+ basic_hosts[0]['roles'] = ['master', 'dashboard', 'database', 'agent']
30
+ basic_hosts[0]['platform'] = 'el-6-x86_64'
31
+ basic_hosts[1]['roles'] = ['agent', 'pe_postgres']
32
+ basic_hosts[1]['platform'] = 'el-6-x86_64'
33
+ basic_hosts
34
+ end
35
+
36
+ it 'generates a hash of monolithic configuring that uses an external postgres with cert setup' do
37
+ expect(BeakerAnswers::PeConf.new(hosts, meep_schema_version, {:pe_postgresql_options => {:security => "cert"}}).configuration_hash).to(
38
+ match(gold_pe_postgres_cert_configuration_hash)
39
+ )
40
+ end
41
+ end
42
+
43
+ context 'pe_postgres_password' do
44
+ let(:host_count) { 2 }
45
+ let(:hosts) do
46
+ basic_hosts[0]['roles'] = ['master', 'dashboard', 'database', 'agent']
47
+ basic_hosts[0]['platform'] = 'el-6-x86_64'
48
+ basic_hosts[1]['roles'] = ['agent', 'pe_postgres']
49
+ basic_hosts[1]['platform'] = 'el-6-x86_64'
50
+ basic_hosts
51
+ end
52
+
53
+ it 'generates a hash of monolithic configuring that uses an external postgres with passwords' do
54
+ expect(BeakerAnswers::PeConf.new(hosts, meep_schema_version, {:pe_postgresql_options => {:security => "password"}}).configuration_hash).to(
55
+ match(gold_pe_postgres_password_configuration_hash)
56
+ )
57
+ end
58
+ end
59
+
24
60
  context 'split' do
25
61
  let(:host_count) { 6 }
26
62
  let(:hosts) do
@@ -62,7 +98,25 @@ describe 'BeakerAnswers::PeConf' do
62
98
  "puppet_enterprise::puppetdb_host" => basic_hosts[2].hostname,
63
99
  }
64
100
  end
65
-
101
+ let(:gold_pe_postgres_cert_configuration_hash) do
102
+ {
103
+ "puppet_enterprise::database_cert_auth" => true,
104
+ "puppet_enterprise::database_ssl" => true,
105
+ "puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
106
+ "puppet_enterprise::database_host" => basic_hosts[1].hostname
107
+ }
108
+ end
109
+ let(:gold_pe_postgres_password_configuration_hash) do
110
+ {
111
+ "puppet_enterprise::activity_database_password" => "PASSWORD",
112
+ "puppet_enterprise::classifier_database_password" => "PASSWORD",
113
+ "puppet_enterprise::orchestrator_database_password" => "PASSWORD",
114
+ "puppet_enterprise::puppetdb_database_password" => "PASSWORD",
115
+ "puppet_enterprise::rbac_database_password" => "PASSWORD",
116
+ "puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
117
+ "puppet_enterprise::database_host" => basic_hosts[1].hostname
118
+ }
119
+ end
66
120
  include_examples 'pe.conf configuration'
67
121
  end
68
122
 
@@ -78,6 +132,33 @@ describe 'BeakerAnswers::PeConf' do
78
132
  "meep_schema_version" => "2.0",
79
133
  }
80
134
  end
135
+ let(:gold_pe_postgres_cert_configuration_hash) do
136
+ {
137
+ "node_roles" => {
138
+ "pe_role::monolithic::primary_master" => [basic_hosts[0].hostname],
139
+ },
140
+ "puppet_enterprise::profile::database" => basic_hosts[1].hostname,
141
+ "agent_platforms" => ['el_6_x86_64'],
142
+ "meep_schema_version" => "2.0",
143
+ "puppet_enterprise::database_cert_auth" => true,
144
+ "puppet_enterprise::database_ssl" => true,
145
+ }
146
+ end
147
+ let(:gold_pe_postgres_password_configuration_hash) do
148
+ {
149
+ "node_roles" => {
150
+ "pe_role::monolithic::primary_master" => [basic_hosts[0].hostname],
151
+ },
152
+ "puppet_enterprise::profile::database" => basic_hosts[1].hostname,
153
+ "agent_platforms" => ['el_6_x86_64'],
154
+ "meep_schema_version" => "2.0",
155
+ "puppet_enterprise::activity_database_password" => "PASSWORD",
156
+ "puppet_enterprise::classifier_database_password" => "PASSWORD",
157
+ "puppet_enterprise::orchestrator_database_password" => "PASSWORD",
158
+ "puppet_enterprise::puppetdb_database_password" => "PASSWORD",
159
+ "puppet_enterprise::rbac_database_password" => "PASSWORD",
160
+ }
161
+ end
81
162
  let(:gold_split_configuration_hash) do
82
163
  {
83
164
  "node_roles" => {
@@ -97,4 +178,103 @@ describe 'BeakerAnswers::PeConf' do
97
178
 
98
179
  include_examples 'pe.conf configuration'
99
180
  end
181
+
182
+ describe 'the_host_with_role' do
183
+ let(:host_count) { 2 }
184
+ let(:mono_basic_hosts) { make_hosts( { :pe_ver => '3.0',
185
+ :platform => 'linux',
186
+ :roles => [ 'agent' ],
187
+ :type => 'pe'}, 4 ) }
188
+ let(:mono_hosts) do
189
+ mono_basic_hosts[0]['roles'] = ['master', 'dashboard', 'database', 'agent']
190
+ mono_basic_hosts[0]['platform'] = 'el-6-x86_64'
191
+ mono_basic_hosts[1]['roles'] = ['agent']
192
+ mono_basic_hosts[1]['platform'] = 'el-6-x86_64'
193
+ mono_basic_hosts
194
+ end
195
+ let(:host_count) { 4 }
196
+ let(:split_basic_hosts) { make_hosts( { :pe_ver => '3.0',
197
+ :platform => 'linux',
198
+ :roles => [ 'agent' ],
199
+ :type => 'pe'}, 4 ) }
200
+ let(:split_hosts) do
201
+ split_basic_hosts[0]['roles'] = ['master','agent']
202
+ split_basic_hosts[0]['platform'] = 'el-6-x86_64'
203
+ split_basic_hosts[1]['roles'] = ['database','agent']
204
+ split_basic_hosts[1]['platform'] = 'el-6-x86_64'
205
+ split_basic_hosts[2]['roles'] = ['dashboard','agent']
206
+ split_basic_hosts[2]['platform'] = 'el-6-x86_64'
207
+ split_basic_hosts[3]['roles'] = ['agent']
208
+ split_basic_hosts[3]['platform'] = 'el-6-x86_64'
209
+ split_basic_hosts
210
+ end
211
+
212
+ it 'returns master in monolithic' do
213
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
214
+ expect(peconf.send(:the_host_with_role, 'master')).to eq(mono_basic_hosts[0])
215
+ end
216
+
217
+ it 'returns database in monolithic' do
218
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
219
+ expect(peconf.send(:the_host_with_role, 'database')).to eq(mono_basic_hosts[0])
220
+ end
221
+
222
+ it 'returns dashboard in monolithic' do
223
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
224
+ expect(peconf.send(:the_host_with_role, 'dashboard')).to eq(mono_basic_hosts[0])
225
+ end
226
+
227
+ it 'returns master in split' do
228
+ peconf = BeakerAnswers::PeConf.new(split_hosts, "1.0")
229
+ expect(peconf.send(:the_host_with_role, 'master')).to eq(split_basic_hosts[0])
230
+ end
231
+
232
+ it 'returns database in split' do
233
+ peconf = BeakerAnswers::PeConf.new(split_hosts, "1.0")
234
+ expect(peconf.send(:the_host_with_role, 'database')).to eq(split_basic_hosts[1])
235
+ end
236
+
237
+ it 'returns dashboard in split' do
238
+ peconf = BeakerAnswers::PeConf.new(split_hosts, "1.0")
239
+ expect(peconf.send(:the_host_with_role, 'dashboard')).to eq(split_basic_hosts[2])
240
+ end
241
+
242
+ it 'raises an error if multiple hosts have master role' do
243
+ mono_hosts[1]['roles'] = ['master','agent']
244
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
245
+ expect{ peconf.send(:the_host_with_role, 'master') }.to raise_error(ArgumentError)
246
+ end
247
+
248
+ it 'raises an error if multiple hosts have database role' do
249
+ mono_hosts[1]['roles'] = ['database','agent']
250
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
251
+ expect{ peconf.send(:the_host_with_role, 'database') }.to raise_error(ArgumentError)
252
+ end
253
+
254
+ it 'raises an error if multiple hosts have dashboard role' do
255
+ mono_hosts[1]['roles'] = ['dashboard','agent']
256
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
257
+ expect{ peconf.send(:the_host_with_role, 'dashboard') }.to raise_error(ArgumentError)
258
+ end
259
+
260
+ it 'raises no error if multiple hosts have database role and flag is passed in' do
261
+ mono_hosts[1]['roles'] = ['database','agent']
262
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
263
+ expect(peconf.send(:the_host_with_role, 'database', raise_error=false)).to eq(mono_basic_hosts[0])
264
+ end
265
+
266
+ it 'returns postgres node in monolithic if pe_postgres is set as a role' do
267
+ mono_hosts[1]['roles'] = ['pe_postgres','agent']
268
+ peconf = BeakerAnswers::PeConf.new(mono_hosts, "1.0")
269
+ expect(peconf.send(:the_host_with_role, 'pe_postgres')).to eq(mono_basic_hosts[1])
270
+ end
271
+
272
+ it 'returns postgres node in split if pe_postgres is set as a role' do
273
+ split_hosts[3]['roles'] = ['pe_postgres','agent']
274
+ peconf = BeakerAnswers::PeConf.new(split_hosts, "1.0")
275
+ expect(peconf.send(:the_host_with_role, 'pe_postgres')).to eq(split_basic_hosts[3])
276
+ end
277
+
278
+ end
279
+
100
280
  end
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.18.0
4
+ version: 0.19.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: 2017-09-28 00:00:00.000000000 Z
12
+ date: 2017-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  version: '0'
255
255
  requirements: []
256
256
  rubyforge_project:
257
- rubygems_version: 2.4.6
257
+ rubygems_version: 2.4.8
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: Answer generation for PE Installation!