Module: Beaker::DSL::InstallUtils::FOSSDefaults

Included in:
FOSSUtils, Puppet5, BeakerPuppet
Defined in:
lib/beaker-puppet/install_utils/foss_defaults.rb

Overview

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

Constant Summary collapse

FOSS_DEFAULT_DOWNLOAD_URLS =

Here be the default download URLs

{
  win_download_url: 'https://downloads.puppet.com/windows',
  mac_download_url: 'https://downloads.puppet.com/mac',
  pe_promoted_builds_url: 'https://pm.puppet.com',
  release_apt_repo_url: 'https://apt.puppet.com',
  release_yum_repo_url: 'https://yum.puppet.com',
  nightly_builds_url: 'https://nightlies.puppet.com',
  nightly_apt_repo_url: 'https://nightlies.puppet.com/apt',
  nightly_yum_repo_url: 'https://nightlies.puppet.com/yum',
  nightly_win_download_url: 'https://nightlies.puppet.com/downloads/windows',
  nightly_mac_download_url: 'https://nightlies.puppet.com/downloads/mac',
  dev_builds_url: 'https://builds.delivery.puppetlabs.net',
}
FOSS_DEFAULTS =

Here be the pathing and default values for FOSS installs

{
  'freebsd' => {
    'puppetserver-confdir' => '/etc/puppetserver/conf.d',
    'puppetservice' => 'puppetmaster',
    'puppetpath' => '/usr/local/etc/puppet/modules',
    'puppetvardir' => '/var/lib/puppet',
    'puppetbin' => '/usr/bin/puppet',
    'puppetbindir' => '/usr/bin',
    'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
    'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
    'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
    'hieradatadir' => '/usr/local/etc/puppet/modules/hieradata',
    'hieraconf' => '/usr/local/etc/puppet/modules/hiera.yaml',
    'distmoduledir' => '/usr/local/etc/puppet/modules',
    'sitemoduledir' => '/usr/share/puppet/modules',
  },
  'openbsd' => {
    'puppetserver-confdir' => '/etc/puppetserver/conf.d',
    'puppetservice' => 'puppetmaster',
    'puppetpath' => '/etc/puppet/modules',
    'puppetvardir' => '/var/puppet',
    'puppetbin' => '/usr/local/bin/puppet',
    'puppetbindir' => '/usr/local/bin',
    'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
    'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
    'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
    'hieradatadir' => '/etc/puppet/hieradata',
    'hieraconf' => '/etc/puppet/hiera.yaml',
    'distmoduledir' => '/etc/puppet/modules',
    'sitemoduledir' => '/usr/local/share/puppet/modules',
  },
  'mac' => {
    'puppetserver-confdir' => '/etc/puppetserver/conf.d',
    'puppetservice' => 'puppetmaster',
    'puppetpath' => '/etc/puppet',
    'puppetconfdir' => '/etc/puppet',
    'puppetcodedir' => '/etc/puppet',
    'puppetvardir' => '/var/lib/puppet',
    'puppetbin' => '/usr/bin/puppet',
    'puppetbindir' => '/usr/bin',
    'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
    'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
    'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
    'hieradatadir' => '/etc/puppet/hieradata',
    'hieraconf' => '/etc/puppet/hiera.yaml',
    'distmoduledir' => '/etc/puppet/modules',
    'sitemoduledir' => '/usr/share/puppet/modules',
  },
  'unix' => {
    'puppetserver-confdir' => '/etc/puppetserver/conf.d',
    'puppetservice' => 'puppetmaster',
    'puppetpath' => '/etc/puppet',
    'puppetconfdir' => '/etc/puppet',
    'puppetvardir' => '/var/lib/puppet',
    'puppetbin' => '/usr/bin/puppet',
    'puppetbindir' => '/usr/bin',
    'privatebindir' => '/usr/bin',
    'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
    'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
    'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
    'hieradatadir' => '/etc/puppet/hieradata',
    'hieraconf' => '/etc/puppet/hiera.yaml',
    'distmoduledir' => '/etc/puppet/modules',
    'sitemoduledir' => '/usr/share/puppet/modules',
  },
  'archlinux' => {
    'puppetserver-confdir' => '/etc/puppetserver/conf.d',
    'puppetservice' => 'puppetmaster',
    'puppetpath' => '/etc/puppetlabs/puppet',
    'puppetconfdir' => '/etc/puppetlabs/puppet',
    'puppetvardir' => '/opt/puppetlabs/puppet/cache',
    'puppetbin' => '/usr/bin/puppet',
    'puppetbindir' => '/usr/bin',
    'privatebindir' => '/usr/bin',
    'hieralibdir' => '/var/lib/hiera',
    'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
    'hierabindir' => '/usr/bin',
    'hieradatadir' => '/etc/puppetlabs/code/hiera',
    'hieraconf' => '/etc/hiera.yaml',
    'distmoduledir' => '/etc/puppetlabs/code/modules',
    'sitemoduledir' => '/usr/share/puppet/modules',
  },
  'windows' => { # cygwin windows
    '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/puppet/etc/modules',
    'sitemoduledir' => 'C:/usr/share/puppet/modules',
    'hieralibdir' => '`cygpath -w /opt/puppet-git-repos/hiera/lib`',
    'hierapuppetlibdir' => '`cygpath -w /opt/puppet-git-repos/hiera-puppet/lib`',
    # let's just add both potential bin dirs to the path
    'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet/bin',
    'privatebindir' => '/usr/bin',
    'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
  },
  'pswindows' => { # windows windows
    'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
    'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
    'hieralibdir' => 'C:\\opt\\puppet-git-repos\\hiera\\lib',
    'hierapuppetlibdir' => 'C:\\opt\\puppet-git-repos\\hiera-puppet\\lib',
    'hierabindir' => 'C:\\opt\\puppet-git-repos\\hiera\\bin',
    'puppetpath' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc";"C:\\Program Files\\Puppet Labs\\Puppet\\etc"',
    'hieraconf' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc\\hiera.yaml";"C:\\Program Files\\Puppet Labs\\Puppet\\etc\\hiera.yaml"',
    'puppetvardir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\var";"C:\\Program Files\\Puppet Labs\\Puppet\\var"',
    'puppetbindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\bin"',
  },
}

