diff options
-rw-r--r-- | lib/chef/provider/ohai.rb | 8 | ||||
-rw-r--r-- | lib/chef/resource/ohai.rb | 30 | ||||
-rw-r--r-- | spec/unit/resource/ohai_spec.rb | 2 |
3 files changed, 11 insertions, 29 deletions
diff --git a/lib/chef/provider/ohai.rb b/lib/chef/provider/ohai.rb index 6b5a605ed5..8f1939af6d 100644 --- a/lib/chef/provider/ohai.rb +++ b/lib/chef/provider/ohai.rb @@ -21,6 +21,8 @@ require "ohai" class Chef class Provider class Ohai < Chef::Provider + use_inline_resources + provides :ohai def whyrun_supported? @@ -31,7 +33,7 @@ class Chef true end - def action_reload + action :reload do converge_by("re-run ohai and merge results into node attributes") do ohai = ::Ohai::System.new @@ -39,9 +41,9 @@ class Chef # Otherwise it will only reload the specified plugin # Note that any changes to plugins, or new plugins placed on # the path are picked up by ohai. - ohai.all_plugins @new_resource.plugin + ohai.all_plugins new_resource.plugin node.automatic_attrs.merge! ohai.data - Chef::Log.info("#{@new_resource} reloaded") + Chef::Log.info("#{new_resource} reloaded") end end end diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb index 09cd22efc5..6fffecf16e 100644 --- a/lib/chef/resource/ohai.rb +++ b/lib/chef/resource/ohai.rb @@ -20,34 +20,14 @@ class Chef class Resource class Ohai < Chef::Resource + resource_name :ohai + provides :ohai - identity_attr :name - - state_attrs :plugin + property :ohai_name, name_property: true + property :plugin, [String] default_action :reload - - def initialize(name, run_context = nil) - super - @name = name - @plugin = nil - end - - def plugin(arg = nil) - set_or_return( - :plugin, - arg, - :kind_of => [ String ] - ) - end - - def name(arg = nil) - set_or_return( - :name, - arg, - :kind_of => [ String ] - ) - end + allowed_actions :reload end end end diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb index 9669ef193d..cf1748002b 100644 --- a/spec/unit/resource/ohai_spec.rb +++ b/spec/unit/resource/ohai_spec.rb @@ -33,7 +33,7 @@ describe Chef::Resource::Ohai do expect(@resource.resource_name).to eql(:ohai) end - it "should have a default action of create" do + it "should have a default action of reload" do expect(@resource.action).to eql([:reload]) end |