diff options
-rw-r--r-- | lib/chef/provider/mount/mount.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/remote_file.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/route.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/execute.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/hostname.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/remote_file.rb | 2 | ||||
-rw-r--r-- | spec/unit/resource/execute_spec.rb | 2 |
7 files changed, 9 insertions, 9 deletions
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index 17b357ec70..00acb556b0 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -157,7 +157,7 @@ class Chef # Return appropriate default mount options according to the given os. def default_mount_options - node[:os] == "linux" ? "defaults" : "rw" + linux? ? "defaults" : "rw" end def enable_fs diff --git a/lib/chef/provider/remote_file.rb b/lib/chef/provider/remote_file.rb index a2506d6a15..e0a7dfb4d4 100644 --- a/lib/chef/provider/remote_file.rb +++ b/lib/chef/provider/remote_file.rb @@ -1,7 +1,7 @@ # # Author:: Jesse Campbell (<hikeit@gmail.com>) # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2020, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ class Chef requirements.assert(:all_actions) do |a| a.assertion do if prop - node[:platform_family] == "windows" + windows? else true end diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb index 523074bdbb..387a82df57 100644 --- a/lib/chef/provider/route.rb +++ b/lib/chef/provider/route.rb @@ -95,7 +95,7 @@ class Chef end # For linux, we use /proc/net/route file to read proc table info - return if node[:os] != "linux" + return unless linux? route_file = ::File.open("/proc/net/route", "r") diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index ecb1944742..0f61aaf4c8 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -131,7 +131,7 @@ class Chef end def validate_identity_platform(specified_user, password = nil, specified_domain = nil, elevated = false) - if node[:platform_family] == "windows" + if windows? if specified_user && password.nil? raise ArgumentError, "A value for `password` must be specified when a value for `user` is specified on the Windows platform" end diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index ef0218ebaa..e3897b6bef 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -100,7 +100,7 @@ class Chef action :set do description "Sets the node's hostname." - if node["platform_family"] != "windows" + if !windows? ohai "reload hostname" do plugin "hostname" action :nothing @@ -143,7 +143,7 @@ class Chef not_if { shell_out!("/usr/sbin/scutil --get LocalHostName").stdout.chomp == shortname } notifies :reload, "ohai[reload hostname]" end - when node["os"] == "linux" + when linux? case when ::File.exist?("/usr/bin/hostnamectl") && !docker? # use hostnamectl whenever we find it on linux (as systemd takes over the world) diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index 04c582d50d..54c7786cfd 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -109,7 +109,7 @@ class Chef end def validate_identity_platform(specified_user, password = nil, specified_domain = nil) - if node[:platform_family] == "windows" + if windows? if specified_user && password.nil? raise ArgumentError, "A value for `remote_password` must be specified when a value for `user` is specified on the Windows platform" end diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb index 9bd434b74a..868916a0f1 100644 --- a/spec/unit/resource/execute_spec.rb +++ b/spec/unit/resource/execute_spec.rb @@ -109,7 +109,7 @@ describe Chef::Resource::Execute do shared_examples_for "a consumer of the Execute resource" do context "when running on Windows" do before do - allow(resource).to receive(:node).and_return({ platform_family: "windows" }) + allow(resource).to receive(:windows?).and_return(true) end context "when no user, domain, or password is specified" do |