- From: Joshua Timberman <
>
- To:
- Subject: [chef] Re: How can we use the attribute "path" in cookbook_file ?
- Date: Thu, 22 Sep 2011 23:00:19 -0700
Hello!
On Thu, Sep 22, 2011 at 4:36 AM, Ilya
<
>
wrote:
>
We have a problem. We are trying to copy a file from one folder to
>
another, using "cookbook_file" using the attribute "path". Example code:
>
>
cookbook_file "/opt/server.tgz" do
>
path "/mnt/server/"
>
source "server.tgz"
>
end
"path" is the "name parameter attribute" for cookbook_file,
remote_file, template and file resources, as described in the Resource
documentation[0]. The name is the string following the resource type.
Above, this is "/opt/server.tgz".
To use the cookbook_file resource, you put the source file in the
'files/default' directory of the cookbook where the recipe is located
and Chef will retrieve it from the server to put into the path
location when it configures the resource on the node.
cookbook_file "/mnt/server/server.tgz" do
source "server.tgz"
end
Will put it in the /mnt/server location as long as the source is in
the cookbook.
If you want to copy a file's contents from one location to another,
you can use the file resource with the content parameter that calls
the Ruby IO object's read method.
file "/mnt/server/server.tgz" do
content IO.read("/opt/server.tgz")
end
The file "/opt/server.tgz" must exist during the compile phase[1].
[0]:
http://wiki.opscode.com/display/chef/Resources
[1]:
http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run
--
Opscode, Inc
Joshua Timberman, Director of Training and Services
IRC, Skype, Twitter, Github: jtimberman
Archive powered by MHonArc 2.6.16.