beaker 1.19.1 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +295 -4
  3. data/README.md +4 -0
  4. data/lib/beaker/answers/version20.rb +103 -107
  5. data/lib/beaker/answers/version28.rb +111 -115
  6. data/lib/beaker/answers/version30.rb +194 -192
  7. data/lib/beaker/answers/version32.rb +27 -22
  8. data/lib/beaker/answers/version34.rb +6 -6
  9. data/lib/beaker/answers.rb +55 -21
  10. data/lib/beaker/cli.rb +13 -11
  11. data/lib/beaker/dsl/helpers.rb +2 -2
  12. data/lib/beaker/dsl/install_utils.rb +2 -4
  13. data/lib/beaker/host.rb +9 -5
  14. data/lib/beaker/host_prebuilt_steps.rb +33 -20
  15. data/lib/beaker/hypervisor/aws_sdk.rb +12 -10
  16. data/lib/beaker/hypervisor/ec2_helper.rb +1 -0
  17. data/lib/beaker/hypervisor/google_compute.rb +0 -1
  18. data/lib/beaker/hypervisor/vagrant.rb +11 -16
  19. data/lib/beaker/hypervisor/vagrant_fusion.rb +17 -0
  20. data/lib/beaker/hypervisor/vagrant_virtualbox.rb +26 -0
  21. data/lib/beaker/hypervisor/vagrant_workstation.rb +13 -0
  22. data/lib/beaker/hypervisor/vcloud_pooled.rb +3 -1
  23. data/lib/beaker/hypervisor.rb +22 -13
  24. data/lib/beaker/logger.rb +29 -0
  25. data/lib/beaker/options/command_line_parser.rb +2 -0
  26. data/lib/beaker/options/parser.rb +5 -4
  27. data/lib/beaker/options/presets.rb +58 -35
  28. data/lib/beaker/version.rb +1 -1
  29. data/spec/beaker/answers_spec.rb +156 -135
  30. data/spec/beaker/cli_spec.rb +35 -2
  31. data/spec/beaker/dsl/install_utils_spec.rb +2 -3
  32. data/spec/beaker/host_prebuilt_steps_spec.rb +47 -24
  33. data/spec/beaker/host_spec.rb +6 -6
  34. data/spec/beaker/hypervisor/ec2_helper_spec.rb +2 -2
  35. data/spec/beaker/hypervisor/hypervisor_spec.rb +35 -0
  36. data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +34 -0
  37. data/spec/beaker/hypervisor/vagrant_spec.rb +39 -2
  38. data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +34 -0
  39. data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +34 -0
  40. data/spec/beaker/logger_spec.rb +30 -0
  41. data/spec/beaker/options/presets_spec.rb +4 -4
  42. data/spec/helpers.rb +2 -1
  43. data/spec/mocks.rb +5 -1
  44. metadata +9 -60
@@ -1,126 +1,122 @@
1
1
  module Beaker
