diff options
author | sakazuki <sakazuki@gmail.com> | 2014-01-10 06:05:57 +0900 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-09-10 14:49:29 -0700 |
commit | ced0fa862371230a936ff27d3a552ab39cd2f17a (patch) | |
tree | 364bdabefe2614f0b82ec9284e3498a7d4ccf75a | |
parent | 8cec934b19fe0eb1d6943064eee22e18ac22e7c3 (diff) | |
download | chef-ced0fa862371230a936ff27d3a552ab39cd2f17a.tar.gz |
rewrite in the style of remote_directory
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 3dc092942e..b36e997258 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -19,6 +19,7 @@ require 'chef/log' require 'chef/mixin/command' require 'chef/provider' +require 'chef/resource/file' require 'chef/exceptions' require 'erb' @@ -168,20 +169,27 @@ class Chef ! @config_template.nil? and ! @config_path.nil? end + def resource_for_config(path) + config = Chef::Resource::File.new(path, run_context) + config.cookbook_name = @new_resource.cookbook || @new_resource.cookbook_name + config + end + def generate_config return unless can_generate_config? b = binding template = ::ERB.new(@config_template) - file @config_path do - content template.result(b) - end + config = resource_for_config(@config_path) + config.content template.result(b) + config.run_action(:create) + @new_resource.updated_by_last_action(true) if config.updated? end def delete_config return unless can_generate_config? - file @config_path do - action :delete - end + config = resource_for_config(@config_path) + config.run_action(:delete) + @new_resource.updated_by_last_action(true) if config.updated? end private |