beaker-answers 0.0.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 +15 -0
- data/.gitignore +25 -0
- data/.rspec +3 -0
- data/.simplecov +9 -0
- data/Gemfile +3 -0
- data/LICENSE +202 -0
- data/README.md +2 -0
- data/Rakefile +7 -0
- data/beaker-answers.gemspec +38 -0
- data/bin/beaker-answers +32 -0
- data/lib/beaker-answers.rb +6 -0
- data/lib/beaker-answers/answers.rb +152 -0
- data/lib/beaker-answers/version.rb +5 -0
- data/lib/beaker-answers/versions/version20.rb +126 -0
- data/lib/beaker-answers/versions/version28.rb +126 -0
- data/lib/beaker-answers/versions/version30.rb +233 -0
- data/lib/beaker-answers/versions/version32.rb +49 -0
- data/lib/beaker-answers/versions/version34.rb +56 -0
- data/lib/beaker-answers/versions/version38.rb +34 -0
- data/lib/beaker-answers/versions/version40.rb +49 -0
- data/spec/beaker-answers/beaker-answers_spec.rb +532 -0
- data/spec/helpers.rb +109 -0
- data/spec/spec_helper.rb +10 -0
- metadata +226 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
module BeakerAnswers
|
2
|
+
|
3
|
+
# This class provides answer file information for PE version 2.0
|
4
|
+
#
|
5
|
+
class Version20 < Answers
|
6
|
+
|
7
|
+
# The version of PE that this set of answers is appropriate for
|
8
|
+
def self.pe_version_matcher
|
9
|
+
/\A2\.0/
|
10
|
+
end
|
11
|
+
|
12
|
+
# Return answer data for a host
|
13
|
+
#
|
14
|
+
# @param [Beaker::Host] host Host to return data for
|
15
|
+
# @param [Beaker::Host] master Host object representing the master
|
16
|
+
# @param [Beaker::Host] dashboard Host object representing the dashboard
|
17
|
+
# @param [Hash] options options for answer files
|
18
|
+
# @option options [Symbol] :type Should be one of :upgrade or :install.
|
19
|
+
# @return [Hash] A hash (keyed from hosts) containing hashes of answer file
|
20
|
+
# data.
|
21
|
+
def host_answers(host, master, dashboard, options)
|
22
|
+
return nil if host['platform'] =~ /windows/
|
23
|
+
|
24
|
+
agent_a = {
|
25
|
+
:q_install => 'y',
|
26
|
+
:q_puppetagent_install => 'y',
|
27
|
+
:q_puppet_cloud_install => 'y',
|
28
|
+
:q_puppet_symlinks_install => 'y',
|
29
|
+
:q_vendor_packages_install => 'y',
|
30
|
+
:q_puppetagent_certname => host.to_s,
|
31
|
+
:q_puppetagent_server => master.to_s,
|
32
|
+
|
33
|
+
# Disable console and master by default
|
34
|
+
# This will be overridden by other blocks being merged in
|
35
|
+
:q_puppetmaster_install => 'n',
|
36
|
+
:q_puppet_enterpriseconsole_install => 'n',
|
37
|
+
}
|
38
|
+
|
39
|
+
master_dns_altnames = [master.to_s, master['ip'], 'puppet'].compact.uniq.join(',')
|
40
|
+
master_a = {
|
41
|
+
:q_puppetmaster_install => 'y',
|
42
|
+
:q_puppetmaster_certname => master.to_s,
|
43
|
+
:q_puppetmaster_dnsaltnames => master_dns_altnames,
|
44
|
+
:q_puppetmaster_enterpriseconsole_hostname => dashboard.to_s,
|
45
|
+
:q_puppetmaster_enterpriseconsole_port => answer_for(options, :q_puppetmaster_enterpriseconsole_port, 443),
|
46
|
+
:q_puppetmaster_forward_facts => 'y',
|
47
|
+
}
|
48
|
+
|
49
|
+
dashboard_user = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_user_email)}'"
|
50
|
+
smtp_host = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_host, dashboard.to_s)}'"
|
51
|
+
dashboard_password = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_password)}'"
|
52
|
+
smtp_port = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_port)}'"
|
53
|
+
smtp_username = answer_for(options, :q_puppet_enterpriseconsole_smtp_username)
|
54
|
+
smtp_password = answer_for(options, :q_puppet_enterpriseconsole_smtp_password)
|
55
|
+
smtp_use_tls = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_use_tls)}'"
|
56
|
+
auth_database_name = answer_for(options, :q_puppet_enterpriseconsole_auth_database_name, 'console_auth')
|
57
|
+
auth_database_user = answer_for(options, :q_puppet_enterpriseconsole_auth_database_user, 'mYu7hu3r')
|
58
|
+
console_database_name = answer_for(options, :q_puppet_enterpriseconsole_database_name, 'console')
|
59
|
+
console_database_user = answer_for(options, :q_puppet_enterpriseconsole_database_user, 'mYc0nS03u3r')
|
60
|
+
console_inventory_port = answer_for(options, :q_puppet_enterpriseconsole_inventory_port, 8140)
|
61
|
+
console_httpd_port = answer_for(options, :q_puppet_enterpriseconsole_httpd_port, 443)
|
62
|
+
|
63
|
+
console_a = {
|
64
|
+
:q_puppet_enterpriseconsole_install => 'y',
|
65
|
+
:q_puppet_enterpriseconsole_database_install => 'y',
|
66
|
+
:q_puppet_enterpriseconsole_auth_database_name => auth_database_name,
|
67
|
+
:q_puppet_enterpriseconsole_auth_database_user => auth_database_user,
|
68
|
+
:q_puppet_enterpriseconsole_auth_database_password => dashboard_password,
|
69
|
+
:q_puppet_enterpriseconsole_database_name => console_database_name,
|
70
|
+
:q_puppet_enterpriseconsole_database_user => console_database_user,
|
71
|
+
:q_puppet_enterpriseconsole_database_root_password => dashboard_password,
|
72
|
+
:q_puppet_enterpriseconsole_database_password => dashboard_password,
|
73
|
+
:q_puppet_enterpriseconsole_inventory_hostname => host.to_s,
|
74
|
+
:q_puppet_enterpriseconsole_inventory_certname => host.to_s,
|
75
|
+
:q_puppet_enterpriseconsole_inventory_dnsaltnames => master.to_s,
|
76
|
+
:q_puppet_enterpriseconsole_inventory_port => console_inventory_port,
|
77
|
+
:q_puppet_enterpriseconsole_master_hostname => master.to_s,
|
78
|
+
:q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
|
79
|
+
:q_puppet_enterpriseconsole_auth_password => dashboard_password,
|
80
|
+
:q_puppet_enterpriseconsole_httpd_port => console_httpd_port,
|
81
|
+
:q_puppet_enterpriseconsole_smtp_host => smtp_host,
|
82
|
+
:q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
|
83
|
+
:q_puppet_enterpriseconsole_smtp_port => smtp_port,
|
84
|
+
}
|
85
|
+
|
86
|
+
console_a[:q_puppet_enterpriseconsole_auth_user] = console_a[:q_puppet_enterpriseconsole_auth_user_email]
|
87
|
+
|
88
|
+
if smtp_password and smtp_username
|
89
|
+
console_a.merge!({
|
90
|
+
:q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
|
91
|
+
:q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
|
92
|
+
:q_puppet_enterpriseconsole_smtp_user_auth => 'y'
|
93
|
+
})
|
94
|
+
end
|
95
|
+
|
96
|
+
answers = agent_a.dup
|
97
|
+
if host == master
|
98
|
+
answers.merge! master_a
|
99
|
+
end
|
100
|
+
|
101
|
+
if host == dashboard
|
102
|
+
answers.merge! console_a
|
103
|
+
end
|
104
|
+
|
105
|
+
return answers
|
106
|
+
end
|
107
|
+
|
108
|
+
# Return answer data for all hosts.
|
109
|
+
#
|
110
|
+
# @return [Hash] A hash (keyed from hosts) containing hashes of answer file
|
111
|
+
# data.
|
112
|
+
def generate_answers
|
113
|
+
the_answers = {}
|
114
|
+
dashboard = only_host_with_role(@hosts, 'dashboard')
|
115
|
+
master = only_host_with_role(@hosts, 'master')
|
116
|
+
@hosts.each do |h|
|
117
|
+
the_answers[h.name] = host_answers(h, master, dashboard, @options)
|
118
|
+
if the_answers[h.name] && h[:custom_answers]
|
119
|
+
the_answers[h.name] = the_answers[h.name].merge(h[:custom_answers])
|
120
|
+
end
|
121
|
+
h[:answers] = the_answers[h.name]
|
122
|
+
end
|
123
|
+
return the_answers
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module BeakerAnswers
|
2
|
+
# This class provides answer file information for PE version 2.8
|
3
|
+
#
|
4
|
+
# @api private
|
5
|
+
class Version28 < Answers
|
6
|
+
|
7
|
+
# The version of PE that this set of answers is appropriate for
|
8
|
+
def self.pe_version_matcher
|
9
|
+
/\A2\.8/
|
10
|
+
end
|
11
|
+
|
12
|
+
# Return answer data for a host
|
13
|
+
#
|
14
|
+
# @param [Beaker::Host] host Host to return data for
|
15
|
+
# @param [Beaker::Host] master Host object representing the master
|
16
|
+
# @param [Beaker::Host] dashboard Host object representing the dashboard
|
17
|
+
# @param [Hash] options options for answer files
|
18
|
+
# @option options [Symbol] :type Should be one of :upgrade or :install.
|
19
|
+
# @return [Hash] A hash (keyed from hosts) containing hashes of answer file
|
20
|
+
# data.
|
21
|
+
def host_answers(host, master, dashboard, options)
|
22
|
+
return nil if host['platform'] =~ /windows/
|
23
|
+
|
24
|
+
agent_a = {
|
25
|
+
:q_install => 'y',
|
26
|
+
:q_puppetagent_install => 'y',
|
27
|
+
:q_puppet_cloud_install => 'y',
|
28
|
+
:q_puppet_symlinks_install => 'y',
|
29
|
+
:q_vendor_packages_install => 'y',
|
30
|
+
:q_puppetagent_certname => host.to_s,
|
31
|
+
:q_puppetagent_server => master.to_s,
|
32
|
+
|
33
|
+
# Disable console and master by default
|
34
|
+
# This will be overridden by other blocks being merged in
|
35
|
+
:q_puppetmaster_install => 'n',
|
36
|
+
:q_puppet_enterpriseconsole_install => 'n',
|
37
|
+
}
|
38
|
+
|
39
|
+
master_dns_altnames = [master.to_s, master['ip'], 'puppet'].compact.uniq.join(',')
|
40
|
+
master_a = {
|
41
|
+
:q_puppetmaster_install => 'y',
|
42
|
+
:q_puppetmaster_certname => master.to_s,
|
43
|
+
:q_puppetmaster_dnsaltnames => master_dns_altnames,
|
44
|
+
:q_puppetmaster_enterpriseconsole_hostname => dashboard.to_s,
|
45
|
+
:q_puppetmaster_enterpriseconsole_port => answer_for(options, :q_puppetmaster_enterpriseconsole_port, 443),
|
46
|
+
:q_puppetmaster_forward_facts => 'y',
|
47
|
+
}
|
48
|
+
|
49
|
+
dashboard_user = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_user_email)}'"
|
50
|
+
smtp_host = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_host, dashboard.to_s)}'"
|
51
|
+
dashboard_password = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_password)}'"
|
52
|
+
smtp_port = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_port)}'"
|
53
|
+
smtp_username = answer_for(options, :q_puppet_enterpriseconsole_smtp_username)
|
54
|
+
smtp_password = answer_for(options, :q_puppet_enterpriseconsole_smtp_password)
|
55
|
+
smtp_use_tls = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_use_tls)}'"
|
56
|
+
auth_database_name = answer_for(options, :q_puppet_enterpriseconsole_auth_database_name, 'console_auth')
|
57
|
+
auth_database_user = answer_for(options, :q_puppet_enterpriseconsole_auth_database_user, 'mYu7hu3r')
|
58
|
+
console_database_name = answer_for(options, :q_puppet_enterpriseconsole_database_name, 'console')
|
59
|
+
console_database_user = answer_for(options, :q_puppet_enterpriseconsole_database_user, 'mYc0nS03u3r')
|
60
|
+
console_inventory_port = answer_for(options, :q_puppet_enterpriseconsole_inventory_port, 8140)
|
61
|
+
console_httpd_port = answer_for(options, :q_puppet_enterpriseconsole_httpd_port, 443)
|
62
|
+
|
63
|
+
console_a = {
|
64
|
+
:q_puppet_enterpriseconsole_install => 'y',
|
65
|
+
:q_puppet_enterpriseconsole_database_install => 'y',
|
66
|
+
:q_puppet_enterpriseconsole_auth_database_name => auth_database_name,
|
67
|
+
:q_puppet_enterpriseconsole_auth_database_user => auth_database_user,
|
68
|
+
:q_puppet_enterpriseconsole_auth_database_password => dashboard_password,
|
69
|
+
:q_puppet_enterpriseconsole_database_name => console_database_name,
|
70
|
+
:q_puppet_enterpriseconsole_database_user => console_database_user,
|
71
|
+
:q_puppet_enterpriseconsole_database_password => dashboard_password,
|
72
|
+
:q_puppet_enterpriseconsole_inventory_hostname => host.to_s,
|
73
|
+
:q_puppet_enterpriseconsole_inventory_certname => host.to_s,
|
74
|
+
:q_puppet_enterpriseconsole_inventory_dnsaltnames => master.to_s,
|
75
|
+
:q_puppet_enterpriseconsole_inventory_port => console_inventory_port,
|
76
|
+
:q_puppet_enterpriseconsole_master_hostname => master.to_s,
|
77
|
+
:q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
|
78
|
+
:q_puppet_enterpriseconsole_auth_password => dashboard_password,
|
79
|
+
:q_puppet_enterpriseconsole_httpd_port => console_httpd_port,
|
80
|
+
:q_puppet_enterpriseconsole_smtp_host => smtp_host,
|
81
|
+
:q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
|
82
|
+
:q_puppet_enterpriseconsole_smtp_port => smtp_port,
|
83
|
+
}
|
84
|
+
|
85
|
+
console_a[:q_puppet_enterpriseconsole_auth_user] = console_a[:q_puppet_enterpriseconsole_auth_user_email]
|
86
|
+
|
87
|
+
if smtp_password and smtp_username
|
88
|
+
console_a.merge!({
|
89
|
+
:q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
|
90
|
+
:q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
|
91
|
+
:q_puppet_enterpriseconsole_smtp_user_auth => 'y'
|
92
|
+
})
|
93
|
+
end
|
94
|
+
|
95
|
+
answers = agent_a.dup
|
96
|
+
if host == master
|
97
|
+
answers.merge! master_a
|
98
|
+
end
|
99
|
+
|
100
|
+
if host == dashboard
|
101
|
+
answers.merge! console_a
|
102
|
+
end
|
103
|
+
|
104
|
+
return answers
|
105
|
+
end
|
106
|
+
|
107
|
+
# Return answer data for all hosts.
|
108
|
+
#
|
109
|
+
# @return [Hash] A hash (keyed from hosts) containing hashes of answer file
|
110
|
+
# data.
|
111
|
+
def generate_answers
|
112
|
+
the_answers = {}
|
113
|
+
dashboard = only_host_with_role(@hosts, 'dashboard')
|
114
|
+
master = only_host_with_role(@hosts, 'master')
|
115
|
+
@hosts.each do |h|
|
116
|
+
the_answers[h.name] = host_answers(h, master, dashboard, @options)
|
117
|
+
if the_answers[h.name] && h[:custom_answers]
|
118
|
+
the_answers[h.name] = the_answers[h.name].merge(h[:custom_answers])
|
119
|
+
end
|
120
|
+
h[:answers] = the_answers[h.name]
|
121
|
+
end
|
122
|
+
return the_answers
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
module BeakerAnswers
|
2
|
+
# This class provides answer file information for PE version 3.x
|
3
|
+
#
|
4
|
+
# @api private
|
5
|
+
class Version30 < Answers
|
6
|
+
|
7
|
+
# The version of PE that this set of answers is appropriate for
|
8
|
+
def self.pe_version_matcher
|
9
|
+
/\A3\.(0|1)/
|
10
|
+
end
|
11
|
+
|
12
|
+
# Return answer data for a host
|
13
|
+
#
|
14
|
+
# @param [Beaker::Host] host Host to return data for
|
15
|
+
# @param [Beaker::Host] master Host object representing the master
|
16
|
+
# @param [Beaker::Host] dashboard Host object representing the dashboard
|
17
|
+
# @param [Hash] options options for answer files
|
18
|
+
# @option options [Symbol] :type Should be one of :upgrade or :install.
|
19
|
+
# @return [Hash] A hash (keyed from hosts) containing hashes of answer file
|
20
|
+
# data.
|
21
|
+
def host_answers(host, master, database, dashboard, options)
|
22
|
+
# Windows hosts don't have normal answers...
|
23
|
+
return nil if host['platform'] =~ /windows/
|
24
|
+
masterless = options[:masterless]
|
25
|
+
|
26
|
+
# Everything's an agent
|
27
|
+
agent_a = {
|
28
|
+
:q_puppetagent_install => answer_for(options, :q_puppetagent_install, 'y'),
|
29
|
+
:q_puppet_cloud_install => answer_for(options, :q_puppet_cloud_install, 'y'),
|
30
|
+
:q_verify_packages => answer_for(options, :q_verify_packages, 'y'),
|
31
|
+
:q_puppet_symlinks_install => answer_for(options, :q_puppet_symlinks_install, 'y'),
|
32
|
+
:q_puppetagent_certname => answer_for(options, :q_puppetagent_certname, host.to_s),
|
33
|
+
|
34
|
+
# Disable database, console, and master by default
|
35
|
+
# This will be overridden by other blocks being merged in.
|
36
|
+
:q_puppetmaster_install => answer_for(options, :q_puppetmaster_install, 'n'),
|
37
|
+
:q_all_in_one_install => answer_for(options, :q_all_in_one_install, 'n'),
|
38
|
+
:q_puppet_enterpriseconsole_install => answer_for(options, :q_puppet_enterpriseconsole_install, 'n'),
|
39
|
+
:q_puppetdb_install => answer_for(options, :q_puppetdb_install, 'n'),
|
40
|
+
:q_database_install => answer_for(options, :q_database_install, 'n'),
|
41
|
+
}
|
42
|
+
agent_a[:q_puppetagent_server] = masterless ? host.to_s : master.to_s
|
43
|
+
agent_a[:q_continue_or_reenter_master_hostname] = 'c' if masterless
|
44
|
+
|
45
|
+
# These base answers are needed by all
|
46
|
+
common_a = {
|
47
|
+
:q_install => answer_for(options, :q_install, 'y'),
|
48
|
+
:q_vendor_packages_install => answer_for(options, :q_vendor_packages_install, 'y'),
|
49
|
+
}
|
50
|
+
|
51
|
+
unless masterless
|
52
|
+
# master/database answers
|
53
|
+
master_database_a = {
|
54
|
+
:q_puppetmaster_certname => answer_for(options, :q_puppetmaster_certname, master.to_s)
|
55
|
+
}
|
56
|
+
|
57
|
+
# Master/dashboard answers
|
58
|
+
master_console_a = {
|
59
|
+
:q_puppetdb_hostname => answer_for(options, :q_puppetdb_hostname, database.to_s),
|
60
|
+
:q_puppetdb_port => answer_for(options, :q_puppetdb_port, 8081)
|
61
|
+
}
|
62
|
+
|
63
|
+
# Master only answers
|
64
|
+
master_dns_altnames = [master.to_s, master['ip'], 'puppet'].compact.uniq.join(',')
|
65
|
+
master_a = {
|
66
|
+
:q_puppetmaster_install => answer_for(options, :q_puppetmaster_install, 'y'),
|
67
|
+
:q_puppetmaster_dnsaltnames => master_dns_altnames,
|
68
|
+
:q_puppetmaster_enterpriseconsole_hostname => answer_for(options, :q_puppetmaster_enterpriseconsole_hostname, dashboard.to_s),
|
69
|
+
:q_puppetmaster_enterpriseconsole_port => answer_for(options, :q_puppetmaster_enterpriseconsole_port, 443),
|
70
|
+
}
|
71
|
+
|
72
|
+
# Common answers for console and database
|
73
|
+
console_auth_password = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_password)}'"
|
74
|
+
puppetdb_database_name = answer_for(options, :q_puppetdb_database_name, 'pe-puppetdb')
|
75
|
+
puppetdb_database_user = answer_for(options, :q_puppetdb_database_user, 'mYpdBu3r')
|
76
|
+
puppetdb_database_password = answer_for(options, :q_puppetdb_database_password, "'#{answer_for(options, :q_puppetdb_password)}'")
|
77
|
+
console_auth_database_name = answer_for(options, :q_puppet_enterpriseconsole_auth_database_name, 'console_auth')
|
78
|
+
console_auth_database_user = answer_for(options, :q_puppet_enterpriseconsole_auth_database_user, 'mYu7hu3r')
|
79
|
+
console_auth_database_password = answer_for(options, :q_puppet_enterpriseconsole_auth_database_password, console_auth_password)
|
80
|
+
console_database_name = answer_for(options, :q_puppet_enterpriseconsole_database_name, 'console')
|
81
|
+
console_database_user = answer_for(options, :q_puppet_enterpriseconsole_database_user, 'mYc0nS03u3r')
|
82
|
+
console_database_host = answer_for(options, :q_database_host, database.to_s)
|
83
|
+
console_database_port = answer_for(options, :q_database_port, 5432)
|
84
|
+
console_database_password = answer_for(options, :q_puppet_enterpriseconsole_database_password, console_auth_password)
|
85
|
+
|
86
|
+
console_database_a = {
|
87
|
+
:q_puppetdb_database_name => puppetdb_database_name,
|
88
|
+
:q_puppetdb_database_user => puppetdb_database_user,
|
89
|
+
:q_puppetdb_database_password => puppetdb_database_password,
|
90
|
+
:q_puppet_enterpriseconsole_auth_database_name => console_auth_database_name,
|
91
|
+
:q_puppet_enterpriseconsole_auth_database_user => console_auth_database_user,
|
92
|
+
:q_puppet_enterpriseconsole_auth_database_password => console_auth_database_password,
|
93
|
+
:q_puppet_enterpriseconsole_database_name => console_database_name,
|
94
|
+
:q_puppet_enterpriseconsole_database_user => console_database_user,
|
95
|
+
:q_puppet_enterpriseconsole_database_password => console_database_password,
|
96
|
+
:q_database_host => console_database_host,
|
97
|
+
:q_database_port => console_database_port,
|
98
|
+
}
|
99
|
+
|
100
|
+
# Console only answers
|
101
|
+
dashboard_user = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_user_email)}'"
|
102
|
+
|
103
|
+
|
104
|
+
console_install = answer_for(options, :q_puppet_enterpriseconsole_install, 'y')
|
105
|
+
console_inventory_hostname = answer_for(options, :q_puppet_enterpriseconsole_inventory_hostname, host.to_s)
|
106
|
+
console_inventory_certname = answer_for(options, :q_puppet_enterpriseconsole_inventory_certname, host.to_s)
|
107
|
+
console_inventory_dnsaltnames = answer_for(options, :q_puppet_enterpriseconsole_inventory_dnsaltnames, dashboard.to_s)
|
108
|
+
smtp_host = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_host, dashboard.to_s)}'"
|
109
|
+
smtp_port = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_port)}'"
|
110
|
+
smtp_username = answer_for(options, :q_puppet_enterpriseconsole_smtp_username)
|
111
|
+
smtp_password = answer_for(options, :q_puppet_enterpriseconsole_smtp_password)
|
112
|
+
smtp_use_tls = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_use_tls)}'"
|
113
|
+
console_inventory_port = answer_for(options, :q_puppet_enterpriseconsole_inventory_port, 8140)
|
114
|
+
master_hostname = answer_for(options, :q_puppet_enterpriseconsole_master_hostname, master.to_s)
|
115
|
+
console_httpd_port = answer_for(options, :q_puppet_enterpriseconsole_httpd_port, 443)
|
116
|
+
|
117
|
+
console_a = {
|
118
|
+
:q_puppet_enterpriseconsole_install => console_install,
|
119
|
+
:q_puppet_enterpriseconsole_inventory_hostname => console_inventory_hostname,
|
120
|
+
:q_puppet_enterpriseconsole_inventory_certname => console_inventory_certname,
|
121
|
+
:q_puppet_enterpriseconsole_inventory_dnsaltnames => console_inventory_dnsaltnames,
|
122
|
+
:q_puppet_enterpriseconsole_inventory_port => console_inventory_port,
|
123
|
+
:q_puppet_enterpriseconsole_master_hostname => master_hostname,
|
124
|
+
:q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
|
125
|
+
:q_puppet_enterpriseconsole_auth_password => console_auth_password,
|
126
|
+
:q_puppet_enterpriseconsole_httpd_port => console_httpd_port,
|
127
|
+
:q_puppet_enterpriseconsole_smtp_host => smtp_host,
|
128
|
+
:q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
|
129
|
+
:q_puppet_enterpriseconsole_smtp_port => smtp_port,
|
130
|
+
}
|
131
|
+
|
132
|
+
if smtp_password and smtp_username
|
133
|
+
console_smtp_user_auth = answer_for(options, :q_puppet_enterpriseconsole_smtp_user_auth, 'y')
|
134
|
+
console_a.merge!({
|
135
|
+
:q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
|
136
|
+
:q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
|
137
|
+
:q_puppet_enterpriseconsole_smtp_user_auth => console_smtp_user_auth
|
138
|
+
})
|
139
|
+
end
|
140
|
+
|
141
|
+
# Database only answers
|
142
|
+
database_a = {
|
143
|
+
:q_puppetdb_install => answer_for(options, :q_puppetdb_install, 'y'),
|
144
|
+
:q_database_install => answer_for(options, :q_database_install, 'y'),
|
145
|
+
:q_database_root_password => "'#{answer_for(options, :q_database_root_password, '=ZYdjiP3jCwV5eo9s1MBd')}'",
|
146
|
+
:q_database_root_user => answer_for(options, :q_database_root_user, 'pe-postgres'),
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
150
|
+
# Special answers for special hosts
|
151
|
+
aix_a = {
|
152
|
+
:q_run_updtvpkg => answer_for(options, :q_run_updtvpkg, 'y'),
|
153
|
+
}
|
154
|
+
|
155
|
+
answers = common_a.dup
|
156
|
+
|
157
|
+
unless options[:type] == :upgrade
|
158
|
+
answers.merge! agent_a
|
159
|
+
end
|
160
|
+
|
161
|
+
if host == master
|
162
|
+
answers.merge! master_console_a
|
163
|
+
unless options[:type] == :upgrade
|
164
|
+
answers.merge! master_a
|
165
|
+
answers.merge! master_database_a
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
if host == dashboard
|
170
|
+
answers.merge! master_console_a
|
171
|
+
answers.merge! console_database_a
|
172
|
+
answers[:q_pe_database] = answer_for(options, :q_pe_database, 'y')
|
173
|
+
unless options[:type] == :upgrade
|
174
|
+
answers.merge! console_a
|
175
|
+
else
|
176
|
+
answers[:q_database_export_dir] = answer_for(options, :q_database_export_dir, '/tmp')
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
if host == database
|
181
|
+
if database != master
|
182
|
+
if options[:type] == :upgrade
|
183
|
+
# This is kinda annoying - if we're upgrading to 3.0 and are
|
184
|
+
# puppetdb, we're actually doing a clean install. We thus
|
185
|
+
# need the core agent answers.
|
186
|
+
answers.merge! agent_a
|
187
|
+
end
|
188
|
+
answers.merge! master_database_a
|
189
|
+
end
|
190
|
+
answers.merge! database_a
|
191
|
+
answers.merge! console_database_a
|
192
|
+
end
|
193
|
+
|
194
|
+
if host == master and host == database and host == dashboard
|
195
|
+
answers[:q_all_in_one_install] = 'y'
|
196
|
+
end
|
197
|
+
|
198
|
+
if host['platform'].include? 'aix'
|
199
|
+
answers.merge! aix_a
|
200
|
+
end
|
201
|
+
|
202
|
+
return answers
|
203
|
+
end
|
204
|
+
|
205
|
+
# Return answer data for all hosts.
|
206
|
+
#
|
207
|
+
# @return [Hash] A hash (keyed from hosts) containing hashes of answer file
|
208
|
+
# data.
|
209
|
+
def generate_answers
|
210
|
+
the_answers = {}
|
211
|
+
masterless = @options[:masterless]
|
212
|
+
database = masterless ? nil : only_host_with_role(@hosts, 'database')
|
213
|
+
dashboard = masterless ? nil : only_host_with_role(@hosts, 'dashboard')
|
214
|
+
master = masterless ? nil : only_host_with_role(@hosts, 'master')
|
215
|
+
@hosts.each do |h|
|
216
|
+
if @options[:type] == :upgrade and h[:pe_ver] =~ /\A3.0/
|
217
|
+
# 3.0.x to 3.0.x should require no answers
|
218
|
+
the_answers[h.name] = {
|
219
|
+
:q_install => answer_for(@options, :q_install, 'y'),
|
220
|
+
:q_install_vendor_packages => answer_for(@options, :q_install_vendor_packages, 'y'),
|
221
|
+
}
|
222
|
+
else
|
223
|
+
the_answers[h.name] = host_answers(h, master, database, dashboard, @options)
|
224
|
+
end
|
225
|
+
if the_answers[h.name] && h[:custom_answers]
|
226
|
+
the_answers[h.name] = the_answers[h.name].merge(h[:custom_answers])
|
227
|
+
end
|
228
|
+
h[:answers] = the_answers[h.name]
|
229
|
+
end
|
230
|
+
return the_answers
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|