diff options
-rw-r--r-- | chef-utils/README.md | 14 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/architecture.rb | 11 | ||||
-rw-r--r-- | chef-utils/spec/unit/dsl/architecture_spec.rb | 8 |
3 files changed, 24 insertions, 9 deletions
diff --git a/chef-utils/README.md b/chef-utils/README.md index e44d4d6937..fb5dd98b07 100644 --- a/chef-utils/README.md +++ b/chef-utils/README.md @@ -108,17 +108,21 @@ The OS helpers provide an alternative to comparing data from `node['os']`. Architecture Helpers allow you to determine the processor architecture of your node. -* `_64_bit?` * `_32_bit?` +* `_64_bit?` +* `aarch64?` +* `arch64?` +* `arm64?` +* `arm?` +* `armhf?` * `i386?` * `intel?` -* `sparc?` +* `powerpc?` * `ppc64?` * `ppc64le?` -* `powerpc?` -* `armhf?` -* `s390x?` * `s390?` +* `s390x?` +* `sparc?` ### Cloud Helpers diff --git a/chef-utils/lib/chef-utils/dsl/architecture.rb b/chef-utils/lib/chef-utils/dsl/architecture.rb index d20c6c5a76..30e908d694 100644 --- a/chef-utils/lib/chef-utils/dsl/architecture.rb +++ b/chef-utils/lib/chef-utils/dsl/architecture.rb @@ -103,6 +103,17 @@ module ChefUtils %w{powerpc}.include?(node["kernel"]["machine"]) end + # Determine if the current architecture is arm + # + # @since 15.10 + # + # @return [Boolean] + # + def arm?(node = __getnode) + %w{armhf aarch64 arm64 arch64} + .include?(node["kernel"]["machine"]) + end + # Determine if the current architecture is 32-bit ARM. # # @since 15.5 diff --git a/chef-utils/spec/unit/dsl/architecture_spec.rb b/chef-utils/spec/unit/dsl/architecture_spec.rb index a2ce300fe0..c43b2d0733 100644 --- a/chef-utils/spec/unit/dsl/architecture_spec.rb +++ b/chef-utils/spec/unit/dsl/architecture_spec.rb @@ -84,17 +84,17 @@ RSpec.describe ChefUtils::DSL::Architecture do context "on aarch64" do let(:arch) { "aarch64" } - arch_reports_true_for(:_64_bit?) + arch_reports_true_for(:_64_bit?, :arm?) end context "on arch64" do let(:arch) { "arch64" } - arch_reports_true_for(:_64_bit?) + arch_reports_true_for(:_64_bit?, :arm?) end context "on arm64" do let(:arch) { "arm64" } - arch_reports_true_for(:_64_bit?) + arch_reports_true_for(:_64_bit?, :arm?) end context "on sun4v" do let(:arch) { "sun4v" } @@ -129,7 +129,7 @@ RSpec.describe ChefUtils::DSL::Architecture do context "on armhf" do let(:arch) { "armhf" } - arch_reports_true_for(:armhf?, :_32_bit?) + arch_reports_true_for(:armhf?, :_32_bit?, :arm?) end context "on s390" do let(:arch) { "s390" } |