Chef-solo + cookbooks development

I want to develop cookbooks and test them in virtualbox before using
them in production.

Having to upload my cookbooks to the chef server and run chef-client
from virtualbox everytime I make a little change seems like overkill…

So I clone my chef repository in virtualbox, write a solo.rb file to
make my cookbooks_path point to the cookbooks dir of my repository, and
a solo.json file to make it use my recipe.

But when I run chef-solo, it says my cookbook is not found. I suppose it
has something to do with the metadata.json file of my cookbook not being
generated.

So I try to generate the metadata using the knife cookbook metadata
subcommand, but knife now complains about the chef server authentication
(which I didn’t set up since I wanted to use chef-solo).

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Seb

It should be possible to generate the metadata by running a rake task
(Rakefile in the chef-repo parent folder, a seperate git-repository for
containing your cookbooks).

Assuming its still there - as havent used it recently.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

I want to develop cookbooks and test them in virtualbox before using
them in production.

Having to upload my cookbooks to the chef server and run chef-client
from virtualbox everytime I make a little change seems like overkill...

So I clone my chef repository in virtualbox, write a solo.rb file to
make my cookbooks_path point to the cookbooks dir of my repository, and
a solo.json file to make it use my recipe.

But when I run chef-solo, it says my cookbook is not found. I suppose it
has something to do with the metadata.json file of my cookbook not being
generated.

