Class: Beaker::Answers
- Inherits:
-
Object
- Object
- Beaker::Answers
- Defined in:
- lib/beaker/answers.rb
Overview
This class provides methods for generating PE answer file information.
Constant Summary collapse
- DEFAULT_ANSWERS =
Beaker::Options::OptionsHash.new.merge({ :q_puppet_enterpriseconsole_auth_user_email => '[email protected]', :q_puppet_enterpriseconsole_auth_password => '~!@#$%^*-/ aZ', :q_puppet_enterpriseconsole_smtp_port => 25, :q_puppet_enterpriseconsole_smtp_use_tls => 'n', :q_verify_packages => 'y', :q_puppetdb_password => '~!@#$%^*-/ aZ', :q_puppetmaster_enterpriseconsole_port => 443, :q_puppet_enterpriseconsole_auth_database_name => 'console_auth', :q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r', :q_puppet_enterpriseconsole_database_name => 'console', :q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r', :q_database_root_password => '=ZYdjiP3jCwV5eo9s1MBd', :q_database_root_user => 'pe-postgres', :q_database_export_dir => '/tmp', :q_puppetdb_database_name => 'pe-puppetdb', :q_puppetdb_database_user => 'mYpdBu3r', :q_database_port => 5432, :q_puppetdb_port => 8081, :q_classifier_database_user => 'DFGhjlkj', :q_database_name => 'pe-classifier', :q_classifier_database_password => '~!@#$%^*-/ aZ', :q_activity_database_user => 'adsfglkj', :q_activity_database_name => 'pe-activity', :q_activity_database_password => '~!@#$%^*-/ aZ', :q_rbac_database_user => 'RbhNBklm', :q_rbac_database_name => 'pe-rbac', :q_rbac_database_password => '~!@#$%^*-/ aZ', :q_install_update_server => 'y', :q_exit_for_nc_migrate => 'n', :q_enable_future_parser => 'n', :q_pe_check_for_updates => 'n', })
Class Method Summary collapse
-
.create(version, hosts, options) ⇒ Hash
When given a Puppet Enterprise version, a list of hosts and other qualifying data this method will return the appropriate object that can be used to generate answer file data.
Instance Method Summary collapse
-
#answer_for(options, q, default = nil) ⇒ String
The answer value for a provided question.
-
#answer_string(host) ⇒ String
This converts a data hash provided by answers, and returns a Puppet Enterprise compatible answer file ready for use.
-
#answers ⇒ Hash
Access the answers hash for this version, host and option information.
-
#generate_answers ⇒ Object
Generate the answers hash based upon version, host and option information.
-
#initialize(version, hosts, options) ⇒ Hash
constructor
When given a Puppet Enterprise version, a list of hosts and other qualifying data this method will return a hash (keyed from the hosts) of default Puppet Enterprise answer file data hashes.
Constructor Details
#initialize(version, hosts, options) ⇒ Hash
When given a Puppet Enterprise version, a list of hosts and other qualifying data this method will return a hash (keyed from the hosts) of default Puppet Enterprise answer file data hashes.
105 106 107 108 109 |
# File 'lib/beaker/answers.rb', line 105 def initialize(version, hosts, ) @version = version @hosts = hosts @options = end |
Class Method Details
.create(version, hosts, options) ⇒ Hash
When given a Puppet Enterprise version, a list of hosts and other qualifying data this method will return the appropriate object that can be used to generate answer file data.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/beaker/answers.rb', line 50 def self.create version, hosts, case version when /\A4\.0/ return Version40.new(version, hosts, ) when /\A3\.99/ return Version40.new(version, hosts, ) when /\A3\.8/ return Version38.new(version, hosts, ) when /\A3\.7/ return Version34.new(version, hosts, ) when /\A3\.4/ return Version34.new(version, hosts, ) when /\A3\.[2-3]/ return Version32.new(version, hosts, ) when /\A3\.1/ return Version30.new(version, hosts, ) when /\A3\.0/ return Version30.new(version, hosts, ) when /\A2\.8/ return Version28.new(version, hosts, ) when /\A2\.0/ return Version20.new(version, hosts, ) else raise NotImplementedError, "Don't know how to generate answers for #{version}" end end |
Instance Method Details
#answer_for(options, q, default = nil) ⇒ String
The answer value for a provided question. Use the user answer when available, otherwise return the default
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/beaker/answers.rb', line 82 def answer_for(, q, default = nil) answer = DEFAULT_ANSWERS[q] # check to see if there is a value for this in the provided options if [:answers] && [:answers][q] answer = [:answers][q] end # use the default if we don't have anything if not answer answer = default end answer end |
#answer_string(host) ⇒ String
This converts a data hash provided by answers, and returns a Puppet Enterprise compatible answer file ready for use.
end
134 135 136 |
# File 'lib/beaker/answers.rb', line 134 def answer_string(host) answers[host.name].map { |k,v| "#{k}=#{v}" }.join("\n") end |
#answers ⇒ Hash
Access the answers hash for this version, host and option information. If the answers have not yet been calculated, generate them.
119 120 121 |
# File 'lib/beaker/answers.rb', line 119 def answers @answers ||= generate_answers end |
#generate_answers ⇒ Object
Generate the answers hash based upon version, host and option information
112 113 114 |
# File 'lib/beaker/answers.rb', line 112 def generate_answers raise "This should be handled by subclasses!" end |