beaker 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 +17 -0
- data/.rspec +2 -0
- data/.simplecov +14 -0
- data/DOCUMENTING.md +167 -0
- data/Gemfile +3 -0
- data/LICENSE +17 -0
- data/README.md +332 -0
- data/Rakefile +121 -0
- data/beaker.gemspec +42 -0
- data/beaker.rb +10 -0
- data/bin/beaker +9 -0
- data/lib/beaker.rb +36 -0
- data/lib/beaker/answers.rb +29 -0
- data/lib/beaker/answers/version28.rb +104 -0
- data/lib/beaker/answers/version30.rb +194 -0
- data/lib/beaker/cli.rb +113 -0
- data/lib/beaker/command.rb +241 -0
- data/lib/beaker/command_factory.rb +21 -0
- data/lib/beaker/dsl.rb +85 -0
- data/lib/beaker/dsl/assertions.rb +87 -0
- data/lib/beaker/dsl/helpers.rb +625 -0
- data/lib/beaker/dsl/install_utils.rb +299 -0
- data/lib/beaker/dsl/outcomes.rb +99 -0
- data/lib/beaker/dsl/roles.rb +97 -0
- data/lib/beaker/dsl/structure.rb +63 -0
- data/lib/beaker/dsl/wrappers.rb +100 -0
- data/lib/beaker/host.rb +193 -0
- data/lib/beaker/host/aix.rb +15 -0
- data/lib/beaker/host/aix/file.rb +16 -0
- data/lib/beaker/host/aix/group.rb +35 -0
- data/lib/beaker/host/aix/user.rb +32 -0
- data/lib/beaker/host/unix.rb +54 -0
- data/lib/beaker/host/unix/exec.rb +15 -0
- data/lib/beaker/host/unix/file.rb +16 -0
- data/lib/beaker/host/unix/group.rb +40 -0
- data/lib/beaker/host/unix/pkg.rb +22 -0
- data/lib/beaker/host/unix/user.rb +32 -0
- data/lib/beaker/host/windows.rb +44 -0
- data/lib/beaker/host/windows/exec.rb +18 -0
- data/lib/beaker/host/windows/file.rb +15 -0
- data/lib/beaker/host/windows/group.rb +36 -0
- data/lib/beaker/host/windows/pkg.rb +26 -0
- data/lib/beaker/host/windows/user.rb +32 -0
- data/lib/beaker/hypervisor.rb +37 -0
- data/lib/beaker/hypervisor/aixer.rb +52 -0
- data/lib/beaker/hypervisor/blimper.rb +123 -0
- data/lib/beaker/hypervisor/fusion.rb +56 -0
- data/lib/beaker/hypervisor/solaris.rb +65 -0
- data/lib/beaker/hypervisor/vagrant.rb +118 -0
- data/lib/beaker/hypervisor/vcloud.rb +175 -0
- data/lib/beaker/hypervisor/vsphere.rb +80 -0
- data/lib/beaker/hypervisor/vsphere_helper.rb +200 -0
- data/lib/beaker/logger.rb +167 -0
- data/lib/beaker/network_manager.rb +73 -0
- data/lib/beaker/options_parsing.rb +323 -0
- data/lib/beaker/result.rb +55 -0
- data/lib/beaker/shared.rb +15 -0
- data/lib/beaker/shared/error_handler.rb +17 -0
- data/lib/beaker/shared/host_handler.rb +46 -0
- data/lib/beaker/shared/repetition.rb +28 -0
- data/lib/beaker/ssh_connection.rb +198 -0
- data/lib/beaker/test_case.rb +225 -0
- data/lib/beaker/test_config.rb +148 -0
- data/lib/beaker/test_suite.rb +288 -0
- data/lib/beaker/utils.rb +7 -0
- data/lib/beaker/utils/ntp_control.rb +42 -0
- data/lib/beaker/utils/repo_control.rb +92 -0
- data/lib/beaker/utils/setup_helper.rb +77 -0
- data/lib/beaker/utils/validator.rb +27 -0
- data/spec/beaker/command_spec.rb +94 -0
- data/spec/beaker/dsl/assertions_spec.rb +104 -0
- data/spec/beaker/dsl/helpers_spec.rb +230 -0
- data/spec/beaker/dsl/install_utils_spec.rb +70 -0
- data/spec/beaker/dsl/outcomes_spec.rb +43 -0
- data/spec/beaker/dsl/roles_spec.rb +86 -0
- data/spec/beaker/dsl/structure_spec.rb +60 -0
- data/spec/beaker/dsl/wrappers_spec.rb +52 -0
- data/spec/beaker/host_spec.rb +95 -0
- data/spec/beaker/logger_spec.rb +117 -0
- data/spec/beaker/options_parsing_spec.rb +37 -0
- data/spec/beaker/puppet_command_spec.rb +128 -0
- data/spec/beaker/ssh_connection_spec.rb +39 -0
- data/spec/beaker/test_case_spec.rb +6 -0
- data/spec/beaker/test_suite_spec.rb +44 -0
- data/spec/mocks_and_helpers.rb +34 -0
- data/spec/spec_helper.rb +15 -0
- metadata +359 -0
data/Rakefile
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
|
2
|
+
task :default => [ 'test:spec' ]
|
3
|
+
|
4
|
+
task :spec do
|
5
|
+
Rake::Task['test:spec'].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :test do
|
9
|
+
desc 'Run specs (with coverage on 1.9), alias `spec` & the default'
|
10
|
+
task :spec do
|
11
|
+
original_dir = Dir.pwd
|
12
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
13
|
+
sh 'export COVERAGE=true; bundle exec rspec'
|
14
|
+
Dir.chdir( original_dir )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
###########################################################
|
20
|
+
#
|
21
|
+
# Documentation Tasks
|
22
|
+
#
|
23
|
+
###########################################################
|
24
|
+
|
25
|
+
|
26
|
+
DOCS_DAEMON = "yard server --reload --daemon --server thin"
|
27
|
+
FOREGROUND_SERVER = 'bundle exec yard server --reload --verbose --server thin lib/beaker'
|
28
|
+
|
29
|
+
def running?( cmdline )
|
30
|
+
ps = `ps -ef`
|
31
|
+
found = ps.lines.grep( /#{Regexp.quote( cmdline )}/ )
|
32
|
+
if found.length > 1
|
33
|
+
raise StandardError, "Found multiple YARD Servers. Don't know what to do."
|
34
|
+
end
|
35
|
+
|
36
|
+
yes = found.empty? ? false : true
|
37
|
+
return yes, found.first
|
38
|
+
end
|
39
|
+
|
40
|
+
def pid_from( output )
|
41
|
+
output.squeeze(' ').strip.split(' ')[1]
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Start the documentation server in the foreground'
|
45
|
+
task :docs => 'docs:clear' do
|
46
|
+
original_dir = Dir.pwd
|
47
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
48
|
+
sh FOREGROUND_SERVER
|
49
|
+
Dir.chdir( original_dir )
|
50
|
+
end
|
51
|
+
|
52
|
+
namespace :docs do
|
53
|
+
|
54
|
+
desc 'Clear the generated documentation cache'
|
55
|
+
task :clear do
|
56
|
+
original_dir = Dir.pwd
|
57
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
58
|
+
sh 'rm -rf docs'
|
59
|
+
Dir.chdir( original_dir )
|
60
|
+
end
|
61
|
+
|
62
|
+
desc 'Generate static documentation'
|
63
|
+
task :gen => 'docs:clear' do
|
64
|
+
original_dir = Dir.pwd
|
65
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
66
|
+
sh 'bundle exec yard doc'
|
67
|
+
Dir.chdir( original_dir )
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'Run the documentation server in the background, alias `bg`'
|
71
|
+
task :background => 'docs:clear' do
|
72
|
+
yes, output = running?( DOCS_DAEMON )
|
73
|
+
if yes
|
74
|
+
puts "Not starting a new YARD Server..."
|
75
|
+
puts "Found one running with pid #{pid_from( output )}."
|
76
|
+
else
|
77
|
+
original_dir = Dir.pwd
|
78
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
79
|
+
sh "bundle exec #{DOCS_DAEMON}"
|
80
|
+
Dir.chdir( original_dir )
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
task(:bg) { Rake::Task['docs:background'].invoke }
|
85
|
+
|
86
|
+
desc 'Check the status of the documentation server'
|
87
|
+
task :status do
|
88
|
+
yes, output = running?( DOCS_DAEMON )
|
89
|
+
if yes
|
90
|
+
pid = pid_from( output )
|
91
|
+
puts "Found a YARD Server running with pid #{pid}"
|
92
|
+
else
|
93
|
+
puts "Could not find a running YARD Server."
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Stop a running YARD Server"
|
98
|
+
task :stop do
|
99
|
+
yes, output = running?( DOCS_DAEMON )
|
100
|
+
if yes
|
101
|
+
pid = pid_from( output )
|
102
|
+
puts "Found a YARD Server running with pid #{pid}"
|
103
|
+
`kill #{pid}`
|
104
|
+
puts "Stopping..."
|
105
|
+
yes, output = running?( DOCS_DAEMON )
|
106
|
+
if yes
|
107
|
+
`kill -9 #{pid}`
|
108
|
+
yes, output = running?( DOCS_DAEMON )
|
109
|
+
if yes
|
110
|
+
puts "Could not Stop Server!"
|
111
|
+
else
|
112
|
+
puts "Server stopped."
|
113
|
+
end
|
114
|
+
else
|
115
|
+
puts "Server stopped."
|
116
|
+
end
|
117
|
+
else
|
118
|
+
puts "Could not find a running YARD Server"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/beaker.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'rbconfig'
|
4
|
+
ruby_conf = defined?(RbConfig) ? RbConfig::CONFIG : Config::CONFIG
|
5
|
+
less_than_one_nine = ruby_conf['MAJOR'].to_i == 1 && ruby_conf['MINOR'].to_i < 9
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "beaker"
|
9
|
+
s.version = '0.0.0'
|
10
|
+
s.authors = ["Puppetlabs"]
|
11
|
+
s.email = ["delivery@puppetlabs.com"]
|
12
|
+
s.homepage = "https://github.com/puppetlabs/beaker"
|
13
|
+
s.summary = %q{Let's test Puppet!}
|
14
|
+
s.description = %q{Puppetlabs accceptance testing harness}
|
15
|
+
s.license = 'Apache2'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
# Testing dependencies
|
23
|
+
s.add_development_dependency 'rspec', '2.11.0'
|
24
|
+
s.add_development_dependency 'fakefs', '0.4'
|
25
|
+
s.add_development_dependency 'rake'
|
26
|
+
s.add_development_dependency 'simplecov' unless less_than_one_nine
|
27
|
+
|
28
|
+
# Documentation dependencies
|
29
|
+
s.add_development_dependency 'yard'
|
30
|
+
s.add_development_dependency 'markdown' unless less_than_one_nine
|
31
|
+
s.add_development_dependency 'thin'
|
32
|
+
|
33
|
+
# Run time dependencies
|
34
|
+
s.add_runtime_dependency 'json'
|
35
|
+
s.add_runtime_dependency 'net-ssh'
|
36
|
+
s.add_runtime_dependency 'net-scp'
|
37
|
+
s.add_runtime_dependency 'rbvmomi'
|
38
|
+
s.add_runtime_dependency 'blimpy'
|
39
|
+
s.add_runtime_dependency 'nokogiri', '1.5.10'
|
40
|
+
s.add_runtime_dependency 'fission' if RUBY_PLATFORM =~ /darwin/i
|
41
|
+
s.add_runtime_dependency 'inifile'
|
42
|
+
end
|
data/beaker.rb
ADDED
data/bin/beaker
ADDED
data/lib/beaker.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems' unless defined?(Gem)
|
2
|
+
module Beaker
|
3
|
+
|
4
|
+
%w( utils test_suite test_config result command options_parsing network_manager cli ).each do |lib|
|
5
|
+
begin
|
6
|
+
require "beaker/#{lib}"
|
7
|
+
rescue LoadError
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'beaker', lib))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
# These really are our sub-systems that live within the harness today
|
12
|
+
# Ideally I would like to see them split out into modules that can be
|
13
|
+
# included as such here
|
14
|
+
#
|
15
|
+
# The Testing DSL
|
16
|
+
require 'beaker/dsl'
|
17
|
+
#
|
18
|
+
# Our Host Abstraction Layer
|
19
|
+
require 'beaker/host'
|
20
|
+
#
|
21
|
+
# Our Hypervisor Abstraction Layer
|
22
|
+
require 'beaker/hypervisor'
|
23
|
+
#
|
24
|
+
# How we manage connecting to hosts and hypervisors
|
25
|
+
#require 'beaker/connectivity'
|
26
|
+
#
|
27
|
+
# Our test runner, suite, test cases and steps
|
28
|
+
#require 'beaker/runner'
|
29
|
+
#
|
30
|
+
# Common setup and testing steps
|
31
|
+
#require 'beaker/steps'
|
32
|
+
#
|
33
|
+
# Shared methods and helpers
|
34
|
+
require 'beaker/shared'
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
[ 'version30', 'version28' ].each do |file|
|
2
|
+
begin
|
3
|
+
require "beaker/answers/#{file}"
|
4
|
+
rescue LoadError
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'answers', file))
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module Beaker
|
10
|
+
module Answers
|
11
|
+
|
12
|
+
def self.answers(version, hosts, master_certname, options)
|
13
|
+
|
14
|
+
case version
|
15
|
+
when /\A3\.0/
|
16
|
+
Version30.answers(hosts, master_certname, options)
|
17
|
+
when /\A2\.8/
|
18
|
+
Version28.answers(hosts, master_certname, options)
|
19
|
+
else
|
20
|
+
raise NotImplementedError, "Don't know how to generate answers for #{version}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.answer_string(host, answers)
|
25
|
+
answers[host.name].map { |k,v| "#{k}=#{v}" }.join("\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Beaker
|
2
|
+
module Answers
|
3
|
+
module Version28
|
4
|
+
|
5
|
+
def self.host_answers(host, master_certname, master, dashboard, options)
|
6
|
+
return nil if host['platform'] =~ /windows/
|
7
|
+
|
8
|
+
agent_a = {
|
9
|
+
:q_install => 'y',
|
10
|
+
:q_puppetagent_install => 'y',
|
11
|
+
:q_puppet_cloud_install => 'y',
|
12
|
+
:q_puppet_symlinks_install => 'y',
|
13
|
+
:q_vendor_packages_install => 'y',
|
14
|
+
:q_puppetagent_certname => host,
|
15
|
+
:q_puppetagent_server => master,
|
16
|
+
|
17
|
+
# Disable console and master by default
|
18
|
+
# This will be overridden by other blocks being merged in
|
19
|
+
:q_puppetmaster_install => 'n',
|
20
|
+
:q_puppet_enterpriseconsole_install => 'n',
|
21
|
+
}
|
22
|
+
|
23
|
+
master_a = {
|
24
|
+
:q_puppetmaster_install => 'y',
|
25
|
+
:q_puppetmaster_certname => master_certname,
|
26
|
+
:q_puppetmaster_install => 'y',
|
27
|
+
:q_puppetmaster_dnsaltnames => master_certname+",puppet",
|
28
|
+
:q_puppetmaster_enterpriseconsole_hostname => dashboard,
|
29
|
+
:q_puppetmaster_enterpriseconsole_port => 443,
|
30
|
+
:q_puppetmaster_forward_facts => 'y',
|
31
|
+
}
|
32
|
+
|
33
|
+
if master['ip']
|
34
|
+
master_a[:q_puppetmaster_dnsaltnames]+=","+master['ip']
|
35
|
+
end
|
36
|
+
|
37
|
+
dashboard_user = "'#{ENV['q_puppet_enterpriseconsole_auth_user_email'] || 'admin@example.com'}'"
|
38
|
+
smtp_host = "'#{ENV['q_puppet_enterpriseconsole_smtp_host'] || dashboard}'"
|
39
|
+
dashboard_password = ENV['q_puppet_enterpriseconsole_auth_password'] || '~!@#$%^*-/ aZ'
|
40
|
+
smtp_port = "'#{ENV['q_puppet_enterpriseconsole_smtp_port'] || 25}'"
|
41
|
+
smtp_username = ENV['q_puppet_enterpriseconsole_smtp_username']
|
42
|
+
smtp_password = ENV['q_puppet_enterpriseconsole_smtp_password']
|
43
|
+
smtp_use_tls = "'#{ENV['q_puppet_enterpriseconsole_smtp_use_tls'] || 'n'}'"
|
44
|
+
|
45
|
+
console_a = {
|
46
|
+
:q_puppet_enterpriseconsole_install => 'y',
|
47
|
+
:q_puppet_enterpriseconsole_database_install => 'y',
|
48
|
+
:q_puppet_enterpriseconsole_auth_database_name => 'console_auth',
|
49
|
+
:q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r',
|
50
|
+
:q_puppet_enterpriseconsole_auth_database_password => "'#{dashboard_password}'",
|
51
|
+
:q_puppet_enterpriseconsole_database_name => 'console',
|
52
|
+
:q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r',
|
53
|
+
:q_puppet_enterpriseconsole_database_password => "'#{dashboard_password}'",
|
54
|
+
:q_puppet_enterpriseconsole_inventory_hostname => host,
|
55
|
+
:q_puppet_enterpriseconsole_inventory_certname => host,
|
56
|
+
:q_puppet_enterpriseconsole_inventory_dnsaltnames => master,
|
57
|
+
:q_puppet_enterpriseconsole_inventory_port => 8140,
|
58
|
+
:q_puppet_enterpriseconsole_master_hostname => master,
|
59
|
+
|
60
|
+
:q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
|
61
|
+
:q_puppet_enterpriseconsole_auth_password => "'#{dashboard_password}'",
|
62
|
+
|
63
|
+
:q_puppet_enterpriseconsole_httpd_port => 443,
|
64
|
+
|
65
|
+
:q_puppet_enterpriseconsole_smtp_host => smtp_host,
|
66
|
+
:q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
|
67
|
+
:q_puppet_enterpriseconsole_smtp_port => smtp_port,
|
68
|
+
}
|
69
|
+
|
70
|
+
console_a[:q_puppet_enterpriseconsole_auth_user] = console_a[:q_puppet_enterpriseconsole_auth_user_email]
|
71
|
+
|
72
|
+
if smtp_password and smtp_username
|
73
|
+
console_a.merge!({
|
74
|
+
:q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
|
75
|
+
:q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
|
76
|
+
:q_puppet_enterpriseconsole_smtp_user_auth => 'y'
|
77
|
+
})
|
78
|
+
end
|
79
|
+
|
80
|
+
answers = agent_a.dup
|
81
|
+
if host == master
|
82
|
+
answers.merge! master_a
|
83
|
+
end
|
84
|
+
|
85
|
+
if host == dashboard
|
86
|
+
answers.merge! console_a
|
87
|
+
end
|
88
|
+
|
89
|
+
return answers
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.answers(hosts, master_certname, options)
|
93
|
+
the_answers = {}
|
94
|
+
dashboard = only_host_with_role(hosts, 'dashboard')
|
95
|
+
master = only_host_with_role(hosts, 'master')
|
96
|
+
hosts.each do |h|
|
97
|
+
the_answers[h.name] = host_answers(h, master_certname, master, dashboard, options)
|
98
|
+
end
|
99
|
+
return the_answers
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module Beaker
|
2
|
+
module Answers
|
3
|
+
module Version30
|
4
|
+
|
5
|
+
def self.host_answers(host, master_certname, master, database, dashboard, options)
|
6
|
+
# Windows hosts don't have normal answers...
|
7
|
+
return nil if host['platform'] =~ /windows/
|
8
|
+
|
9
|
+
# Everything's an agent
|
10
|
+
agent_a = {
|
11
|
+
:q_puppetagent_install => 'y',
|
12
|
+
:q_puppet_cloud_install => 'y',
|
13
|
+
:q_verify_packages => ENV['q_verify_packages'] || 'y',
|
14
|
+
:q_puppet_symlinks_install => 'y',
|
15
|
+
:q_puppetagent_certname => host,
|
16
|
+
:q_puppetagent_server => master,
|
17
|
+
|
18
|
+
# Disable database, console, and master by default
|
19
|
+
# This will be overridden by other blocks being merged in.
|
20
|
+
:q_puppetmaster_install => 'n',
|
21
|
+
:q_all_in_one_install => 'n',
|
22
|
+
:q_puppet_enterpriseconsole_install => 'n',
|
23
|
+
:q_puppetdb_install => 'n',
|
24
|
+
:q_database_install => 'n',
|
25
|
+
}
|
26
|
+
|
27
|
+
# These base answers are needed by all
|
28
|
+
common_a = {
|
29
|
+
:q_install => 'y',
|
30
|
+
:q_vendor_packages_install => 'y',
|
31
|
+
}
|
32
|
+
|
33
|
+
# master/database answers
|
34
|
+
master_database_a = {
|
35
|
+
:q_puppetmaster_certname => master_certname
|
36
|
+
}
|
37
|
+
|
38
|
+
# Master/dashboard answers
|
39
|
+
master_console_a = {
|
40
|
+
:q_puppetdb_hostname => database,
|
41
|
+
:q_puppetdb_port => 8081
|
42
|
+
}
|
43
|
+
|
44
|
+
# Master only answers
|
45
|
+
master_a = {
|
46
|
+
:q_puppetmaster_install => 'y',
|
47
|
+
:q_puppetmaster_dnsaltnames => master_certname+",puppet",
|
48
|
+
:q_puppetmaster_enterpriseconsole_hostname => dashboard,
|
49
|
+
:q_puppetmaster_enterpriseconsole_port => 443,
|
50
|
+
}
|
51
|
+
|
52
|
+
if master['ip']
|
53
|
+
master_a[:q_puppetmaster_dnsaltnames]+=","+master['ip']
|
54
|
+
end
|
55
|
+
|
56
|
+
# Common answers for console and database
|
57
|
+
dashboard_password = "'#{ENV['q_puppet_enterpriseconsole_auth_password'] || '~!@#$%^*-/ aZ'}'"
|
58
|
+
puppetdb_password = "'#{ENV['q_puppetdb_password'] || '~!@#$%^*-/ aZ'}'"
|
59
|
+
|
60
|
+
console_database_a = {
|
61
|
+
:q_puppetdb_database_name => 'pe-puppetdb',
|
62
|
+
:q_puppetdb_database_user => 'mYpdBu3r',
|
63
|
+
:q_puppetdb_database_password => puppetdb_password,
|
64
|
+
:q_puppet_enterpriseconsole_auth_database_name => 'console_auth',
|
65
|
+
:q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r',
|
66
|
+
:q_puppet_enterpriseconsole_auth_database_password => dashboard_password,
|
67
|
+
:q_puppet_enterpriseconsole_database_name => 'console',
|
68
|
+
:q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r',
|
69
|
+
:q_puppet_enterpriseconsole_database_password => dashboard_password,
|
70
|
+
|
71
|
+
:q_database_host => database,
|
72
|
+
:q_database_port => 5432
|
73
|
+
}
|
74
|
+
|
75
|
+
# Console only answers
|
76
|
+
dashboard_user = "'#{ENV['q_puppet_enterpriseconsole_auth_user_email'] || 'admin@example.com'}'"
|
77
|
+
|
78
|
+
smtp_host = "'#{ENV['q_puppet_enterpriseconsole_smtp_host'] || dashboard}'"
|
79
|
+
smtp_port = "'#{ENV['q_puppet_enterpriseconsole_smtp_port'] || 25}'"
|
80
|
+
smtp_username = ENV['q_puppet_enterpriseconsole_smtp_username']
|
81
|
+
smtp_password = ENV['q_puppet_enterpriseconsole_smtp_password']
|
82
|
+
smtp_use_tls = "'#{ENV['q_puppet_enterpriseconsole_smtp_use_tls'] || 'n'}'"
|
83
|
+
|
84
|
+
console_a = {
|
85
|
+
:q_puppet_enterpriseconsole_install => 'y',
|
86
|
+
:q_puppet_enterpriseconsole_inventory_hostname => host,
|
87
|
+
:q_puppet_enterpriseconsole_inventory_certname => host,
|
88
|
+
:q_puppet_enterpriseconsole_inventory_dnsaltnames => dashboard,
|
89
|
+
:q_puppet_enterpriseconsole_inventory_port => 8140,
|
90
|
+
:q_puppet_enterpriseconsole_master_hostname => master,
|
91
|
+
|
92
|
+
:q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
|
93
|
+
:q_puppet_enterpriseconsole_auth_password => dashboard_password,
|
94
|
+
|
95
|
+
:q_puppet_enterpriseconsole_httpd_port => 443,
|
96
|
+
|
97
|
+
:q_puppet_enterpriseconsole_smtp_host => smtp_host,
|
98
|
+
:q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
|
99
|
+
:q_puppet_enterpriseconsole_smtp_port => smtp_port,
|
100
|
+
}
|
101
|
+
|
102
|
+
if smtp_password and smtp_username
|
103
|
+
console_a.merge!({
|
104
|
+
:q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
|
105
|
+
:q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
|
106
|
+
:q_puppet_enterpriseconsole_smtp_user_auth => 'y'
|
107
|
+
})
|
108
|
+
end
|
109
|
+
|
110
|
+
# Database only answers
|
111
|
+
database_a = {
|
112
|
+
:q_puppetdb_install => 'y',
|
113
|
+
:q_database_install => 'y',
|
114
|
+
:q_database_root_password => "'=ZYdjiP3jCwV5eo9s1MBd'",
|
115
|
+
:q_database_root_user => 'pe-postgres',
|
116
|
+
}
|
117
|
+
|
118
|
+
# Special answers for special hosts
|
119
|
+
aix_a = {
|
120
|
+
:q_run_updtvpkg => 'y',
|
121
|
+
}
|
122
|
+
|
123
|
+
answers = common_a.dup
|
124
|
+
|
125
|
+
unless options[:type] == :upgrade
|
126
|
+
answers.merge! agent_a
|
127
|
+
end
|
128
|
+
|
129
|
+
if host == master
|
130
|
+
answers.merge! master_console_a
|
131
|
+
unless options[:type] == :upgrade
|
132
|
+
answers.merge! master_a
|
133
|
+
answers.merge! master_database_a
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
if host == dashboard
|
138
|
+
answers.merge! master_console_a
|
139
|
+
answers.merge! console_database_a
|
140
|
+
answers[:q_pe_database] = 'y'
|
141
|
+
unless options[:type] == :upgrade
|
142
|
+
answers.merge! console_a
|
143
|
+
else
|
144
|
+
answers[:q_database_export_dir] = '/tmp'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if host == database
|
149
|
+
if database != master
|
150
|
+
if options[:type] == :upgrade
|
151
|
+
# This is kinda annoying - if we're upgrading to 3.0 and are
|
152
|
+
# puppetdb, we're actually doing a clean install. We thus
|
153
|
+
# need the core agent answers.
|
154
|
+
answers.merge! agent_a
|
155
|
+
end
|
156
|
+
answers.merge! master_database_a
|
157
|
+
end
|
158
|
+
answers.merge! database_a
|
159
|
+
answers.merge! console_database_a
|
160
|
+
end
|
161
|
+
|
162
|
+
if host == master and host == database and host == dashboard
|
163
|
+
answers[:q_all_in_one_install] = 'y'
|
164
|
+
end
|
165
|
+
|
166
|
+
if host['platform'].include? 'aix'
|
167
|
+
answers.merge! aix_a
|
168
|
+
end
|
169
|
+
|
170
|
+
return answers
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.answers(hosts, master_certname, options)
|
174
|
+
the_answers = {}
|
175
|
+
database = only_host_with_role(hosts, 'database')
|
176
|
+
dashboard = only_host_with_role(hosts, 'dashboard')
|
177
|
+
master = only_host_with_role(hosts, 'master')
|
178
|
+
hosts.each do |h|
|
179
|
+
if options[:type] == :upgrade and options[:from] =~ /\A3.0/
|
180
|
+
# 3.0.x to 3.0.x should require no answers
|
181
|
+
the_answers[h.name] = {
|
182
|
+
:q_install => 'y',
|
183
|
+
:q_install_vendor_packages => 'y',
|
184
|
+
}
|
185
|
+
else
|
186
|
+
the_answers[h.name] = host_answers(h, master_certname, master, database, dashboard, options)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
return the_answers
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|