beaker-answers 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +4 -0
- data/HISTORY.md +396 -2
- data/beaker-answers.gemspec +1 -1
- data/lib/beaker-answers.rb +5 -0
- data/lib/beaker-answers/answers.rb +86 -9
- data/lib/beaker-answers/helpers.rb +14 -0
- data/lib/beaker-answers/version.rb +1 -1
- data/lib/beaker-answers/versions/upgrade.rb +18 -0
- data/lib/beaker-answers/versions/upgrade38.rb +79 -0
- data/lib/beaker-answers/versions/version20162.rb +106 -2
- data/lib/beaker-answers/versions/version30.rb +1 -1
- data/lib/beaker-answers/versions/version34.rb +1 -1
- data/spec/beaker-answers/beaker-answers_spec.rb +33 -24
- data/spec/beaker-answers/helpers_spec.rb +46 -0
- data/spec/beaker-answers/upgrade_spec.rb +135 -0
- data/spec/beaker-answers/versions/version20162_spec.rb +366 -0
- data/spec/helpers.rb +3 -0
- metadata +22 -2
@@ -29,6 +29,36 @@ 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 "still creates the full install answers" do
|
38
|
+
@ver = version
|
39
|
+
options[:type] = :upgrade
|
40
|
+
expect( answers ).to be_a_kind_of BeakerAnswers::Answers
|
41
|
+
expect( answers ).to_not be_a_kind_of BeakerAnswers::Upgrade
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'generates upgrade38 answers when type is upgrade and the version 3.8' do
|
47
|
+
@ver = '3.8.3'
|
48
|
+
options[:type] = :upgrade
|
49
|
+
expect( answers ).to be_a_kind_of BeakerAnswers::Upgrade38
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'generates 2016.2 answers for 2016.2 hosts' do
|
53
|
+
@ver = '2016.2.0'
|
54
|
+
expect( answers ).to be_a_kind_of BeakerAnswers::Version20162
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'generates 2016.1 answers for 2016.1 hosts' do
|
58
|
+
@ver = '2016.1.0'
|
59
|
+
expect( answers ).to be_a_kind_of BeakerAnswers::Version20161
|
60
|
+
end
|
61
|
+
|
32
62
|
it 'generates 2015.3 answers for 2015.3 hosts' do
|
33
63
|
@ver = '2015.3.0'
|
34
64
|
expect( answers ).to be_a_kind_of BeakerAnswers::Version20153
|
@@ -357,27 +387,6 @@ describe BeakerAnswers::Version20153 do
|
|
357
387
|
end
|
358
388
|
end
|
359
389
|
|
360
|
-
describe BeakerAnswers::Version20162 do
|
361
|
-
let( :options ) { StringifyHash.new }
|
362
|
-
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
|
363
|
-
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
|
364
|
-
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
365
|
-
basic_hosts[2]['roles'] = ['database', 'agent']
|
366
|
-
basic_hosts }
|
367
|
-
let( :answers ) { BeakerAnswers::Answers.create(@ver, hosts, options) }
|
368
|
-
let( :upgrade_answers ) { BeakerAnswers::Answers.create(@ver, hosts, options.merge( {:type => :upgrade}) ) }
|
369
|
-
|
370
|
-
before :each do
|
371
|
-
@ver = '2016.2'
|
372
|
-
@answers = answers.answers
|
373
|
-
end
|
374
|
-
|
375
|
-
it 'should add orchestrator database answers to console' do
|
376
|
-
expect( @answers['vm2'][:q_orchestrator_database_name] ).to be === 'pe-orchestrator'
|
377
|
-
expect( @answers['vm2'][:q_orchestrator_database_user] ).to be === 'Orc3Str8R'
|
378
|
-
end
|
379
|
-
end
|
380
|
-
|
381
390
|
describe BeakerAnswers::Version32 do
|
382
391
|
let( :options ) { StringifyHash.new }
|
383
392
|
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
|
@@ -546,12 +555,12 @@ describe 'Customization' do
|
|
546
555
|
basic_hosts }
|
547
556
|
let( :answers ) { BeakerAnswers::Answers.create(@ver, hosts, options) }
|
548
557
|
|
549
|
-
def test_answer_customization(answer_key, value_to_set)
|
558
|
+
def test_answer_customization(answer_key, value_to_set, expected_value = value_to_set)
|
550
559
|
@ver = '3.0'
|
551
560
|
options[:answers] ||= StringifyHash.new
|
552
561
|
options[:answers][answer_key] = value_to_set
|
553
562
|
host_answers = answers.answers['vm1']
|
554
|
-
expect( host_answers[answer_key] ).to be ===
|
563
|
+
expect( host_answers[answer_key] ).to be === expected_value
|
555
564
|
end
|
556
565
|
|
557
566
|
it 'sets :q_puppetdb_hostname' do
|
@@ -563,7 +572,7 @@ describe 'Customization' do
|
|
563
572
|
end
|
564
573
|
|
565
574
|
it 'sets :q_puppetdb_database_password' do
|
566
|
-
test_answer_customization(:q_puppetdb_database_password, 'q_puppetdb_database_password_custom03')
|
575
|
+
test_answer_customization(:q_puppetdb_database_password, 'q_puppetdb_database_password_custom03', "'q_puppetdb_database_password_custom03'")
|
567
576
|
end
|
568
577
|
|
569
578
|
it 'sets :q_puppet_enterpriseconsole_auth_database_password' do
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#flatten_keys_to_joined_string' do
|
4
|
+
it 'flattens a deep hash into a shallow one' do
|
5
|
+
deep = {'a' => {'b' => {'c' => {'d' => 'e'}}}}
|
6
|
+
shallow = flatten_keys_to_joined_string(deep)
|
7
|
+
expect(shallow).to include({'a::b::c::d' => 'e'})
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'handles duplicate keys' do
|
11
|
+
deep = {'a' => {'a' => {'a' => {'a' => 'a'}}}}
|
12
|
+
shallow = flatten_keys_to_joined_string(deep)
|
13
|
+
expect(shallow).to include({'a::a::a::a' => 'a'})
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates keys for each grandchilds values' do
|
17
|
+
deep = {'a' => {'b' => 'c', 'd' => 'e'}}
|
18
|
+
shallow = flatten_keys_to_joined_string(deep)
|
19
|
+
expect(shallow).to include({'a::b' => 'c'})
|
20
|
+
expect(shallow).to include({'a::d' => 'e'})
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'does not change keys with ::' do
|
24
|
+
deep = {'a::b' => {'c::d' => 'e'}}
|
25
|
+
shallow = flatten_keys_to_joined_string(deep)
|
26
|
+
expect(shallow).to include({'a::b::c::d' => 'e'})
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'does not blow up on an empty hash' do
|
30
|
+
deep = {}
|
31
|
+
shallow = flatten_keys_to_joined_string(deep)
|
32
|
+
expect(shallow).to include({})
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'converts key symbols to strings' do
|
36
|
+
deep = {:a => 'b'}
|
37
|
+
shallow = flatten_keys_to_joined_string(deep)
|
38
|
+
expect(shallow).to include({'a' => 'b'})
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'converts nested key symbols to strings' do
|
42
|
+
deep = {:a => {:b => 'c'}}
|
43
|
+
shallow = flatten_keys_to_joined_string(deep)
|
44
|
+
expect(shallow).to include({'a::b' => 'c'})
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
describe BeakerAnswers::Upgrade do
|
2
|
+
let( :options ) { StringifyHash.new }
|
3
|
+
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
|
4
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
|
5
|
+
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
6
|
+
basic_hosts[2]['roles'] = ['database', 'agent']
|
7
|
+
basic_hosts }
|
8
|
+
let( :answers ) { BeakerAnswers::Upgrade.new(@ver, hosts, options.merge({:type => :upgrade}) ) }
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
@ver = '3.8'
|
12
|
+
@answers = answers.answers
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#generate_answers' do
|
16
|
+
it 'only adds the default yes for each host' do
|
17
|
+
host_answers = answers.generate_answers
|
18
|
+
host_answers.each do |host, host_answer|
|
19
|
+
expect(host_answer).to eq({:q_install => 'y'})
|
20
|
+
expect(host_answer.length).to eq(1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe BeakerAnswers::Upgrade38 do
|
28
|
+
|
29
|
+
let( :options ) { StringifyHash.new }
|
30
|
+
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
|
31
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
|
32
|
+
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
33
|
+
basic_hosts[2]['roles'] = ['database', 'agent']
|
34
|
+
basic_hosts }
|
35
|
+
let( :answers ) { BeakerAnswers::Answers.create(@ver, hosts, options.merge({:type => :upgrade}) ) }
|
36
|
+
|
37
|
+
before :each do
|
38
|
+
@ver = '3.8'
|
39
|
+
@answers = answers.answers
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when no special answers are provided' do
|
43
|
+
it "the master should have only three keys" do
|
44
|
+
answer = @answers['vm1']
|
45
|
+
expect(answer[:q_install]).to eq('y')
|
46
|
+
expect(answer[:q_enable_future_parser]).to eq('y')
|
47
|
+
expect(answer[:q_exit_for_nc_migrate]).to eq('n')
|
48
|
+
expect(answer.length).to eq(3)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'the dashboard should have 19 keys provided' do
|
52
|
+
answer = @answers['vm2']
|
53
|
+
|
54
|
+
expect(answer[:q_install]).to eq('y')
|
55
|
+
expect(answer[:q_enable_future_parser]).to eq('y')
|
56
|
+
expect(answer[:q_exit_for_nc_migrate]).to eq('n')
|
57
|
+
expect(answer[:q_rbac_database_name]).to eq('pe-rbac')
|
58
|
+
expect(answer[:q_rbac_database_user]).to eq('RbhNBklm')
|
59
|
+
expect(answer[:q_rbac_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
60
|
+
expect(answer[:q_activity_database_user]).to eq('adsfglkj')
|
61
|
+
expect(answer[:q_activity_database_name]).to eq('pe-activity')
|
62
|
+
expect(answer[:q_activity_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
63
|
+
expect(answer[:q_classifier_database_name]).to eq('pe-classifier')
|
64
|
+
expect(answer[:q_classifier_database_user]).to eq('DFGhjlkj')
|
65
|
+
expect(answer[:q_classifier_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
66
|
+
expect(answer[:q_puppetdb_database_name]).to eq('pe-puppetdb')
|
67
|
+
expect(answer[:q_puppetdb_database_user]).to eq('mYpdBu3r')
|
68
|
+
expect(answer[:q_puppetdb_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
69
|
+
expect(answer[:q_puppet_enterpriseconsole_auth_password]).to eq("'~!@#$%^*-/ aZ'")
|
70
|
+
expect(answer[:q_puppetdb_port]).to eq(8081)
|
71
|
+
expect(answer[:q_install]).to eq('y')
|
72
|
+
expect(answer[:q_enable_future_parser]).to eq('y')
|
73
|
+
expect(answer[:q_exit_for_nc_migrate]).to eq('n')
|
74
|
+
expect(answer.length).to eq(19)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'the database should have 13 keys provided' do
|
78
|
+
answer = @answers['vm3']
|
79
|
+
expect(answer[:q_enable_future_parser]).to eq('y')
|
80
|
+
expect(answer[:q_exit_for_nc_migrate]).to eq('n')
|
81
|
+
expect(answer[:q_rbac_database_name]).to eq('pe-rbac')
|
82
|
+
expect(answer[:q_rbac_database_user]).to eq('RbhNBklm')
|
83
|
+
expect(answer[:q_rbac_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
84
|
+
expect(answer[:q_activity_database_user]).to eq('adsfglkj')
|
85
|
+
expect(answer[:q_activity_database_name]).to eq('pe-activity')
|
86
|
+
expect(answer[:q_activity_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
87
|
+
expect(answer[:q_classifier_database_name]).to eq('pe-classifier')
|
88
|
+
expect(answer[:q_classifier_database_user]).to eq('DFGhjlkj')
|
89
|
+
expect(answer[:q_classifier_database_password]).to eq("'~!@#$%^*-/ aZ'")
|
90
|
+
expect(answer[:q_install]).to eq('y')
|
91
|
+
expect(answer[:q_enable_future_parser]).to eq('y')
|
92
|
+
expect(answer[:q_exit_for_nc_migrate]).to eq('n')
|
93
|
+
expect(answer.length).to eq(13)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when we set :q_enable_future_parser in global options' do
|
98
|
+
let( :options ) {
|
99
|
+
options = StringifyHash.new
|
100
|
+
options[:answers] = { :q_enable_future_parser => 'thefutureparser!!!'}
|
101
|
+
options
|
102
|
+
}
|
103
|
+
it 'sets that parser option from the global options' do
|
104
|
+
@answers.each do |vmname, answer|
|
105
|
+
expect(answer[:q_enable_future_parser]).to eq('thefutureparser!!!')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when per host custom answers are provided for the master and dashboard' do
|
110
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
|
111
|
+
basic_hosts[0][:custom_answers] = { :q_custom0 => '0LOOK' }
|
112
|
+
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
113
|
+
basic_hosts[1][:custom_answers] = { :q_custom1 => 'LOOKLOOK',
|
114
|
+
:q_custom2 => "LOOK3"}
|
115
|
+
basic_hosts[2]['roles'] = ['database', 'agent']
|
116
|
+
basic_hosts }
|
117
|
+
|
118
|
+
it 'adds those custom answers to the master' do
|
119
|
+
expect( @answers['vm1'][:q_custom0] ).to be === '0LOOK'
|
120
|
+
expect(@answers['vm1'].length).to eq(4)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'adds custom answers to the dashboard' do
|
124
|
+
expect( @answers['vm2'][:q_custom1] ).to be === 'LOOKLOOK'
|
125
|
+
expect( @answers['vm2'][:q_custom2] ).to be === 'LOOK3'
|
126
|
+
expect( @answers['vm2'].length).to eq(21)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'does not add custom answers for the database' do
|
130
|
+
expect(@answers['vm3'].length).to eq(13)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,366 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe BeakerAnswers::Version20162 do
|
5
|
+
let( :ver ) { '2016.2.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
|
+
it 'adds orchestrator database answers to console' do
|
16
|
+
expect( answer_hash['vm2'][:q_orchestrator_database_name] ).to be === 'pe-orchestrator'
|
17
|
+
expect( answer_hash['vm2'][:q_orchestrator_database_user] ).to be === 'Orc3Str8R'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'generates valid answers if #answer_string is called' do
|
21
|
+
expect( answers.answer_string(basic_hosts[2]) ).to match(/q_orchestrator_database_name=pe-orchestrator/)
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when generating a hiera config' do
|
25
|
+
let( :options ) { { :format => 'hiera' } }
|
26
|
+
let( :answer_hiera ) { answers.answer_hiera }
|
27
|
+
let( :default_password ) { '~!@#$%^*-/ aZ' }
|
28
|
+
let( :gold_role_answers ) do
|
29
|
+
{
|
30
|
+
"console_admin_password" => default_password,
|
31
|
+
"puppet_enterprise::use_application_services" => true,
|
32
|
+
"puppet_enterprise::certificate_authority_host" => basic_hosts[0].hostname,
|
33
|
+
"puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
|
34
|
+
"puppet_enterprise::console_host" => basic_hosts[1].hostname,
|
35
|
+
"puppet_enterprise::puppetdb_host" => basic_hosts[2].hostname,
|
36
|
+
"puppet_enterprise::database_host" => basic_hosts[2].hostname,
|
37
|
+
"puppet_enterprise::pcp_broker_host" => basic_hosts[0].hostname,
|
38
|
+
"puppet_enterprise::mcollective_middleware_hosts" => [basic_hosts[0].hostname],
|
39
|
+
}
|
40
|
+
end
|
41
|
+
let( :gold_db_answers ) do
|
42
|
+
{
|
43
|
+
"puppet_enterprise::activity_database_user" => 'adsfglkj',
|
44
|
+
"puppet_enterprise::classifier_database_user" => 'DFGhjlkj',
|
45
|
+
"puppet_enterprise::orchestrator_database_user" => 'Orc3Str8R',
|
46
|
+
"puppet_enterprise::puppetdb_database_user" => 'mYpdBu3r',
|
47
|
+
"puppet_enterprise::rbac_database_user" => 'RbhNBklm',
|
48
|
+
}
|
49
|
+
end
|
50
|
+
let( :gold_db_password_answers ) do
|
51
|
+
{
|
52
|
+
"puppet_enterprise::activity_database_password" => default_password,
|
53
|
+
"puppet_enterprise::classifier_database_password" => default_password,
|
54
|
+
"puppet_enterprise::orchestrator_database_password" => default_password,
|
55
|
+
"puppet_enterprise::puppetdb_database_password" => default_password,
|
56
|
+
"puppet_enterprise::rbac_database_password" => default_password,
|
57
|
+
}
|
58
|
+
end
|
59
|
+
# This is a set of database parameters specified in host.cfg :answers
|
60
|
+
# (for an external postgres, for instance)
|
61
|
+
let( :overridden_database_parameters ) do
|
62
|
+
{
|
63
|
+
"puppet_enterprise::activity_database_name" => 'custom-activity',
|
64
|
+
"puppet_enterprise::activity_database_user" => 'custom-activity-user',
|
65
|
+
"puppet_enterprise::classifier_database_name" => 'custom-classifier',
|
66
|
+
"puppet_enterprise::classifier_database_user" => 'custom-classifier-user',
|
67
|
+
"puppet_enterprise::orchestrator_database_name" => 'custom-orchestrator',
|
68
|
+
"puppet_enterprise::orchestrator_database_user" => 'custom-orchestrator-user',
|
69
|
+
"puppet_enterprise::puppetdb_database_name" => 'custom-puppetdb',
|
70
|
+
"puppet_enterprise::puppetdb_database_user" => 'custom-puppetdb-user',
|
71
|
+
"puppet_enterprise::rbac_database_name" => 'custom-rbac',
|
72
|
+
"puppet_enterprise::rbac_database_user" => 'custom-rbac-user',
|
73
|
+
"puppet_enterprise::activity_database_password" => 'custom-activity-password',
|
74
|
+
"puppet_enterprise::classifier_database_password" => 'custom-classifier-password',
|
75
|
+
"puppet_enterprise::orchestrator_database_password" => 'custom-orchestrator-password',
|
76
|
+
"puppet_enterprise::puppetdb_database_password" => 'custom-puppetdb-password',
|
77
|
+
"puppet_enterprise::rbac_database_password" => 'custom-rbac-password',
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should not have nil keys or values' do
|
82
|
+
answer_hash.each_pair { |k, v|
|
83
|
+
expect([k, v]).not_to include(nil)
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'has the just the role and values for default install' do
|
88
|
+
expect(answer_hash).to eq(
|
89
|
+
gold_role_answers
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when include_legacy_database_defaults' do
|
94
|
+
context 'is false' do
|
95
|
+
let(:options) do
|
96
|
+
{
|
97
|
+
:format => 'hiera',
|
98
|
+
:include_legacy_database_defaults => false,
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'has only the role values' do
|
103
|
+
expect(answer_hash).to eq(gold_role_answers)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'also includes any explicitly added database parameters' do
|
107
|
+
options.merge!(:answers => overridden_database_parameters)
|
108
|
+
expect(answer_hash).to eq(
|
109
|
+
gold_role_answers
|
110
|
+
.merge(overridden_database_parameters)
|
111
|
+
)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'is true' do
|
116
|
+
let(:options) do
|
117
|
+
{
|
118
|
+
:format => 'hiera',
|
119
|
+
:include_legacy_database_defaults => true,
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'has the role values and database defaults' do
|
124
|
+
expect(answer_hash).to eq(
|
125
|
+
gold_role_answers
|
126
|
+
.merge(gold_db_answers)
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'overrides defaults with explicitly added database parameters' do
|
131
|
+
options.merge!(:answers => overridden_database_parameters)
|
132
|
+
expect(answer_hash).to eq(
|
133
|
+
gold_role_answers
|
134
|
+
.merge(overridden_database_parameters)
|
135
|
+
)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'generates valid json if #answer_hiera is called' do
|
141
|
+
expect(answer_hiera).not_to be_empty
|
142
|
+
expect { JSON.load(answer_hiera) }.not_to raise_error
|
143
|
+
expect(answer_hiera).to match "puppet_enterprise::puppet_master_host.*:.*#{basic_hosts[0].hostname}"
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'with legacy answers present' do
|
147
|
+
let(:string_answer) { { 'q_puppet_enterpriseconsole_auth_password' => 'password' } }
|
148
|
+
let(:symbol_answer) { { :q_puppet_enterpriseconsole_auth_password => 'password' } }
|
149
|
+
let(:answers) { BeakerAnswers::Answers.create(ver, hosts, options) }
|
150
|
+
|
151
|
+
context 'when key is a string' do
|
152
|
+
let(:options) { { :format => 'hiera' }.merge(:answers => string_answer) }
|
153
|
+
|
154
|
+
it 'raises a TypeError' do
|
155
|
+
expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'when key is a symbol' do
|
160
|
+
let(:options) { { :format => 'hiera' }.merge(:answers => symbol_answer) }
|
161
|
+
|
162
|
+
it 'raises a TypeError' do
|
163
|
+
expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'when overriding answers' do
|
169
|
+
let( :options ) do
|
170
|
+
{
|
171
|
+
:format => 'hiera',
|
172
|
+
:answers => {
|
173
|
+
'puppet_enterprise' => { 'certificate_authority_host' => 'enterpriseca.vm' },
|
174
|
+
'puppet_enterprise::console_host' => 'enterpriseconsole.vm',
|
175
|
+
'console_admin_password' => 'testing123',
|
176
|
+
}
|
177
|
+
}
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'overrides the defaults when multi-level hash :answers are given' do
|
181
|
+
expect(answer_hash["puppet_enterprise::certificate_authority_host"]).to be === 'enterpriseca.vm'
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'overrides the defaults when a :: delimited key is given' do
|
185
|
+
expect(answer_hash["puppet_enterprise::console_host"]).to be === 'enterpriseconsole.vm'
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'overrides the console_admin_password default' do
|
189
|
+
expect(answer_hash["console_admin_password"]).to be === 'testing123'
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'does not add a duplicate key to the hash' do
|
193
|
+
expect(answer_hash.length).to eq(gold_role_answers.length)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'when overriding answers using symbolic keys' do
|
198
|
+
let( :options ) do
|
199
|
+
{
|
200
|
+
:format => 'hiera',
|
201
|
+
:answers => {
|
202
|
+
:puppet_enterprise => {
|
203
|
+
:certificate_authority_host => 'enterpriseca.vm',
|
204
|
+
:console_host => 'enterpriseconsole.vm',
|
205
|
+
},
|
206
|
+
:console_admin_password => 'testing123',
|
207
|
+
}
|
208
|
+
}
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'overrides the defaults when multi-level hash :answers are given' do
|
212
|
+
expect(answer_hash["puppet_enterprise::certificate_authority_host"]).to be === 'enterpriseca.vm'
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'overrides the defaults when a :: delimited key is given' do
|
216
|
+
expect(answer_hash["puppet_enterprise::console_host"]).to be === 'enterpriseconsole.vm'
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'overrides the console_admin_password default' do
|
220
|
+
expect(answer_hash["console_admin_password"]).to be === 'testing123'
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'does not add duplicate keys to the hash' do
|
224
|
+
expect(answer_hash.length).to eq(gold_role_answers.length)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
# This spec is just providing a baseline for :bash answer generation/regression.
|
230
|
+
# This and bash answer generation in 2016.2.0+ should be dropped once we've cutover.
|
231
|
+
it 'continues to provide same set of :bash answers' do
|
232
|
+
expect(answer_hash).to eq({
|
233
|
+
"vm1" => {
|
234
|
+
:q_install=>"y",
|
235
|
+
:q_vendor_packages_install=>"y",
|
236
|
+
:q_puppetagent_install=>"y",
|
237
|
+
:q_verify_packages=>"y",
|
238
|
+
:q_puppet_symlinks_install=>"y",
|
239
|
+
:q_puppetagent_certname=>"vm1",
|
240
|
+
:q_puppetmaster_install=>"y",
|
241
|
+
:q_all_in_one_install=>"n",
|
242
|
+
:q_puppet_enterpriseconsole_install=>"n",
|
243
|
+
:q_puppetdb_install=>"n",
|
244
|
+
:q_database_install=>"n",
|
245
|
+
:q_puppetagent_server=>"vm1",
|
246
|
+
:q_puppetdb_hostname=>"vm3",
|
247
|
+
:q_puppetdb_port=>8081,
|
248
|
+
:q_puppetmaster_dnsaltnames=>"vm1,ip.address.for.vm1,puppet",
|
249
|
+
:q_puppetmaster_enterpriseconsole_hostname=>"vm2",
|
250
|
+
:q_puppetmaster_enterpriseconsole_port=>443,
|
251
|
+
:q_puppetmaster_certname=>"vm1",
|
252
|
+
:q_pe_check_for_updates=>"n",
|
253
|
+
:q_exit_for_nc_migrate=>"n",
|
254
|
+
:q_enable_future_parser=>"n",
|
255
|
+
:q_update_server_host=>"vm1",
|
256
|
+
:q_install_update_server=>"y",
|
257
|
+
:q_orchestrator_database_name=>"pe-orchestrator",
|
258
|
+
:q_orchestrator_database_user=>"Orc3Str8R",
|
259
|
+
:q_orchestrator_database_password=>"'~!@\#$%^*-/ aZ'",
|
260
|
+
:q_database_host=>"vm3",
|
261
|
+
:q_database_port=>5432,
|
262
|
+
:q_use_application_services=>"y"
|
263
|
+
},
|
264
|
+
"vm2" => {
|
265
|
+
:q_install=>"y",
|
266
|
+
:q_vendor_packages_install=>"y",
|
267
|
+
:q_puppetagent_install=>"y",
|
268
|
+
:q_verify_packages=>"y",
|
269
|
+
:q_puppet_symlinks_install=>"y",
|
270
|
+
:q_puppetagent_certname=>"vm2",
|
271
|
+
:q_puppetmaster_install=>"n",
|
272
|
+
:q_all_in_one_install=>"n",
|
273
|
+
:q_puppet_enterpriseconsole_install=>"y",
|
274
|
+
:q_puppetdb_install=>"n",
|
275
|
+
:q_database_install=>"n",
|
276
|
+
:q_puppetagent_server=>"vm1",
|
277
|
+
:q_puppetdb_hostname=>"vm3",
|
278
|
+
:q_puppetdb_port=>8081,
|
279
|
+
:q_puppetdb_database_name=>"pe-puppetdb",
|
280
|
+
:q_puppetdb_database_user=>"mYpdBu3r",
|
281
|
+
:q_puppetdb_database_password=>"'~!@\#$%^*-/ aZ'",
|
282
|
+
:q_puppet_enterpriseconsole_auth_database_name=>"console_auth",
|
283
|
+
:q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r",
|
284
|
+
:q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'",
|
285
|
+
:q_puppet_enterpriseconsole_database_name=>"console",
|
286
|
+
:q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r",
|
287
|
+
:q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'",
|
288
|
+
:q_database_host=>"vm3",
|
289
|
+
:q_database_port=>5432,
|
290
|
+
:q_pe_database=>"y",
|
291
|
+
:q_puppet_enterpriseconsole_inventory_hostname=>"vm2",
|
292
|
+
:q_puppet_enterpriseconsole_inventory_certname=>"vm2",
|
293
|
+
:q_puppet_enterpriseconsole_inventory_dnsaltnames=>"vm2",
|
294
|
+
:q_puppet_enterpriseconsole_inventory_port=>8140,
|
295
|
+
:q_puppet_enterpriseconsole_master_hostname=>"vm1",
|
296
|
+
:q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'",
|
297
|
+
:q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'",
|
298
|
+
:q_puppet_enterpriseconsole_httpd_port=>443,
|
299
|
+
:q_puppet_enterpriseconsole_smtp_host=>"'vm2'",
|
300
|
+
:q_puppet_enterpriseconsole_smtp_use_tls=>"'n'",
|
301
|
+
:q_puppet_enterpriseconsole_smtp_port=>"'25'",
|
302
|
+
:q_puppetmaster_certname=>"vm1",
|
303
|
+
:q_pe_check_for_updates=>"n",
|
304
|
+
:q_classifier_database_user=>"DFGhjlkj",
|
305
|
+
:q_classifier_database_name=>"pe-classifier",
|
306
|
+
:q_classifier_database_password=>"'~!@\#$%^*-/ aZ'",
|
307
|
+
:q_activity_database_user=>"adsfglkj",
|
308
|
+
:q_activity_database_name=>"pe-activity",
|
309
|
+
:q_activity_database_password=>"'~!@\#$%^*-/ aZ'",
|
310
|
+
:q_rbac_database_user=>"RbhNBklm",
|
311
|
+
:q_rbac_database_name=>"pe-rbac",
|
312
|
+
:q_rbac_database_password=>"'~!@\#$%^*-/ aZ'",
|
313
|
+
:q_exit_for_nc_migrate=>"n",
|
314
|
+
:q_enable_future_parser=>"n",
|
315
|
+
:q_update_server_host=>"vm1",
|
316
|
+
:q_use_application_services=>"y",
|
317
|
+
:q_orchestrator_database_name=>"pe-orchestrator",
|
318
|
+
:q_orchestrator_database_user=>"Orc3Str8R"
|
319
|
+
},
|
320
|
+
"vm3" => {
|
321
|
+
:q_install=>"y",
|
322
|
+
:q_vendor_packages_install=>"y",
|
323
|
+
:q_puppetagent_install=>"y",
|
324
|
+
:q_verify_packages=>"y",
|
325
|
+
:q_puppet_symlinks_install=>"y",
|
326
|
+
:q_puppetagent_certname=>"vm3",
|
327
|
+
:q_puppetmaster_install=>"n",
|
328
|
+
:q_all_in_one_install=>"n",
|
329
|
+
:q_puppet_enterpriseconsole_install=>"n",
|
330
|
+
:q_puppetdb_install=>"y",
|
331
|
+
:q_database_install=>"y",
|
332
|
+
:q_puppetagent_server=>"vm1",
|
333
|
+
:q_puppetmaster_certname=>"vm1",
|
334
|
+
:q_database_root_password=>"'=ZYdjiP3jCwV5eo9s1MBd'",
|
335
|
+
:q_database_root_user=>"pe-postgres",
|
336
|
+
:q_puppetdb_database_name=>"pe-puppetdb",
|
337
|
+
:q_puppetdb_database_user=>"mYpdBu3r",
|
338
|
+
:q_puppetdb_database_password=>"'~!@\#$%^*-/ aZ'",
|
339
|
+
:q_puppet_enterpriseconsole_auth_database_name=>"console_auth",
|
340
|
+
:q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r",
|
341
|
+
:q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'",
|
342
|
+
:q_puppet_enterpriseconsole_database_name=>"console",
|
343
|
+
:q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r",
|
344
|
+
:q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'",
|
345
|
+
:q_database_host=>"vm3",
|
346
|
+
:q_database_port=>5432,
|
347
|
+
:q_classifier_database_user=>"DFGhjlkj",
|
348
|
+
:q_classifier_database_name=>"pe-classifier",
|
349
|
+
:q_classifier_database_password=>"'~!@\#$%^*-/ aZ'",
|
350
|
+
:q_activity_database_user=>"adsfglkj",
|
351
|
+
:q_activity_database_name=>"pe-activity",
|
352
|
+
:q_activity_database_password=>"'~!@\#$%^*-/ aZ'",
|
353
|
+
:q_rbac_database_user=>"RbhNBklm",
|
354
|
+
:q_rbac_database_name=>"pe-rbac",
|
355
|
+
:q_rbac_database_password=>"'~!@\#$%^*-/ aZ'",
|
356
|
+
:q_exit_for_nc_migrate=>"n",
|
357
|
+
:q_enable_future_parser=>"n",
|
358
|
+
:q_update_server_host=>"vm1",
|
359
|
+
:q_orchestrator_database_name=>"pe-orchestrator",
|
360
|
+
:q_orchestrator_database_user=>"Orc3Str8R",
|
361
|
+
:q_orchestrator_database_password=>"'~!@\#$%^*-/ aZ'"
|
362
|
+
},
|
363
|
+
})
|
364
|
+
end
|
365
|
+
|
366
|
+
end
|