# My first chef cookbook

**URL:** <https://discourse.chef.io/t/my-first-chef-cookbook/1454>\
**Category:** Chef Infra (archive)\
**Created:** [June 28, 2010, 11:46pm UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454 "2010-06-28T23:46:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Kang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/pablo_kang/32/894_2.png) [@Pablo\_Kang](https://discourse.chef.io/u/Pablo_Kang)\
**Post date:** [June 28, 2010, 11:46pm UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/1 "2010-06-28T23:46:04Z")

</div>

Wrote a blog post on my experience writing my first cookbook. It takes a  
step by step approach. Thought it might be useful for folks just getting  
their feet wet like I am.

[http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/](http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/)

Thanks for the great product, Opscode team!

pablo

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ringods/32/154_2.png) [@ringods](https://discourse.chef.io/u/ringods)\
**Post date:** [June 29, 2010, 6:46am UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/2 "2010-06-29T06:46:44Z")

</div>

Pablo,

On 29 June 2010 01:46, Pablo Kang [pablokang@gmail.com](mailto:pablokang@gmail.com) wrote:

> Wrote a blog post on my experience writing my first cookbook. It takes a  
> step by step approach. Thought it might be useful for folks just getting  
> their feet wet like I am.  
> [http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/](http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/)

As another user of Chef, I suggest an improvement to your cookbook.  
Your openfire default recipe contains this snippet:

execute "wget" do  
tarball\_url = "[http://www.igniterealtime.org/downloadServlet?filename=openfire/#{tarball}](http://www.igniterealtime.org/downloadServlet?filename=openfire/#%7Btarball%7D)"  
cwd "/tmp"  
command "wget #{tarball\_url}"  
creates "/tmp/#{tarball}"  
action :run  
end

Retrieving a remote file is better done by the "remote\_file" (1) resource:

remote\_file "/tmp/#{tarball}" do  
source "[http://www.igniterealtime.org/downloadServlet?filename=openfire/#{tarball}](http://www.igniterealtime.org/downloadServlet?filename=openfire/#%7Btarball%7D)"  
mode "0644"  
checksum "08da002l" # A SHA256 (or portion thereof) of the file.  
end

(1) [http://wiki.opscode.com/display/chef/Resources#Resources-RemoteFile](http://wiki.opscode.com/display/chef/Resources#Resources-RemoteFile)

Cheers,

Ringo

---

<div class="post-metadata">

**Author:** ![anon49489642](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon49489642](https://discourse.chef.io/u/anon49489642)\
**Post date:** [June 29, 2010, 7:08am UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/3 "2010-06-29T07:08:07Z")

</div>

That's a neat improvement.

Is there a resource that can go further (ie. configure, compile and  
install)?

- Mike

On Tue, Jun 29, 2010 at 4:46 PM, Ringo De Smet [ringo.desmet@gmail.com](mailto:ringo.desmet@gmail.com)wrote:

> Pablo,
> 
> On 29 June 2010 01:46, Pablo Kang [pablokang@gmail.com](mailto:pablokang@gmail.com) wrote:
> 
> > Wrote a blog post on my experience writing my first cookbook. It takes a  
> > step by step approach. Thought it might be useful for folks just getting  
> > their feet wet like I am.  
> > [http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/](http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/)
> 
> As another user of Chef, I suggest an improvement to your cookbook.  
> Your openfire default recipe contains this snippet:
> 
> execute "wget" do  
> tarball\_url = "  
> [http://www.igniterealtime.org/downloadServlet?filename=openfire/#{tarball}](http://www.igniterealtime.org/downloadServlet?filename=openfire/#%7Btarball%7D)  
> "  
> cwd "/tmp"  
> command "wget #{tarball\_url}"  
> creates "/tmp/#{tarball}"  
> action :run  
> end
> 
> Retrieving a remote file is better done by the "remote\_file" (1) resource:
> 
> remote\_file "/tmp/#{tarball}" do  
> source "  
> [http://www.igniterealtime.org/downloadServlet?filename=openfire/#{tarball}](http://www.igniterealtime.org/downloadServlet?filename=openfire/#%7Btarball%7D)  
> "  
> mode "0644"  
> checksum "08da002l" # A SHA256 (or portion thereof) of the file.  
> end
> 
> (1) [http://wiki.opscode.com/display/chef/Resources#Resources-RemoteFile](http://wiki.opscode.com/display/chef/Resources#Resources-RemoteFile)
> 
> Cheers,
> 
> Ringo

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ringods/32/154_2.png) [@ringods](https://discourse.chef.io/u/ringods)\
**Post date:** [June 29, 2010, 7:15am UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/4 "2010-06-29T07:15:53Z")

</div>

Mike,

On 29 June 2010 09:08, Mike Bailey [mike@bailey.net.au](mailto:mike@bailey.net.au) wrote:

> That's a neat improvement.  
> Is there a resource that can go further (ie. configure, compile and  
> install)?

While such a scenario is feasible to implement, I don't go this route.  
I use a build machine to make a package out of what you want to  
configure/compile/install. Then deploy that package to a local package  
repository. The compilation only needs to be done once and repetitive  
installation via Chef is much faster.

Ringo

---

<div class="post-metadata">

**Author:** ![anon49489642](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon49489642](https://discourse.chef.io/u/anon49489642)\
**Post date:** [June 29, 2010, 7:22am UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/5 "2010-06-29T07:22:10Z")

</div>

On Tue, Jun 29, 2010 at 5:15 PM, Ringo De Smet [ringo.desmet@gmail.com](mailto:ringo.desmet@gmail.com)wrote:

> While such a scenario is feasible to implement, I don't go this route.  
> I use a build machine to make a package out of what you want to  
> configure/compile/install.

I agree that this is a better strategy. I only wish I was always  
so disciplined. 🙂

- Mike

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ringods/32/154_2.png) [@ringods](https://discourse.chef.io/u/ringods)\
**Post date:** [June 29, 2010, 7:45am UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/6 "2010-06-29T07:45:22Z")

</div>

Mike,

On 29 June 2010 09:22, Mike Bailey [mike@bailey.net.au](mailto:mike@bailey.net.au) wrote:

> I agree that this is a better strategy. I only wish I was always  
> so disciplined. 🙂

I am currently in the role of Release Manager, and without this  
discipline and Chef, I would be drowning! 🙂

Chef is used for the configuration of all the various types of Hudson  
(1) build slaves. Setting up additional slaves goes quite fast:  
a. existing setup: launch base VDI with Chef client installed,  
register and assign the proper role(s)  
b. new setup: in a few hours I can have a recipe written or updated  
and tested, and then I am back at step a.

Next to that, I am able to offer pre-configured virtual machines to  
our developers by using Chef in combination with Vagrant (2).

(1) [http://hudson-ci.org](http://hudson-ci.org)  
(2) [http://vagrantup.com](http://vagrantup.com)

Ringo

---

<div class="post-metadata">

**Author:** ![Pablo\_Kang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/pablo_kang/32/894_2.png) [@Pablo\_Kang](https://discourse.chef.io/u/Pablo_Kang)\
**Post date:** [June 29, 2010, 2:26pm UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/7 "2010-06-29T14:26:31Z")

</div>

Hi Ringo,

Someone replied on the post with the same comment. I completely missed that  
resource! I'll be sure to update the blog later today. Thanks for the  
pointer!

pablo

On Mon, Jun 28, 2010 at 11:46 PM, Ringo De Smet [ringo.desmet@gmail.com](mailto:ringo.desmet@gmail.com)wrote:

> Pablo,
> 
> On 29 June 2010 01:46, Pablo Kang [pablokang@gmail.com](mailto:pablokang@gmail.com) wrote:
> 
> > Wrote a blog post on my experience writing my first cookbook. It takes a  
> > step by step approach. Thought it might be useful for folks just getting  
> > their feet wet like I am.  
> > [http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/](http://blazingcloud.net/2010/06/28/our-first-chef-cookbook/)
> 
> As another user of Chef, I suggest an improvement to your cookbook.  
> Your openfire default recipe contains this snippet:
> 
> execute "wget" do  
> tarball\_url = "  
> [http://www.igniterealtime.org/downloadServlet?filename=openfire/#{tarball}](http://www.igniterealtime.org/downloadServlet?filename=openfire/#%7Btarball%7D)  
> "  
> cwd "/tmp"  
> command "wget #{tarball\_url}"  
> creates "/tmp/#{tarball}"  
> action :run  
> end
> 
> Retrieving a remote file is better done by the "remote\_file" (1) resource:
> 
> remote\_file "/tmp/#{tarball}" do  
> source "  
> [http://www.igniterealtime.org/downloadServlet?filename=openfire/#{tarball}](http://www.igniterealtime.org/downloadServlet?filename=openfire/#%7Btarball%7D)  
> "  
> mode "0644"  
> checksum "08da002l" # A SHA256 (or portion thereof) of the file.  
> end
> 
> (1) [http://wiki.opscode.com/display/chef/Resources#Resources-RemoteFile](http://wiki.opscode.com/display/chef/Resources#Resources-RemoteFile)
> 
> Cheers,
> 
> Ringo

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ringods/32/154_2.png) [@ringods](https://discourse.chef.io/u/ringods)\
**Post date:** [June 29, 2010, 2:36pm UTC](https://discourse.chef.io/t/my-first-chef-cookbook/1454/8 "2010-06-29T14:36:40Z")

</div>

On 29 June 2010 16:26, Pablo Kang [pablokang@gmail.com](mailto:pablokang@gmail.com) wrote:

> Someone replied on the post with the same comment. I completely missed that  
> resource! I'll be sure to update the blog later today. Thanks for the  
> pointer!

And I must have missed that comment. 🙂

R.