2
- module Answers
3
- # This class provides answer file information for PE version 2.8
4
- #
5
- # @api private
6
- module Version28
7
-
8
- # Return answer data for a host
9
- #
10
- # @param [Beaker::Host] host Host to return data for
11
- # @param [String] master_certname Hostname of the puppet master.
12
- # @param [Beaker::Host] master Host object representing the master
13
- # @param [Beaker::Host] dashboard Host object representing the dashboard
14
- # @param [Hash] options options for answer files
15
- # @option options [Symbol] :type Should be one of :upgrade or :install.
16
- # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
17
- # data.
18
- def self.host_answers(host, master_certname, master, dashboard, options)
19
- return nil if host['platform'] =~ /windows/
20
-
21
- agent_a = {
22
- :q_install => 'y',
23
- :q_puppetagent_install => 'y',
24
- :q_puppet_cloud_install => 'y',
25
- :q_puppet_symlinks_install => 'y',
26
- :q_vendor_packages_install => 'y',
27
- :q_puppetagent_certname => host,
28
- :q_puppetagent_server => master,
29
-
30
- # Disable console and master by default
31
- # This will be overridden by other blocks being merged in
32
- :q_puppetmaster_install => 'n',
33
- :q_puppet_enterpriseconsole_install => 'n',
34
- }
35
-
36
- master_a = {
37
- :q_puppetmaster_install => 'y',
38
- :q_puppetmaster_certname => master_certname,
39
- :q_puppetmaster_install => 'y',
40
- :q_puppetmaster_dnsaltnames => master_certname+",puppet",
41
- :q_puppetmaster_enterpriseconsole_hostname => dashboard,
42
- :q_puppetmaster_enterpriseconsole_port => 443,
43
- :q_puppetmaster_forward_facts => 'y',
44
- }
45
-
46
- if master['ip']
47
- master_a[:q_puppetmaster_dnsaltnames]+=","+master['ip']
48
- end
49
-
50
- dashboard_user = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_user_email]}'"
51
- smtp_host = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_host] || dashboard}'"
52
- dashboard_password = options[:answers][:q_puppet_enterpriseconsole_auth_password]
53
- smtp_port = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_port]}'"
54
- smtp_username = options[:answers][:q_puppet_enterpriseconsole_smtp_username]
55
- smtp_password = options[:answers][:q_puppet_enterpriseconsole_smtp_password]
56
- smtp_use_tls = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_use_tls]}'"
57
-
58
- console_a = {
59
- :q_puppet_enterpriseconsole_install => 'y',
60
- :q_puppet_enterpriseconsole_database_install => 'y',
61
- :q_puppet_enterpriseconsole_auth_database_name => 'console_auth',
62
- :q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r',
63
- :q_puppet_enterpriseconsole_auth_database_password => "'#{dashboard_password}'",
64
- :q_puppet_enterpriseconsole_database_name => 'console',
65
- :q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r',
66
- :q_puppet_enterpriseconsole_database_password => "'#{dashboard_password}'",
67
- :q_puppet_enterpriseconsole_inventory_hostname => host,
68
- :q_puppet_enterpriseconsole_inventory_certname => host,
69
- :q_puppet_enterpriseconsole_inventory_dnsaltnames => master,
70
- :q_puppet_enterpriseconsole_inventory_port => 8140,
71
- :q_puppet_enterpriseconsole_master_hostname => master,
72
-
73
- :q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
74
- :q_puppet_enterpriseconsole_auth_password => "'#{dashboard_password}'",
75
-
76
- :q_puppet_enterpriseconsole_httpd_port => 443,
77
-
78
- :q_puppet_enterpriseconsole_smtp_host => smtp_host,
79
- :q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
80
- :q_puppet_enterpriseconsole_smtp_port => smtp_port,
81
- }
82
-
83
- console_a[:q_puppet_enterpriseconsole_auth_user] = console_a[:q_puppet_enterpriseconsole_auth_user_email]
2
+ # This class provides answer file information for PE version 2.8
3
+ #
4
+ # @api private
5
+ class Version28 < Answers
84
6
 
