Module: Chef::Sugar::Architecture

Extended by:
Architecture
Included in:
Architecture
Defined in:
lib/chef/sugar/architecture.rb

Instance Method Summary collapse

Instance Method Details

#_32_bit?(node) ⇒ Boolean

TODO:

Make this more than “not 64-bit”

Determine if the current architecture is 32-bit

Returns:

  • (Boolean)


41
42
43
# File 'lib/chef/sugar/architecture.rb', line 41

def _32_bit?(node)
  !_64_bit?(node)
end

#_64_bit?(node) ⇒ Boolean

Determine if the current architecture is 64-bit

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/chef/sugar/architecture.rb', line 29

def _64_bit?(node)
  %w(amd64 x86_64 ppc64 ppc64le s390x ia64 sparc64 aarch64 arch64 arm64 sun4v sun4u s390x)
    .include?(node['kernel']['machine']) || ( node['kernel']['bits'] == '64' )
end

#aarch64?(node) ⇒ Boolean

Determine if the current architecture is AArch64

Returns:

  • (Boolean)


120
121
122
123
124
# File 'lib/chef/sugar/architecture.rb', line 120

def aarch64?(node)
  # Add more arm variants as needed here
  %w(aarch64)
    .include?(node['kernel']['machine'])
end

#armhf?(node) ⇒ Boolean

Determine if the current architecture is ARM with Hard Float

Returns:

  • (Boolean)


109
110
111
112
113
# File 'lib/chef/sugar/architecture.rb', line 109

def armhf?(node)
  # Add more arm variants as needed here
  %w(armv6l armv7l)
    .include?(node['kernel']['machine'])
end

#i386?(node) ⇒ Boolean

Determine if the current architecture is i386

Returns:

  • (Boolean)


50
51
52
# File 'lib/chef/sugar/architecture.rb', line 50

def i386?(node)
  _32_bit?(node) && intel?(node)
end

#intel?(node) ⇒ Boolean

Determine if the current architecture is Intel.

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/chef/sugar/architecture.rb', line 59

def intel?(node)
  %w(i86pc i386 x86_64 amd64 i686)
    .include?(node['kernel']['machine'])
end

#powerpc?(node) ⇒ Boolean

Determine if the current architecture is PowerPC

Returns:

  • (Boolean)


99
100
101
102
# File 'lib/chef/sugar/architecture.rb', line 99

def powerpc?(node)
  %w(powerpc)
    .include?(node['kernel']['machine'])
end

#ppc64?(node) ⇒ Boolean

Determine if the current architecture is Powerpc64 Big Endian

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/chef/sugar/architecture.rb', line 79

def ppc64?(node)
  %w(ppc64)
    .include?(node['kernel']['machine'])
end

#ppc64le?(node) ⇒ Boolean

Determine if the current architecture is Powerpc64 Little Endian

Returns:

  • (Boolean)


89
90
91
92
# File 'lib/chef/sugar/architecture.rb', line 89

def ppc64le?(node)
  %w(ppc64le)
    .include?(node['kernel']['machine'])
end

#s390x?(node) ⇒ Boolean

Determine if the current architecture is s390x

Returns:

  • (Boolean)


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

def s390x?(node)
  %w(s390x)
    .include?(node['kernel']['machine'])
end

#sparc?(node) ⇒ Boolean

Determine if the current architecture is SPARC.

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/chef/sugar/architecture.rb', line 69

def sparc?(node)
  %w(sun4u sun4v)
    .include?(node['kernel']['machine'])
end