Module: Beaker::DSL::InstallUtils::AIODefaults

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

Overview

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

Constant Summary collapse

AIO_DEFAULTS =

Here be the pathing and default values for AIO installs

{
  'unix' => {
    'puppetbindir' => '/opt/puppetlabs/bin',
    'privatebindir' => '/opt/puppetlabs/puppet/bin',
    'distmoduledir' => '/etc/puppetlabs/code/modules',
    'sitemoduledir' => '/opt/puppetlabs/puppet/modules',
  },
  # sitemoduledir not included on Windows (check PUP-4049 for more info).
  #
  # Paths to the puppet's vendored ruby installation on Windows were
  # updated in Puppet 6 to more closely match those of *nix agents.
  # These path values include both the older (puppet <= 5) paths (which
  # include sys/ruby) and the newer versions, which have no custom ruby
  # directory
  'windows' => { # windows with cygwin
    'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin',
    'privatebindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin:/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/sys/ruby/bin',
    'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/code/modules',
  },
  'windows-64' => { # windows with cygwin
    'puppetbindir' => '/cygdrive/c/Program Files/Puppet Labs/Puppet/bin',
    'privatebindir' => '/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet/sys/ruby/bin',
    'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/code/modules',
  },
  'pswindows' => { # pure windows
    'puppetbindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\bin"',
    'privatebindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\puppet\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\puppet\\bin";"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\sys\\ruby\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\sys\\ruby\\bin"',
    'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\code\\modules',
  },
}

Instance Method Summary collapse

Instance Method Details

#add_aio_defaults_on(hosts) ⇒ Object

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



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/beaker-puppet/install_utils/aio_defaults.rb', line 59

def add_aio_defaults_on(hosts)
  block_on hosts do |host|
    if host.is_powershell?
      platform = 'pswindows'
    elsif host['platform'] =~ /windows/
      ruby_arch = if host[:ruby_arch] == 'x64'
                    /-64/
                  else
                    /-32/
                  end
      platform = if host['platform'] =~ ruby_arch
                   'windows-64'
                 else
                   'windows'
                 end
    else
      platform = 'unix'
    end
    add_platform_aio_defaults(host, platform)
  end
end

#add_platform_aio_defaults(host, platform) ⇒ Object

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

Parameters:

  • host (Host)

    A single host to act upon

  • platform (String)

    The platform type of this host, one of ‘windows’, ‘pswindows’, or ‘unix’



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/beaker-puppet/install_utils/aio_defaults.rb', line 44

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

#remove_aio_defaults_on(hosts) ⇒ Object

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



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/beaker-puppet/install_utils/aio_defaults.rb', line 94

def remove_aio_defaults_on(hosts)
  block_on hosts do |host|
    platform = if host.is_powershell?
                 'pswindows'
               elsif host['platform'] =~ /windows/
                 'windows'
               else
                 'unix'
               end
    remove_platform_aio_defaults(host, platform)
  end
end

#remove_platform_aio_defaults(host, platform) ⇒ Object

Remove the appropriate aio 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



84
85
86
87
88
89
# File 'lib/beaker-puppet/install_utils/aio_defaults.rb', line 84

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