85
- if smtp_password and smtp_username
86
- console_a.merge!({
87
- :q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
88
- :q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
89
- :q_puppet_enterpriseconsole_smtp_user_auth => 'y'
90
- })
91
- end
92
-
93
- answers = agent_a.dup
94
- if host == master
95
- answers.merge! master_a
96
- end
7
+ # Return answer data for a host
8
+ #
9
+ # @param [Beaker::Host] host Host to return data for
10
+ # @param [Beaker::Host] master Host object representing the master
11
+ # @param [Beaker::Host] dashboard Host object representing the dashboard
12
+ # @param [Hash] options options for answer files
13
+ # @option options [Symbol] :type Should be one of :upgrade or :install.
14
+ # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
15
+ # data.
16
+ def host_answers(host, master, dashboard, options)
17
+ return nil if host['platform'] =~ /windows/
18
+
19
+ agent_a = {
20
+ :q_install => 'y',
21
+ :q_puppetagent_install => 'y',
22
+ :q_puppet_cloud_install => 'y',
23
+ :q_puppet_symlinks_install => 'y',
24
+ :q_vendor_packages_install => 'y',
25
+ :q_puppetagent_certname => host,
26
+ :q_puppetagent_server => master,
27
+
28
+ # Disable console and master by default
29
+ # This will be overridden by other blocks being merged in
30
+ :q_puppetmaster_install => 'n',
31
+ :q_puppet_enterpriseconsole_install => 'n',
32
+ }
33
+
34
+ master_dns_altnames = [master.to_s, master['ip'], 'puppet'].compact.uniq.join(',')
35
+ master_a = {
36
+ :q_puppetmaster_install => 'y',
37
+ :q_puppetmaster_certname => master,
38
+ :q_puppetmaster_install => 'y',
39
+ :q_puppetmaster_dnsaltnames => master_dns_altnames,
40
+ :q_puppetmaster_enterpriseconsole_hostname => dashboard,
41
+ :q_puppetmaster_enterpriseconsole_port => answer_for(options, :q_puppetmaster_enterpriseconsole_port, 443),
42
+ :q_puppetmaster_forward_facts => 'y',
43
+ }
44
+
45
+ dashboard_user = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_user_email)}'"
46
+ smtp_host = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_host, dashboard)}'"
47
+ dashboard_password = "'#{answer_for(options, :q_puppet_enterpriseconsole_auth_password)}'"
48
+ smtp_port = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_port)}'"
49
+ smtp_username = answer_for(options, :q_puppet_enterpriseconsole_smtp_username)
50
+ smtp_password = answer_for(options, :q_puppet_enterpriseconsole_smtp_password)
51
+ smtp_use_tls = "'#{answer_for(options, :q_puppet_enterpriseconsole_smtp_use_tls)}'"
52
+ auth_database_name = answer_for(options, :q_puppet_enterpriseconsole_auth_database_name, 'console_auth')
53
+ auth_database_user = answer_for(options, :q_puppet_enterpriseconsole_auth_database_user, 'mYu7hu3r')
54
+ console_database_name = answer_for(options, :q_puppet_enterpriseconsole_database_name, 'console')
55
+ console_database_user = answer_for(options, :q_puppet_enterpriseconsole_database_user, 'mYc0nS03u3r')
56
+ console_inventory_port = answer_for(options, :q_puppet_enterpriseconsole_inventory_port, 8140)
57
+ console_httpd_port = answer_for(options, :q_puppet_enterpriseconsole_httpd_port, 443)
58
+
59
+ console_a = {
60
+ :q_puppet_enterpriseconsole_install => 'y',
61
+ :q_puppet_enterpriseconsole_database_install => 'y',
62
+ :q_puppet_enterpriseconsole_auth_database_name => auth_database_name,
63
+ :q_puppet_enterpriseconsole_auth_database_user => auth_database_user,
64
+ :q_puppet_enterpriseconsole_auth_database_password => dashboard_password,
65
+ :q_puppet_enterpriseconsole_database_name => console_database_name,
66
+ :q_puppet_enterpriseconsole_database_user => console_database_user,
67
+ :q_puppet_enterpriseconsole_database_password => dashboard_password,
68
+ :q_puppet_enterpriseconsole_inventory_hostname => host,
69
+ :q_puppet_enterpriseconsole_inventory_certname => host,
70
+ :q_puppet_enterpriseconsole_inventory_dnsaltnames => master,
71
+ :q_puppet_enterpriseconsole_inventory_port => console_inventory_port,
72
+ :q_puppet_enterpriseconsole_master_hostname => master,
73
+ :q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
74
+ :q_puppet_enterpriseconsole_auth_password => dashboard_password,
75
+ :q_puppet_enterpriseconsole_httpd_port => console_httpd_port,
76
+ :q_puppet_enterpriseconsole_smtp_host => smtp_host,
77
+ :q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
78
+ :q_puppet_enterpriseconsole_smtp_port => smtp_port,
79
+ }
80
+
81
+ console_a[:q_puppet_enterpriseconsole_auth_user] = console_a[:q_puppet_enterpriseconsole_auth_user_email]
82
+
83
+ if smtp_password and smtp_username
84
+ console_a.merge!({
85
+ :q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
86
+ :q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
87
+ :q_puppet_enterpriseconsole_smtp_user_auth => 'y'
88
+ })
89
+ end
97
90
 
