Module: Beaker::DSL::InstallUtils::PEDefaults

Included in:
PEUtils, PE
Defined in:
lib/beaker-pe/install/pe_defaults.rb

Overview

This module contains default values for pe paths and directorys per-platform

Constant Summary collapse

PE_DEFAULTS =

Here be the pathing and default values for PE installs

{
  'mac' => {
    'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
    'puppetservice'    => 'pe-puppetserver',
    'puppetpath'       => '/etc/puppetlabs/puppet',
    'puppetconfdir'    => '/etc/puppetlabs/puppet',
    'puppetcodedir'    => '/etc/puppetlabs/puppet',
    'puppetbin'        => '/opt/puppet/bin/puppet',
    'puppetbindir'     => '/opt/puppet/bin',
    'puppetsbindir'    => '/opt/puppet/sbin',
    'puppetvardir'     => '/var/opt/lib/pe-puppet',
    'hieradatadir'     => '/var/lib/hiera',
    'hieraconf'        => '/etc/puppetlabs/puppet/hiera.yaml',
    'distmoduledir'    => '/etc/puppetlabs/code/modules',
    'sitemoduledir'    => '/opt/puppet/share/puppet/modules',
  },
  'unix' => {
    'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
    'puppetservice'    => 'pe-puppetserver',
    'puppetpath'       => '/etc/puppetlabs/puppet',
    'puppetconfdir'    => '/etc/puppetlabs/puppet',
    'puppetbin'        => '/opt/puppet/bin/puppet',
    'puppetbindir'     => '/opt/puppet/bin',
    'puppetsbindir'    => '/opt/puppet/sbin',
    'privatebindir'    => '/opt/puppet/bin',
    'puppetvardir'     => '/var/opt/lib/pe-puppet',
    'hieradatadir'     => '/var/lib/hiera',
    'hieraconf'        => '/etc/puppetlabs/puppet/hiera.yaml',
    'distmoduledir'    => '/etc/puppetlabs/code/modules',
    'sitemoduledir'    => '/opt/puppet/share/puppet/modules',
  },
  'windows' => { #cygwin windows
    'puppetservice' => 'pe-puppetserver',
    'puppetpath'    => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
    'puppetconfdir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
    'puppetcodedir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
    'hieraconf'     => '`cygpath -smF 35`/Puppetlabs/puppet/etc/hiera.yaml',
    'puppetvardir'  => '`cygpath -smF 35`/PuppetLabs/puppet/var',
    'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/code/modules',
    'sitemoduledir' => 'C:/usr/share/puppet/modules',
    #let's just add both potential bin dirs to the path
    'puppetbindir'  => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet Enterprise/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet Enterprise/bin',
    'privatebindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet Enterprise/sys/ruby/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet Enterprise/sys/ruby/bin',
  },
  'pswindows' => { #windows windows
    'puppetservice' => 'pe-puppetserver',
    'puppetpath'    => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
    'puppetconfdir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
    'puppetcodedir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
    'hieraconf'     => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\hiera.yaml',
    'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\code\\modules',
    'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
    'puppetvardir'  => 'C:\\ProgramData\\PuppetLabs\\puppet\\var',
    'puppetbindir'  => '"C:\\Program Files (x86)\\PuppetLabs\\Puppet Enterprise\\bin";"C:\\Program Files\\PuppetLabs\\Puppet Enterprise\\bin"'
  },
}

Instance Method Summary collapse

Instance Method Details

#add_pe_defaults_on(hosts) ⇒ Object

Add the appropriate pe defaults to an array of hosts

Parameters:

  • hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/beaker-pe/install/pe_defaults.rb', line 93

def add_pe_defaults_on(hosts)
  block_on hosts do | host |
    case host.class.to_s.downcase
    when /aix|(free|open)bsd|unix/
      platform = 'unix'
    when /mac/
      platform = 'mac'
    when /pswindows/
      platform = 'pswindows'
    else
      platform = 'windows'
    end
    add_platform_pe_defaults(host, platform)
  end
end

#add_platform_pe_defaults(host, platform) ⇒ Object

Add the appropriate pe defaults to the host object so that they can be accessed using host, set host = pe

Parameters:

  • host (Host)

    A single host to act upon

  • platform (String)

    The platform type of this host, one of windows, pswindows, mac & unix



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/beaker-pe/install/pe_defaults.rb', line 71

def add_platform_pe_defaults(host, platform)
  PE_DEFAULTS[platform].each_pair do |key, val|
    host[key] = val
  end
  # add the type and group here for backwards compatability
  if host['platform'] =~ /windows/
    host['group'] = 'Administrators'
  else
    host['group'] = 'pe-puppet'
  end
  host['type'] = 'pe'
  # older pe requires a different puppetservice name, set it here on the master
  if host['roles'].include?('master')
    if host['pe_ver'] and (version_is_less(host['pe_ver'], '3.4'))
      host['puppetservice'] = 'pe-httpd'
    end
  end
end

#remove_pe_defaults_on(hosts) ⇒ Object

Remove the appropriate pe defaults from an array of hosts

Parameters:

  • hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/beaker-pe/install/pe_defaults.rb', line 123

def remove_pe_defaults_on(hosts)
  block_on hosts do | host |
    case host.class.to_s.downcase
    when /aix|(free|open)bsd|unix/
      platform = 'unix'
    when /mac/
      platform = 'mac'
    when /pswindows/
      platform = 'pswindows'
    else
      platform = 'windows'
    end
    remove_platform_pe_defaults(host, platform)
  end
end

#remove_platform_pe_defaults(host, platform) ⇒ Object

Remove the appropriate pe defaults from the host object so that they can no longer be accessed using host, set host = nil

Parameters:

  • host (Host)

    A single host to act upon

  • platform (String)

    The platform type of this host, one of windows, freebsd, mac & unix



112
113
114
115
116
117
118
# File 'lib/beaker-pe/install/pe_defaults.rb', line 112

def remove_platform_pe_defaults(host, platform)
  PE_DEFAULTS[platform].each_pair do |key, val|
    host.delete(key)
  end
  host['group'] = nil
  host['type'] = nil
end