Module: Beaker::Answers

Defined in:
lib/beaker/answers.rb,
lib/beaker/answers/version20.rb,
lib/beaker/answers/version28.rb,
lib/beaker/answers/version30.rb,
lib/beaker/answers/version32.rb

Overview

This module provides static methods for accessing PE answer file information.

Defined Under Namespace

Modules: Version20, Version28, Version30, Version32

Class Method Summary collapse

Class Method Details

.answer_string(host, answers) ⇒ String

This converts a data hash provided by answers, and returns a Puppet Enterprise compatible answer file ready for use.

end

Examples:

Generating an answer file for a series of hosts

hosts.each do |host|
  answers = Beaker::Answers.answers("2.0", hosts, "master")
  create_remote_file host, "/mypath/answer", Beaker::Answers.answer_string(host, answers)

Parameters:

  • host (Beaker::Host)

    Host object in question to generate the answer file for.

  • answers (Hash)

    Answers hash as returned by #answers

Returns:

  • (String)

    a string of answers



55
56
57
# File 'lib/beaker/answers.rb', line 55

def self.answer_string(host, answers)
  answers[host.name].map { |k,v| "#{k}=#{v}" }.join("\n")
end

.answers(version, hosts, master_certname, 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.

Parameters:

  • version (String)

    Puppet Enterprise version to generate answer data for

  • hosts (Array<Beaker::Host>)

    An array of host objects.

  • master_certname (String)

    Hostname of the puppet master.

  • options (Hash)

    options for answer files

Options Hash (options):

  • :type (Symbol)

    Should be one of :upgrade or :install.

Returns:

  • (Hash)

    A hash (keyed from hosts) containing hashes of answer file data.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/beaker/answers.rb', line 25

def self.answers(version, hosts, master_certname, options)

  case version
  when /\A3\.2/
    Version32.answers(hosts, master_certname, options)
  when /\A3\.1/
    Version30.answers(hosts, master_certname, options)
  when /\A3\.0/
    Version30.answers(hosts, master_certname, options)
  when /\A2\.8/
    Version28.answers(hosts, master_certname, options)
  when /\A2\.0/
    Version20.answers(hosts, master_certname, options)
  else
    raise NotImplementedError, "Don't know how to generate answers for #{version}"
  end
end