98
- if host == dashboard
99
- answers.merge! console_a
100
- end
91
+ answers = agent_a.dup
92
+ if host == master
93
+ answers.merge! master_a
94
+ end
101
95
 
102
- return answers
96
+ if host == dashboard
97
+ answers.merge! console_a
103
98
  end
104
99
 
105
- # Return answer data for all hosts.
106
- #
107
- # @param [Array<Beaker::Host>] hosts An array of host objects.
108
- # @param [String] master_certname Hostname of the puppet master.
109
- # @param [Hash] options options for answer files
110
- # @option options [Symbol] :type Should be one of :upgrade or :install.
111
- # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
112
- # data.
113
- def self.answers(hosts, master_certname, options)
114
- the_answers = {}
115
- dashboard = only_host_with_role(hosts, 'dashboard')
116
- master = only_host_with_role(hosts, 'master')
117
- hosts.each do |h|
118
- the_answers[h.name] = host_answers(h, master_certname, master, dashboard, options)
119
- h[:answers] = the_answers[h.name]
100
+ return answers
101
+ end
102
+
103
+ # Return answer data for all hosts.
104
+ #
105
+ # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
106
+ # data.
107
+ def generate_answers
108
+ the_answers = {}
109
+ dashboard = only_host_with_role(@hosts, 'dashboard')
110
+ master = only_host_with_role(@hosts, 'master')
111
+ @hosts.each do |h|
112
+ the_answers[h.name] = host_answers(h, master, dashboard, @options)
113
+ if h[:custom_answers]
114
+ the_answers[h.name] = the_answers[h.name].merge(h[:custom_answers])
120
115
  end
121
- return the_answers
116
+ h[:answers] = the_answers[h.name]
122
117
  end
123
-
118
+ return the_answers
124
119
  end
120
+
125
121
  end
126
122
  end
@@ -1,215 +1,217 @@
1
1
  module Beaker
2
- module Answers
3
- # This class provides answer file information for PE version 3.x
2
+ # This class provides answer file information for PE version 3.x
3
+ #
4
+ # @api private
5
+ class Version30 < Answers
6
+ # Return answer data for a host
4
7
  #
