copying local file after compile time with file resource in CHEF -


trying copy file locally doesn't exist @ compile time. example:

remote_file "/httpfile"    source "http://wiki.opscode.com/display/chef/home"    mode "0666" end file "/httpfile.bak"    content io.read("/httpfile")    only_if {file.exists?("/httpfile")} end 

this code give error: no such file or directory - eventough only_if being used. because io.read happens @ compilation time before file makes system. (4 year old email - http://lists.opscode.com/sympa/arc/chef/2011-08/msg00182.html)

is there way force content io.read("/httpfile") executed @ execution time? or better way now?

thanks

you should able use lazy evaluation take care of this. believe syntax this:

remote_file "/httpfile"    source "https://docs.chef.io/"    mode "0666" end file "/httpfile.bak"    lazy { content io.read("/httpfile") }    only_if {file.exists?("/httpfile")} end 

Popular posts from this blog