Method: Chef::DSL::PlatformIntrospection#platform?

Defined in:
lib/chef/dsl/platform_introspection.rb

#platform?(*args) ⇒ Boolean

Given a list of platforms, returns true if the current recipe is being run on a node with that platform, false otherwise.

Parameters

args

A list of platforms. Each platform can be in string or symbol format.

Returns

true

If the current platform is in the list

false

If the current platform is not in the list

Returns:

  • (Boolean)


163
164
165
166
167
168
169
170
171
# File 'lib/chef/dsl/platform_introspection.rb', line 163

def platform?(*args)
  has_platform = false

  args.flatten.each do |platform|
    has_platform = true if platform.to_s == node[:platform]
  end

  has_platform
end