5
- # @api private
6
- module Version30
7
- # Return answer data for a host
8
- #
9
- # @param [Beaker::Host] host Host to return data for
10
- # @param [String] master_certname Hostname of the puppet master.
11
- # @param [Beaker::Host] master Host object representing the master
12
- # @param [Beaker::Host] dashboard Host object representing the dashboard
13
- # @param [Hash] options options for answer files
14
- # @option options [Symbol] :type Should be one of :upgrade or :install.
15
- # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
16
- # data.
17
- def self.host_answers(host, master_certname, master, database, dashboard, options)
18
- # Windows hosts don't have normal answers...
19
- return nil if host['platform'] =~ /windows/
20
-
21
- # Everything's an agent
22
- agent_a = {
23
- :q_puppetagent_install => 'y',
24
- :q_puppet_cloud_install => 'y',
25
- :q_verify_packages => options[:answers][:q_verify_packages],
26
- :q_puppet_symlinks_install => 'y',
27
- :q_puppetagent_certname => host,
28
- :q_puppetagent_server => master_certname,
29
-
30
- # Disable database, console, and master by default
31
- # This will be overridden by other blocks being merged in.
32
- :q_puppetmaster_install => 'n',
33
- :q_all_in_one_install => 'n',
34
- :q_puppet_enterpriseconsole_install => 'n',
35
- :q_puppetdb_install => 'n',
36
- :q_database_install => 'n',
37
- }
38
-
39
- # These base answers are needed by all
40
- common_a = {
41
- :q_install => 'y',
42
- :q_vendor_packages_install => 'y',
43
- }
44
-
45
- # master/database answers
46
- master_database_a = {
47
- :q_puppetmaster_certname => master_certname
48
- }
49
-
50
- # Master/dashboard answers
51
- master_console_a = {
52
- :q_puppetdb_hostname => database,
53
- :q_puppetdb_port => 8081
54
- }
55
-
56
- # Master only answers
57
- master_a = {
58
- :q_puppetmaster_install => 'y',
59
- :q_puppetmaster_dnsaltnames => master_certname+",puppet",
60
- :q_puppetmaster_enterpriseconsole_hostname => dashboard,
61
- :q_puppetmaster_enterpriseconsole_port => 443,
62
- }
63
-
64
- if master['ip']
65
- master_a[:q_puppetmaster_dnsaltnames]+= "," + master['ip']
66
- end
8
+ # @param [Beaker::Host] host Host to return data for
9
+ # @param [Beaker::Host] master Host object representing the master
10
+ # @param [Beaker::Host] dashboard Host object representing the dashboard
11
+ # @param [Hash] options options for answer files
12
+ # @option options [Symbol] :type Should be one of :upgrade or :install.
13
+ # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
14
+ # data.
15
+ def host_answers(host, master, database, dashboard, options)
16
+ # Windows hosts don't have normal answers...
17
+ return nil if host['platform'] =~ /windows/
18
+
19
+ # Everything's an agent
20
+ agent_a = {
21
+ :q_puppetagent_install => 'y',
22
+ :q_puppet_cloud_install => 'y',
23
+ :q_verify_packages => options[:answers][:q_verify_packages],
24
+ :q_puppet_symlinks_install => 'y',
25
+ :q_puppetagent_certname => host,
26
+ :q_puppetagent_server => master,
27
+
28
+ # Disable database, console, and master by default
29
+ # This will be overridden by other blocks being merged in.
30
+ :q_puppetmaster_install => 'n',
31
+ :q_all_in_one_install => 'n',
32
+ :q_puppet_enterpriseconsole_install => 'n',
33
+ :q_puppetdb_install => 'n',
34
+ :q_database_install => 'n',
35
+ }
36
+
37
+ # These base answers are needed by all
38
+ common_a = {
39
+ :q_install => 'y',
40
+ :q_vendor_packages_install => 'y',
41
+ }
42
+
43
+ # master/database answers
44
+ master_database_a = {
45
+ :q_puppetmaster_certname => master
46
+ }
47
+
48
+ # Master/dashboard answers
49
+ master_console_a = {
50
+ :q_puppetdb_hostname => database,
51
+ :q_puppetdb_port => answer_for(options, :q_puppetdb_port, 8081)
52
+ }
53
+
54
+ # Master only answers
55
+ master_dns_altnames = [master.to_s, master['ip'], 'puppet'].compact.uniq.join(',')
56
+ master_a = {
57
+ :q_puppetmaster_install => 'y',
58
+ :q_puppetmaster_dnsaltnames => master_dns_altnames,
59
+ :q_puppetmaster_enterpriseconsole_hostname => dashboard,
60
+ :q_puppetmaster_enterpriseconsole_port => answer_for(options, :q_puppetmaster_enterpriseconsole_port, 443),
61
+ }
62
+
63
+ # Common answers for console and database
64
+ database_name = answer_for(options, :q_puppetdb_database_name, 'pe-puppetdb')
65
+ database_user = answer_for(options, :q_puppetdb_database_user, 'mYpdBu3r')
66
+ dashboard_password = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_password]}'"
67
+ puppetdb_password = "'#{options[:answers][:q_puppetdb_password]}'"
68
+ auth_database_name = answer_for(options, :q_puppet_enterpriseconsole_auth_database_name, 'console_auth')
69
+ auth_database_user = answer_for(options, :q_puppet_enterpriseconsole_auth_database_user, 'mYu7hu3r')
70
+ console_database_name = answer_for(options, :q_puppet_enterpriseconsole_database_name, 'console')
71
+ console_database_user = answer_for(options, :q_puppet_enterpriseconsole_database_user, 'mYc0nS03u3r')
72
+ database_port = answer_for(options, :q_database_port, 5432)
73
+
74
+ console_database_a = {
75
+ :q_puppetdb_database_name => database_name,
76
+ :q_puppetdb_database_user => database_user,
77
+ :q_puppetdb_database_password => puppetdb_password,
78
+ :q_puppet_enterpriseconsole_auth_database_name => auth_database_name,
79
+ :q_puppet_enterpriseconsole_auth_database_user => auth_database_user,
80
+ :q_puppet_enterpriseconsole_auth_database_password => dashboard_password,
81
+ :q_puppet_enterpriseconsole_database_name => console_database_name,
82
+ :q_puppet_enterpriseconsole_database_user => console_database_user,
83
+ :q_puppet_enterpriseconsole_database_password => dashboard_password,
84
+
85
+ :q_database_host => database,
86
+ :q_database_port => database_port,
87
+ }
88
+
89
+ # Console only answers
90
+ dashboard_user = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_user_email]}'"
91
+
92
+
93
+ smtp_host = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_host] || dashboard}'"
94
+ smtp_port = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_port]}'"
95
+ smtp_username = options[:answers][:q_puppet_enterpriseconsole_smtp_username]
96
+ smtp_password = options[:answers][:q_puppet_enterpriseconsole_smtp_password]
97
+ smtp_use_tls = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_use_tls]}'"
98
+ console_inventory_port = answer_for(options, :q_puppet_enterpriseconsole_inventory_port, 8140)
99
+ console_httpd_port = answer_for(options, :q_puppet_enterpriseconsole_httpd_port, 443)
100
+
101
+ console_a = {
102
+ :q_puppet_enterpriseconsole_install => 'y',
103
+ :q_puppet_enterpriseconsole_inventory_hostname => host,
104
+ :q_puppet_enterpriseconsole_inventory_certname => host,
105
+ :q_puppet_enterpriseconsole_inventory_dnsaltnames => dashboard,
106
+ :q_puppet_enterpriseconsole_inventory_port => console_inventory_port,
107
+ :q_puppet_enterpriseconsole_master_hostname => master,
108
+
109
+ :q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
110
+ :q_puppet_enterpriseconsole_auth_password => dashboard_password,
111
+
112
+ :q_puppet_enterpriseconsole_httpd_port => console_httpd_port,
113
+
114
+ :q_puppet_enterpriseconsole_smtp_host => smtp_host,
115
+ :q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
116
+ :q_puppet_enterpriseconsole_smtp_port => smtp_port,
117
+ }
118
+
119
+ if smtp_password and smtp_username
120
+ console_a.merge!({
121
+ :q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
122
+ :q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
123
+ :q_puppet_enterpriseconsole_smtp_user_auth => 'y'
124
+ })
125
+ end
67
126
 