So I try to generate the metadata using the knife cookbook metadata
subcommand, but knife now complains about the chef server authentication
(which I didn't set up since I wanted to use chef-solo).

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Seb

Thanks, Dreamcat4.
I found the rake task, but it is just a wrapper for knife.

It finally worked by creating a .chef/knife.rb file containing:
node_name "virtualbox"

But it keeps complaining about the missing cookbook.
Running chef-client with strace gives the following:

$ sudo strace chef-solo -c solo.rb -l debug 2>&1 | grep cookbooks
open("/cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/site-cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)

I don't know why chef-solo is looking for cookbooks in /cookbooks
and /site-cookbooks.
Please note I have no /etc/chef directory.

Symlinking the cookbooks/site-cookbooks subdirs of my chef repo to /
works.
But that's ugly :slight_smile:

Here is the content of my solo.rb file:
$ cat solo.rb
current_dir = File.dirname(FILE)

file_cache_path current_dir
cookbook_path ["#{current_dir}/cookbooks",
"#{current_dir}/site-cookbooks"]
json_attribs "#{current_dir}/solo.json"
role_path "#{current_dir}/roles"

And my solo.json file:
$ cat solo.json
{
"run_list": [ "recipe[my_cookbook]" ]
}

And I run chef-solo like this:
$ sudo chef-solo -c solo.rb

I downloaded and installed rubygems manually, and I'm using the latest
chef gem.

Any idea ?

Le mercredi 20 octobre 2010 à 13:16 +0100, Dreamcat4 a écrit :

It should be possible to generate the metadata by running a rake task
(Rakefile in the chef-repo parent folder, a seperate git-repository for
containing your cookbooks).

Assuming its still there - as havent used it recently.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

I want to develop cookbooks and test them in virtualbox before using
them in production.

Having to upload my cookbooks to the chef server and run chef-client
from virtualbox everytime I make a little change seems like overkill...

So I clone my chef repository in virtualbox, write a solo.rb file to
make my cookbooks_path point to the cookbooks dir of my repository, and
a solo.json file to make it use my recipe.

But when I run chef-solo, it says my cookbook is not found. I suppose it
has something to do with the metadata.json file of my cookbook not being
generated.

So I try to generate the metadata using the knife cookbook metadata
subcommand, but knife now complains about the chef server authentication
(which I didn't set up since I wanted to use chef-solo).

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Seb

Just eyeballing, it looks like some how 'current_dir' isn't getting
set to what you expect probably because of a nuance of how chef loads
the file.

You can trouble shoot that if you like, but I highly recommend you
check out vagrant.

vagrant is a great way to dev cookbooks.

If you like virtualbox, chances are you'll love vagrant.

I do.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

Thanks, Dreamcat4.
I found the rake task, but it is just a wrapper for knife.

It finally worked by creating a .chef/knife.rb file containing:
node_name "virtualbox"

But it keeps complaining about the missing cookbook.
Running chef-client with strace gives the following:

$ sudo strace chef-solo -c solo.rb -l debug 2>&1 | grep cookbooks
open("/cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/site-cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)

I don't know why chef-solo is looking for cookbooks in /cookbooks
and /site-cookbooks.
Please note I have no /etc/chef directory.

Symlinking the cookbooks/site-cookbooks subdirs of my chef repo to /
works.
But that's ugly :slight_smile:

Here is the content of my solo.rb file:
$ cat solo.rb
current_dir = File.dirname(FILE)

file_cache_path current_dir
cookbook_path ["#{current_dir}/cookbooks",
"#{current_dir}/site-cookbooks"]
json_attribs "#{current_dir}/solo.json"
role_path "#{current_dir}/roles"

And my solo.json file:
$ cat solo.json
{
"run_list": [ "recipe[my_cookbook]" ]
}

And I run chef-solo like this:
$ sudo chef-solo -c solo.rb

I downloaded and installed rubygems manually, and I'm using the latest
chef gem.

Any idea ?

Le mercredi 20 octobre 2010 à 13:16 +0100, Dreamcat4 a écrit :

It should be possible to generate the metadata by running a rake task
(Rakefile in the chef-repo parent folder, a seperate git-repository for
containing your cookbooks).

Assuming its still there - as havent used it recently.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

I want to develop cookbooks and test them in virtualbox before using
them in production.

Having to upload my cookbooks to the chef server and run chef-client
from virtualbox everytime I make a little change seems like overkill...

So I clone my chef repository in virtualbox, write a solo.rb file to
make my cookbooks_path point to the cookbooks dir of my repository, and
a solo.json file to make it use my recipe.

But when I run chef-solo, it says my cookbook is not found. I suppose it
has something to do with the metadata.json file of my cookbook not being
generated.

So I try to generate the metadata using the knife cookbook metadata
subcommand, but knife now complains about the chef server authentication
(which I didn't set up since I wanted to use chef-solo).

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Seb

How Cool!

I am thrilled to find out about Vagrant in this thread. Its going to
be great to have that particular layer already taken care of. Looking
forward to using it pretty much everyday.

VirtualBox <=> RackSpace Cloud Servers anyone?

On Wed, Oct 20, 2010 at 3:58 PM, Andrew Shafer andrew@cloudscaling.com wrote:

Just eyeballing, it looks like some how 'current_dir' isn't getting
set to what you expect probably because of a nuance of how chef loads
the file.

You can trouble shoot that if you like, but I highly recommend you
check out vagrant.

vagrant is a great way to dev cookbooks.

If you like virtualbox, chances are you'll love vagrant.

I do.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

Thanks, Dreamcat4.
I found the rake task, but it is just a wrapper for knife.

It finally worked by creating a .chef/knife.rb file containing:
node_name "virtualbox"

But it keeps complaining about the missing cookbook.
Running chef-client with strace gives the following:

$ sudo strace chef-solo -c solo.rb -l debug 2>&1 | grep cookbooks
open("/cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/site-cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)

I don't know why chef-solo is looking for cookbooks in /cookbooks
and /site-cookbooks.
Please note I have no /etc/chef directory.

Symlinking the cookbooks/site-cookbooks subdirs of my chef repo to /
works.
But that's ugly :slight_smile:

Here is the content of my solo.rb file:
$ cat solo.rb
current_dir = File.dirname(FILE)

file_cache_path current_dir
cookbook_path ["#{current_dir}/cookbooks",
"#{current_dir}/site-cookbooks"]
json_attribs "#{current_dir}/solo.json"
role_path "#{current_dir}/roles"

And my solo.json file:
$ cat solo.json
{
"run_list": [ "recipe[my_cookbook]" ]
}

And I run chef-solo like this:
$ sudo chef-solo -c solo.rb

I downloaded and installed rubygems manually, and I'm using the latest
chef gem.

Any idea ?

Le mercredi 20 octobre 2010 à 13:16 +0100, Dreamcat4 a écrit :

It should be possible to generate the metadata by running a rake task
(Rakefile in the chef-repo parent folder, a seperate git-repository for
containing your cookbooks).

Assuming its still there - as havent used it recently.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

I want to develop cookbooks and test them in virtualbox before using
them in production.

Having to upload my cookbooks to the chef server and run chef-client
from virtualbox everytime I make a little change seems like overkill...

So I clone my chef repository in virtualbox, write a solo.rb file to
make my cookbooks_path point to the cookbooks dir of my repository, and
a solo.json file to make it use my recipe.

But when I run chef-solo, it says my cookbook is not found. I suppose it
has something to do with the metadata.json file of my cookbook not being
generated.

So I try to generate the metadata using the knife cookbook metadata
subcommand, but knife now complains about the chef server authentication
(which I didn't set up since I wanted to use chef-solo).

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Seb

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

On Oct 20, 2010, at 6:02 AM, Sébastien Nicouleaud wrote:

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Have you seen 'shef'? It is Chef in IRB:

http://wiki.opscode.com/display/chef/Getting+Started+with+Shef

You can use it to test recipes in 'solo' or 'client' modes, the latter will connect with the Chef Server so you can test things like search and loading data bags.

That said, Vagrant is nifty too :).


Opscode, Inc
Joshua Timberman, Technical Evangelist
IRC, Skype, Twitter, Github: jtimberman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAky/INUACgkQO97WSdVpzT1B6QCfQJ3t27LZ3Wcfj1RzvJ3Eceyr
f78AnRN9+my+JnExkh8pIm47sBh4YpWK
=zr3C
-----END PGP SIGNATURE-----

Vagrant looks like very helpful project. Thanks for sharing..

On Wed, Oct 20, 2010 at 12:03 PM, Joshua Timberman joshua@opscode.comwrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

On Oct 20, 2010, at 6:02 AM, Sébastien Nicouleaud wrote:

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Have you seen 'shef'? It is Chef in IRB:

http://wiki.opscode.com/display/chef/Getting+Started+with+Shef

You can use it to test recipes in 'solo' or 'client' modes, the latter will
connect with the Chef Server so you can test things like search and loading
data bags.

That said, Vagrant is nifty too :).


Opscode, Inc
Joshua Timberman, Technical Evangelist
IRC, Skype, Twitter, Github: jtimberman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAky/INUACgkQO97WSdVpzT1B6QCfQJ3t27LZ3Wcfj1RzvJ3Eceyr
f78AnRN9+my+JnExkh8pIm47sBh4YpWK
=zr3C
-----END PGP SIGNATURE-----

--
Charles Sullivan
charlie.sullivan@gmail.com

Thank you very much for your help.

I found the vagrant website 5 minutes before reading your email, so your
answer confirms my thoughts.

Cheers,
Seb

Le mercredi 20 octobre 2010 à 08:58 -0600, Andrew Shafer a écrit :

Just eyeballing, it looks like some how 'current_dir' isn't getting
set to what you expect probably because of a nuance of how chef loads
the file.

You can trouble shoot that if you like, but I highly recommend you
check out vagrant.

vagrant is a great way to dev cookbooks.

If you like virtualbox, chances are you'll love vagrant.

I do.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

Thanks, Dreamcat4.
I found the rake task, but it is just a wrapper for knife.

It finally worked by creating a .chef/knife.rb file containing:
node_name "virtualbox"

But it keeps complaining about the missing cookbook.
Running chef-client with strace gives the following:

$ sudo strace chef-solo -c solo.rb -l debug 2>&1 | grep cookbooks
open("/cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/site-cookbooks", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC) = -1 ENOENT (No such file or directory)

I don't know why chef-solo is looking for cookbooks in /cookbooks
and /site-cookbooks.
Please note I have no /etc/chef directory.

Symlinking the cookbooks/site-cookbooks subdirs of my chef repo to /
works.
But that's ugly :slight_smile:

Here is the content of my solo.rb file:
$ cat solo.rb
current_dir = File.dirname(FILE)

file_cache_path current_dir
cookbook_path ["#{current_dir}/cookbooks",
"#{current_dir}/site-cookbooks"]
json_attribs "#{current_dir}/solo.json"
role_path "#{current_dir}/roles"

And my solo.json file:
$ cat solo.json
{
"run_list": [ "recipe[my_cookbook]" ]
}

And I run chef-solo like this:
$ sudo chef-solo -c solo.rb

I downloaded and installed rubygems manually, and I'm using the latest
chef gem.

Any idea ?

Le mercredi 20 octobre 2010 à 13:16 +0100, Dreamcat4 a écrit :

It should be possible to generate the metadata by running a rake task
(Rakefile in the chef-repo parent folder, a seperate git-repository for
containing your cookbooks).

Assuming its still there - as havent used it recently.

2010/10/20 Sébastien Nicouleaud sebastien.nicouleaud@gmail.com:

I want to develop cookbooks and test them in virtualbox before using
them in production.

Having to upload my cookbooks to the chef server and run chef-client
from virtualbox everytime I make a little change seems like overkill...

So I clone my chef repository in virtualbox, write a solo.rb file to
make my cookbooks_path point to the cookbooks dir of my repository, and
a solo.json file to make it use my recipe.

But when I run chef-solo, it says my cookbook is not found. I suppose it
has something to do with the metadata.json file of my cookbook not being
generated.

So I try to generate the metadata using the knife cookbook metadata
subcommand, but knife now complains about the chef server authentication
(which I didn't set up since I wanted to use chef-solo).

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Seb

I'll give Vagrant a try first.
Anyway, thank you for your answer, I'll take a look at shef too.

Seb

Le mercredi 20 octobre 2010 à 11:03 -0600, Joshua Timberman a écrit :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

On Oct 20, 2010, at 6:02 AM, Sébastien Nicouleaud wrote:

So, my question is: is there a way to develop and test cookbooks locally
without any chef server ?
Or am I missing something ?

Have you seen 'shef'? It is Chef in IRB:

http://wiki.opscode.com/display/chef/Getting+Started+with+Shef

You can use it to test recipes in 'solo' or 'client' modes, the latter will connect with the Chef Server so you can test things like search and loading data bags.

That said, Vagrant is nifty too :).


Opscode, Inc
Joshua Timberman, Technical Evangelist
IRC, Skype, Twitter, Github: jtimberman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAky/INUACgkQO97WSdVpzT1B6QCfQJ3t27LZ3Wcfj1RzvJ3Eceyr
f78AnRN9+my+JnExkh8pIm47sBh4YpWK
=zr3C
-----END PGP SIGNATURE-----