Module: Beaker::Answers::Version28 Private

Defined in:
lib/beaker/answers/version28.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This class provides answer file information for PE version 2.8

Class Method Summary collapse

Class Method Details

.answers(hosts, master_certname, options) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return answer data for all hosts.

Parameters:

  • 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.



113
114
115
116
117
118
119
120
121
# File 'lib/beaker/answers/version28.rb', line 113

def self.answers(hosts, master_certname, options)
  the_answers = {}
  dashboard = only_host_with_role(hosts, 'dashboard')
  master = only_host_with_role(hosts, 'master')
  hosts.each do |h|
      the_answers[h.name] = host_answers(h, master_certname, master, dashboard, options)
  end
  return the_answers
end

.host_answers(host, master_certname, master, dashboard, options) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return answer data for a host

Parameters:

  • host (Beaker::Host)

    Host to return data for

  • master_certname (String)

    Hostname of the puppet master.

  • master (Beaker::Host)

    Host object representing the master

  • dashboard (Beaker::Host)

    Host object representing the dashboard

  • 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.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/beaker/answers/version28.rb', line 18

def self.host_answers(host, master_certname, master, dashboard, options)
  return nil if host['platform'] =~ /windows/

  agent_a = {
    :q_install => 'y',
    :q_puppetagent_install => 'y',
    :q_puppet_cloud_install => 'y',
    :q_puppet_symlinks_install => 'y',
    :q_vendor_packages_install => 'y',
    :q_puppetagent_certname => host,
    :q_puppetagent_server => master,

    # Disable console and master by default
    # This will be overridden by other blocks being merged in
    :q_puppetmaster_install => 'n',
    :q_puppet_enterpriseconsole_install => 'n',
  }

  master_a = {
    :q_puppetmaster_install => 'y',
    :q_puppetmaster_certname => master_certname,
    :q_puppetmaster_install => 'y',
    :q_puppetmaster_dnsaltnames => master_certname+",puppet",
    :q_puppetmaster_enterpriseconsole_hostname => dashboard,
    :q_puppetmaster_enterpriseconsole_port => 443,
    :q_puppetmaster_forward_facts => 'y',
  }

  if master['ip']
    master_a[:q_puppetmaster_dnsaltnames]+=","+master['ip']
  end

  dashboard_user = "'#{ENV['q_puppet_enterpriseconsole_auth_user_email'] || '[email protected]'}'"
  smtp_host = "'#{ENV['q_puppet_enterpriseconsole_smtp_host'] || dashboard}'"
  dashboard_password = ENV['q_puppet_enterpriseconsole_auth_password'] || '~!@#$%^*-/ aZ'
  smtp_port = "'#{ENV['q_puppet_enterpriseconsole_smtp_port'] || 25}'"
  smtp_username = ENV['q_puppet_enterpriseconsole_smtp_username']
  smtp_password = ENV['q_puppet_enterpriseconsole_smtp_password']
  smtp_use_tls = "'#{ENV['q_puppet_enterpriseconsole_smtp_use_tls'] || 'n'}'"

  console_a = {
    :q_puppet_enterpriseconsole_install => 'y',
    :q_puppet_enterpriseconsole_database_install => 'y',
    :q_puppet_enterpriseconsole_auth_database_name => 'console_auth',
    :q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r',
    :q_puppet_enterpriseconsole_auth_database_password => "'#{dashboard_password}'",
    :q_puppet_enterpriseconsole_database_name => 'console',
    :q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r',
    :q_puppet_enterpriseconsole_database_password => "'#{dashboard_password}'",
    :q_puppet_enterpriseconsole_inventory_hostname => host,
    :q_puppet_enterpriseconsole_inventory_certname => host,
    :q_puppet_enterpriseconsole_inventory_dnsaltnames => master,
    :q_puppet_enterpriseconsole_inventory_port => 8140,
    :q_puppet_enterpriseconsole_master_hostname => master,

    :q_puppet_enterpriseconsole_auth_user_email => dashboard_user,
    :q_puppet_enterpriseconsole_auth_password => "'#{dashboard_password}'",

    :q_puppet_enterpriseconsole_httpd_port => 443,

    :q_puppet_enterpriseconsole_smtp_host => smtp_host,
    :q_puppet_enterpriseconsole_smtp_use_tls => smtp_use_tls,
    :q_puppet_enterpriseconsole_smtp_port => smtp_port,
  }

  console_a[:q_puppet_enterpriseconsole_auth_user] = console_a[:q_puppet_enterpriseconsole_auth_user_email]

  if smtp_password and smtp_username
    console_a.merge!({
                       :q_puppet_enterpriseconsole_smtp_password => "'#{smtp_password}'",
                       :q_puppet_enterpriseconsole_smtp_username => "'#{smtp_username}'",
                       :q_puppet_enterpriseconsole_smtp_user_auth => 'y'
                     })
  end

  answers = agent_a.dup
  if host == master
    answers.merge! master_a
  end

  if host == dashboard
    answers.merge! console_a
  end

  return answers
end