68
- # Common answers for console and database
69
- dashboard_password = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_password]}'"
70
- puppetdb_password = "'#{options[:answers][:q_puppetdb_password]}'"
71
-
72
- console_database_a = {
73
- :q_puppetdb_database_name => 'pe-puppetdb',
74
- :q_puppetdb_database_user => 'mYpdBu3r',
75
- :q_puppetdb_database_password => puppetdb_password,
76
- :q_puppet_enterpriseconsole_auth_database_name => 'console_auth',
77
- :q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r',
78
- :q_puppet_enterpriseconsole_auth_database_password => dashboard_password,
79
- :q_puppet_enterpriseconsole_database_name => 'console',
80
- :q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r',
81
- :q_puppet_enterpriseconsole_database_password => dashboard_password,
82
-
83
- :q_database_host => database,
84
- :q_database_port => 5432
85
- }
86
-
87
- # Console only answers
88
- dashboard_user = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_user_email]}'"
89
-
90
-
91
- smtp_host = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_host] || dashboard}'"
92
- smtp_port = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_port]}'"
93
- smtp_username = options[:answers][:q_puppet_enterpriseconsole_smtp_username]
94
- smtp_password = options[:answers][:q_puppet_enterpriseconsole_smtp_password]
95
- smtp_use_tls = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_use_tls]}'"
96
-
97
- console_a = {
98
- :q_puppet_enterpriseconsole_install => 'y',
99
- :q_puppet_enterpriseconsole_inventory_hostname => host,
100
- :q_puppet_enterpriseconsole_inventory_certname => host,
101
- :q_puppet_enterpriseconsole_inventory_dnsaltnames => dashboard,
102
- :q_puppet_enterpriseconsole_inventory_port => 8140,
103
- :q_puppet_enterpriseconsole_master_hostname => master,
104
-
105
- :q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
106
- :q_puppet_enterpriseconsole_auth_password => dashboard_password,
107
-
108
- :q_puppet_enterpriseconsole_httpd_port => 443,
109
-
110
- :q_puppet_enterpriseconsole_smtp_host => smtp_host,
111
- :q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
112
- :q_puppet_enterpriseconsole_smtp_port => smtp_port,
113
- }
114
-
115
- if smtp_password and smtp_username
116
- console_a.merge!({
117
- :q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
118
- :q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
119
- :q_puppet_enterpriseconsole_smtp_user_auth => 'y'
120
- })
121
- end
127
+ # Database only answers
128
+ database_a = {
129
+ :q_puppetdb_install => 'y',
130
+ :q_database_install => 'y',
131
+ :q_database_root_password => "'#{answer_for(options, :q_database_root_password, '=ZYdjiP3jCwV5eo9s1MBd')}'",
132
+ :q_database_root_user => answer_for(options, :q_database_root_user, 'pe-postgres'),
133
+ }
122
134
 
