Module: Chef::Sugar::Platform

Extended by:
Platform
Included in:
Platform
Defined in:
lib/chef/sugar/platform.rb

Constant Summary collapse

PLATFORM_VERSIONS =
{
  'debian' => {
    'squeeze' => '6',
    'wheezy'  => '7',
    'jessie'  => '8',
    'stretch' => '9',
  },
  'linuxmint' => {
    'qiana'  => '17',
    'petra'  => '16',
    'olivia' => '15',
    'nadia'  => '14',
    'maya'   => '13',
    'lisa'   => '12',
  },
  'mac_os_x' => {
    'lion'          => '10.7',
    'mountain_lion' => '10.8',
    'mavericks'     => '10.9',
    'yosemite'      => '10.10',
    'el_capitan'    => '10.11',
    'sierra'        => '10.12',
  },
  'solaris' => {
    '7'  => '5.7',
    '8'  => '5.8',
    '9'  => '5.9',
    '10' => '5.10',
    '11' => '5.11',
  },
  'ubuntu' => {
    'lucid'    => '10.04',
    'maverick' => '10.10',
    'natty'    => '11.04',
    'oneiric'  => '11.10',
    'precise'  => '12.04',
    'quantal'  => '12.10',
    'raring'   => '13.04',
    'saucy'    => '13.10',
    'trusty'   => '14.04',
    'utopic'   => '14.10',
    'vivid'    => '15.04',
    'wily'     => '15.10',
    'xenial'   => '16.04',
    'zesty'    => '17.04',
  },
}
COMPARISON_OPERATORS =
{
  'after'        => ->(a, b) { a > b },
  'after_or_at'  => ->(a, b) { a >= b },
  ''             => ->(a, b) { a == b },
  'before'       => ->(a, b) { a < b },
  'before_or_at' => ->(a, b) { a <= b },
}

Instance Method Summary collapse

Instance Method Details

#aix?(node) ⇒ Boolean

Determine if the current node is aix

Parameters:

Returns:

  • (Boolean)


225
226
227
# File 'lib/chef/sugar/platform.rb', line 225

def aix?(node)
  node['platform'] == 'aix'
end

#amazon_linux?(node) ⇒ Boolean Also known as: amazon?

Determine if the current node is amazon linux.

Parameters:

Returns:

  • (Boolean)


143
144
145
# File 'lib/chef/sugar/platform.rb', line 143

def amazon_linux?(node)
  node['platform'] == 'amazon'
end

#centos?(node) ⇒ Boolean

Determine if the current node is centos.

Parameters:

Returns:

  • (Boolean)


155
156
157
# File 'lib/chef/sugar/platform.rb', line 155

def centos?(node)
  node['platform'] == 'centos'
end

#debian_platform?(node) ⇒ Boolean

Determine if the current node is debian (platform, not platform_family).

Parameters:

Returns:

  • (Boolean)


132
133
134
# File 'lib/chef/sugar/platform.rb', line 132

def debian_platform?(node)
  node['platform'] == 'debian'
end

#fedora_platform?(node) ⇒ Boolean

Determine if the current node is fedora (platform, not platform_family).

Parameters:

Returns:

  • (Boolean)


202
203
204
# File 'lib/chef/sugar/platform.rb', line 202

def fedora_platform?(node)
  node['platform'] == 'fedora'
end

#ios_xr?(node) ⇒ Boolean

Determine if the current node is a Cisco IOS-XR device

Parameters:

Returns:

  • (Boolean)


280
281
282
# File 'lib/chef/sugar/platform.rb', line 280

def ios_xr?(node)
  node['platform'] == 'ios_xr'
end

#linux_mint?(node) ⇒ Boolean Also known as: mint?

Determine if the current node is linux mint.

Parameters:

Returns:

  • (Boolean)


109
110
111
# File 'lib/chef/sugar/platform.rb', line 109

def linux_mint?(node)
  node['platform'] == 'linuxmint'
end

#nexus?(node) ⇒ Boolean

Determine if the current node is a Cisco nexus device

Parameters:

Returns:

  • (Boolean)


269
270
271
# File 'lib/chef/sugar/platform.rb', line 269

def nexus?(node)
  node['platform'] == 'nexus'
end

#omnios?(node) ⇒ Boolean

Determine if the current node is omnios

Parameters:

Returns:

  • (Boolean)


247
248
249
# File 'lib/chef/sugar/platform.rb', line 247

def omnios?(node)
  node['platform'] == 'omnios'
end

#oracle_linux?(node) ⇒ Boolean Also known as: oracle?

Determine if the current node is oracle linux.

Parameters:

Returns:

  • (Boolean)


166
167
168
# File 'lib/chef/sugar/platform.rb', line 166

def oracle_linux?(node)
  node['platform'] == 'oracle'
end

#platform_version(node) ⇒ Chef::Sugar::Constraints::Version

Return the platform_version for the node. Acts like a String but also provides a mechanism for checking version constraints.

Parameters:

Returns:



292
293
294
# File 'lib/chef/sugar/platform.rb', line 292

def platform_version(node)
  Chef::Sugar::Constraints::Version.new(node['platform_version'])
end

#raspbian?(node) ⇒ Boolean

Determine if the current node is raspbian

Parameters:

Returns:

  • (Boolean)


258
259
260
# File 'lib/chef/sugar/platform.rb', line 258

def raspbian?(node)
  node['platform'] == 'raspbian'
end

#redhat_enterprise_linux?(node) ⇒ Boolean Also known as: redhat_enterprise?

Determine if the current node is redhat enterprise.

Parameters:

Returns:

  • (Boolean)


190
191
192
# File 'lib/chef/sugar/platform.rb', line 190

def redhat_enterprise_linux?(node)
  node['platform'] == 'redhat'
end

#scientific_linux?(node) ⇒ Boolean Also known as: scientific?

Determine if the current node is scientific linux.

Parameters:

Returns:

  • (Boolean)


178
179
180
# File 'lib/chef/sugar/platform.rb', line 178

def scientific_linux?(node)
  node['platform'] == 'scientific'
end

#smartos?(node) ⇒ Boolean

Determine if the current node is smartos

Parameters:

Returns:

  • (Boolean)


236
237
238
# File 'lib/chef/sugar/platform.rb', line 236

def smartos?(node)
  node['platform'] == 'smartos'
end

#solaris2?(node) ⇒ Boolean Also known as: solaris?

Determine if the current node is solaris2

Parameters:

Returns:

  • (Boolean)


213
214
215
# File 'lib/chef/sugar/platform.rb', line 213

def solaris2?(node)
  node['platform'] == 'solaris2'
end

#ubuntu?(node) ⇒ Boolean

Determine if the current node is ubuntu.

Parameters:

Returns:

  • (Boolean)


121
122
123
# File 'lib/chef/sugar/platform.rb', line 121

def ubuntu?(node)
  node['platform'] == 'ubuntu'
end