Instance Method Summary collapse

Instance Method Details

#add_foss_defaults_on(hosts) ⇒ Object

Add the appropriate foss 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.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/beaker-puppet/install_utils/foss_defaults.rb', line 154

def add_foss_defaults_on(hosts)
  block_on hosts do |host|
    platform = case host.class.to_s.downcase
               when /aix|unix/
                 'unix'
               when /freebsd/
                 'freebsd'
               when /openbsd/
                 'openbsd'
               when /mac/
                 'mac'
               when /pswindows/
                 'pswindows'
               when /archlinux/
                 'archlinux'
               else
                 'windows'
               end
    add_platform_foss_defaults(host, platform)
  end
end

#add_platform_foss_defaults(host, platform) ⇒ Object

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

Parameters:

  • host (Host)

    A single host to act upon

  • platform (String)

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



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/beaker-puppet/install_utils/foss_defaults.rb', line 138

def add_platform_foss_defaults(host, platform)
  FOSS_DEFAULTS[platform].each_pair do |key, val|
    host[key] = val
  end
  # add the group and type for backwards compatability
  host['group'] = if host['platform'] =~ /windows/
                    'Administrators'
                  else
                    'puppet'
                  end
  host['type'] = 'foss'
end

#remove_foss_defaults_on(hosts) ⇒ Object

Remove the appropriate foss 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.



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/beaker-puppet/install_utils/foss_defaults.rb', line 190

def remove_foss_defaults_on(hosts)
  block_on hosts do |host|
    platform = case host.class.to_s.downcase
               when /aix|unix/
                 'unix'
               when /freebsd/
                 'freebsd'
               when /openbsd/
                 'openbsd'
               when /mac/
                 'mac'
               when /pswindows/
                 'pswindows'
               else
                 'windows'
               end
    remove_platform_foss_defaults(host, platform)
  end
end

#remove_platform_foss_defaults(host, platform) ⇒ Object

Remove the appropriate foss 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, pswindows, freebsd, mac & unix



179
180
181
182
183
184
185
# File 'lib/beaker-puppet/install_utils/foss_defaults.rb', line 179

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