123
- # Database only answers
124
- database_a = {
125
- :q_puppetdb_install => 'y',
126
- :q_database_install => 'y',
127
- :q_database_root_password => "'=ZYdjiP3jCwV5eo9s1MBd'",
128
- :q_database_root_user => 'pe-postgres',
129
- }
135
+ # Special answers for special hosts
136
+ aix_a = {
137
+ :q_run_updtvpkg => 'y',
138
+ }
130
139
 
131
- # Special answers for special hosts
132
- aix_a = {
133
- :q_run_updtvpkg => 'y',
134
- }
140
+ answers = common_a.dup
135
141
 
136
- answers = common_a.dup
142
+ unless options[:type] == :upgrade
143
+ answers.merge! agent_a
144
+ end
137
145
 
146
+ if host == master
147
+ answers.merge! master_console_a
138
148
  unless options[:type] == :upgrade
139
- answers.merge! agent_a
140
- end
141
-
142
- if host == master
143
- answers.merge! master_console_a
144
- unless options[:type] == :upgrade
145
- answers.merge! master_a
146
- answers.merge! master_database_a
147
- end
149
+ answers.merge! master_a
150
+ answers.merge! master_database_a
148
151
  end
152
+ end
149
153
 
150
- if host == dashboard
151
- answers.merge! master_console_a
152
- answers.merge! console_database_a
153
- answers[:q_pe_database] = 'y'
154
- unless options[:type] == :upgrade
155
- answers.merge! console_a
156
- else
157
- answers[:q_database_export_dir] = '/tmp'
158
- end
154
+ if host == dashboard
155
+ answers.merge! master_console_a
156
+ answers.merge! console_database_a
157
+ answers[:q_pe_database] = 'y'
158
+ unless options[:type] == :upgrade
159
+ answers.merge! console_a
160
+ else
161
+ answers[:q_database_export_dir] = answer_for(options, :q_database_export_dir, '/tmp')
159
162
  end
