- From: Alex Kiernan <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: resource for copy local file?
- Date: Fri, 9 Sep 2011 10:44:12 +0100
Couple of typos, but solves a particular itch for me!
--- file_provider_copy.rb.orig 2011-09-09 10:43:20.000000000 +0100
+++ file_provider_copy.rb 2011-09-09 10:34:03.000000000 +0100
@@ -3,7 +3,7 @@
class Chef
class Provider
class File
- class Copy << Chef::Provider::File
+ class Copy < Chef::Provider::File
def compare_content
checksum(@current_resource.path) == checksum(@new_resource.content)
@@ -12,7 +12,7 @@
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)
On Thu, Sep 1, 2011 at 12:17 AM, Adam Jacob
<
>
wrote:
>
This is a quick, untested hack - but stick this in a library in a
>
cookbook, and use it like the gist says, and you should get the copy
>
behavior you want.
>
>
https://gist.github.com/1185022
>
>
Adam
>
>
On Wed, Aug 31, 2011 at 12:23 PM, Charles Duffy
>
<
>
>
wrote:
>
> No surprise -- the read is happening at compile time, but the remote_file
>
> resource is actually _created_ at execution time.
>
>
>
> You could force it to run at compile time, I suppose, but the better answer
>
> is that trying to use the "content IO.read" approach doesn't make sense if
>
> you're trying to read things which prior execution-time resources change.
>
>
>
> Anyhow, it's a bad idea for large files, as it means you need to have
>
> enough
>
> memory to store the whole thing -- not a great pattern to use often.
>
>
>
> Perhaps you could implement the copy in a ruby_block resource? That will
>
> make it happen at execution time properly.
>
>
>
> On Tue, Aug 30, 2011 at 10:29 PM,
>
> <
>
>
> wrote:
>
>>
>
>> I still got error: FATAL: Errno::ENOENT: No such file or directory -
>
>> /httpfile
>
>> after I add only_if statement
>
>>
>
>> remote_file "/httpfile" do
>
>> source "http://wiki.opscode.com/display/chef/Home"
>
>> mode "0666"
>
>> end
>
>> file "/httpfile.bak" do
>
>> content IO.read("/httpfile")
>
>> only_if {File.exists?("/httpfile")}
>
>> end
>
>>
>
>> I
>
>
>
>
>
>
>
>
--
>
Opscode, Inc.
>
Adam Jacob, Chief Product Officer
>
T: (206) 619-7151 E:
>
>
--
Alex Kiernan
- [chef] Re: Re: Re: Re: Re: resource for copy local file?, Alex Kiernan, 09/09/2011
Archive powered by MHonArc 2.6.16.