My first chef cookbook


#1

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/

Thanks for the great product, Opscode team!

pablo


#2

Pablo,

On 29 June 2010 01:46, Pablo Kang 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/

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}"
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}"
mode "0644"
checksum “08da002l” # A SHA256 (or portion thereof) of the file.
end

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

Cheers,

Ringo


#3

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.comwrote:

Pablo,

On 29 June 2010 01:46, Pablo Kang 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/

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}
"
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}
"
mode "0644"
checksum “08da002l” # A SHA256 (or portion thereof) of the file.
end

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

Cheers,

Ringo


#4

Mike,

On 29 June 2010 09:08, Mike Bailey 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


#5

On Tue, Jun 29, 2010 at 5:15 PM, Ringo De Smet ringo.desmet@gmail.comwrote:

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. :slight_smile:

  • Mike

#6

Mike,

On 29 June 2010 09:22, Mike Bailey mike@bailey.net.au wrote:

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

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

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
(2) http://vagrantup.com

Ringo


#7

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.comwrote:

Pablo,

On 29 June 2010 01:46, Pablo Kang 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/

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}
"
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}
"
mode "0644"
checksum “08da002l” # A SHA256 (or portion thereof) of the file.
end

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

Cheers,

Ringo


#8

On 29 June 2010 16:26, Pablo Kang 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. :slight_smile:

R.