163
+ end
160
164
 
161
- if host == database
162
- if database != master
163
- if options[:type] == :upgrade
164
- # This is kinda annoying - if we're upgrading to 3.0 and are
165
- # puppetdb, we're actually doing a clean install. We thus
166
- # need the core agent answers.
167
- answers.merge! agent_a
168
- end
169
- answers.merge! master_database_a
165
+ if host == database
166
+ if database != master
167
+ if options[:type] == :upgrade
168
+ # This is kinda annoying - if we're upgrading to 3.0 and are
169
+ # puppetdb, we're actually doing a clean install. We thus
170
+ # need the core agent answers.
171
+ answers.merge! agent_a
170
172
  end
171
- answers.merge! database_a
172
- answers.merge! console_database_a
173
- end
174
-
175
- if host == master and host == database and host == dashboard
176
- answers[:q_all_in_one_install] = 'y'
173
+ answers.merge! master_database_a
177
174
  end
175
+ answers.merge! database_a
176
+ answers.merge! console_database_a
177
+ end
178
178
 
179
- if host['platform'].include? 'aix'
180
- answers.merge! aix_a
181
- end
179
+ if host == master and host == database and host == dashboard
180
+ answers[:q_all_in_one_install] = 'y'
181
+ end
182
182
 
183
- return answers
183
+ if host['platform'].include? 'aix'
184
+ answers.merge! aix_a
184
185
  end
185
186
 
186
- # Return answer data for all hosts.
187
- #
188
- # @param [Array<Beaker::Host>] hosts An array of host objects.
189
- # @param [String] master_certname Hostname of the puppet master.
190
- # @param [Hash] options options for answer files
191
- # @option options [Symbol] :type Should be one of :upgrade or :install.
192
- # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
193
- # data.
194
- def self.answers(hosts, master_certname, options)
195
- the_answers = {}
196
- database = only_host_with_role(hosts, 'database')
197
- dashboard = only_host_with_role(hosts, 'dashboard')
198
- master = only_host_with_role(hosts, 'master')
199
- hosts.each do |h|
200
- if options[:type] == :upgrade and h[:pe_ver] =~ /\A3.0/
201
- # 3.0.x to 3.0.x should require no answers
202
- the_answers[h.name] = {
203
- :q_install => 'y',
204
- :q_install_vendor_packages => 'y',
205
- }
206
- else
207
- the_answers[h.name] = host_answers(h, master_certname, master, database, dashboard, options)
208
- end
209
- h[:answers] = the_answers[h.name]
187
+ return answers
188
+ end
189
+
190
+ # Return answer data for all hosts.
191
+ #
192
+ # @return [Hash] A hash (keyed from hosts) containing hashes of answer file
193
+ # data.
194
+ def generate_answers
195
+ the_answers = {}
196
+ database = only_host_with_role(@hosts, 'database')
197
+ dashboard = only_host_with_role(@hosts, 'dashboard')
198
+ master = only_host_with_role(@hosts, 'master')
199
+ @hosts.each do |h|
200
+ if @options[:type] == :upgrade and h[:pe_ver] =~ /\A3.0/
201
+ # 3.0.x to 3.0.x should require no answers
202
+ the_answers[h.name] = {
203
+ :q_install => 'y',
204
+ :q_install_vendor_packages => 'y',
205
+ }
206
+ else
207
+ the_answers[h.name] = host_answers(h, master, database, dashboard, @options)
208
+ end
209
+ if h[:custom_answers]
210
+ the_answers[h.name] = the_answers[h.name].merge(h[:custom_answers])
210
211
  end
211
- return the_answers
212
+ h[:answers] = the_answers[h.name]
212
213
  end
214
+ return the_answers
213
215
  end
214
216
  end
215
217
  end