[chef] Re: Re: Re: Re: Re: Re: resource for copy local file?


Chronological Thread 
  • From: < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: resource for copy local file?
  • Date: Mon, 12 Sep 2011 19:27:00 -0700 (PDT)

I followed the instruction, but can't work as expected. Any suggestions?

Below is my recipe:
#cat /root/cookbooks/a/recipes/default.rb
file "/copied.txt" do
content "/tmp/1.txt"
provider Chef::Provider::File::Copy
end

The content of /copied.txt is not the content of /tmp/1.txt 
#cat /copied.txt
/tmp/1.txt

Below is my library file:
# cat /root/cookbooks/a/libraries/file_provider_copy.rb
class Chef
  class Provider
    class File
      class Copy < Chef::Provider::File

        def compare_content
          checksum(@current_resource.path) == checksum(@new_resource.content)
        end

        def set_content
          unless compare_content
            backup @new_resource.path if ::File.exists?(@new_resource.path)
  #          ::File.cp_r(@new_resource.content, @new_resource.path)
::FileUtils.cp_r(@new_resource.content, @new_resource.path)

            
Chef::Log.info("
 copied to
")
            @new_resource.updated_by_last_action(true)
          end
        end
      end
    end
  end
end


  • [chef] Re: Re: Re: Re: Re: Re: resource for copy local file?, zkfhu, 09/12/2011

Archive powered by MHonArc 2.6.16.

§