Knife.rb cookbook_path with Berkshelf


#1

All -

I’m trying to add my Berkshelf cookbooks location to the cookbook_path in knife.rb without much success.

Here’s what I have:


cookbook_path ["/Users/mhn/.berkshelf/cookbooks", “#{current_dir}/…/cookbooks”]

When I try to run

knife cookbook upload ome_jboss

for example, I get an error saying that cookbook one_jboss could not be found in my cookbook path. ome_jboss does exist at /Users/mhn/.berkshelf/cookbooks. I’ve tried putting the Berkshelf path specification first and last in the array, and I’ve tried it just by itself there, all with the same result.

Thanks,
Mark

mark nichols | (t|a.n) @zanshin | (w) zanshin.net | (gpg key) 53445200


#2

berkshelf stores the cookbooks in a directory which has their version . So
sudo cookbook will be stored as sudo-1.0.0. This wont work with chef, as it
expects a directory named sudo. You need to invoke berkshelf install --path
and use as your cookbook_path.

Also, you might not need any other entries in cookbook_path as berks can
manage local repos as well, and berks install will pull them (as long as
you version bump religiously). Other wise, use multiple entries, with your
own cookbook dir in the beginning (to give it higher precedence in search
path)

On Wed, Aug 21, 2013 at 11:53 AM, Mark H. Nichols chef@zanshin.net wrote:

All -

I’m trying to add my Berkshelf cookbooks location to the cookbook_path in
knife.rb without much success.

Here’s what I have:


cookbook_path ["/Users/mhn/.berkshelf/cookbooks",
"#{current_dir}/…/cookbooks"]

When I try to run

knife cookbook upload ome_jboss

for example, I get an error saying that cookbook one_jboss could not be
found in my cookbook path. ome_jboss does exist at
/Users/mhn/.berkshelf/cookbooks. I’ve tried putting the Berkshelf path
specification first and last in the array, and I’ve tried it just by itself
there, all with the same result.

Thanks,
Mark

mark nichols | (t|a.n) @zanshin | (w) zanshin.net | (gpg key) 53445200


#3

On Aug 21, 2013, at 2:02 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

berkshelf stores the cookbooks in a directory which has their version . So sudo cookbook will be stored as sudo-1.0.0. This wont work with chef, as it expects a directory named sudo. You need to invoke berkshelf install --path and use as your cookbook_path.

Okay. I see that what I think of as ‘ome_jboss’ is actually ‘one_jboss_23489h-daa338348c4d14e9e1abe693ecc98dfc6d412f5c’. Actually there are several ome_jboss cookbook versions, each with a different sha. All of our private cookbooks are individual Git repositories on GitHub and were populated into .berkshelf/cookbooks via a line like this in a Berksfile:

cookbook ‘ome_jboss’, github: ‘kstateome/ome_jboss’, protocol: :ssh

In reading the Berkshelf documentation I don’t see a way to specify something other than the Git SHA to be appended to the resulting directory name. Do I need to tag with the current version number all of our private cookbooks so that I can pull those specific versions into Berkshelf?

Thanks,
Mark


#4

You can always download the cookbook manually and tell github to use the
local copy:

cookbook ‘’, path: ‘/absolute/path/to/the/cookbook’

On Wed, Aug 21, 2013 at 3:31 PM, Mark H. Nichols chef@zanshin.net wrote:

On Aug 21, 2013, at 2:02 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

berkshelf stores the cookbooks in a directory which has their version .
So sudo cookbook will be stored as sudo-1.0.0. This wont work with chef, as
it expects a directory named sudo. You need to invoke berkshelf install
–path and use as your cookbook_path.

Okay. I see that what I think of as ‘ome_jboss’ is actually
’one_jboss_23489h-daa338348c4d14e9e1abe693ecc98dfc6d412f5c’. Actually there
are several ome_jboss cookbook versions, each with a different sha. All of
our private cookbooks are individual Git repositories on GitHub and were
populated into .berkshelf/cookbooks via a line like this in a Berksfile:

cookbook ‘ome_jboss’, github: ‘kstateome/ome_jboss’, protocol: :ssh

In reading the Berkshelf documentation I don’t see a way to specify
something other than the Git SHA to be appended to the resulting directory
name. Do I need to tag with the current version number all of our private
cookbooks so that I can pull those specific versions into Berkshelf?

Thanks,
Mark


#5

you can specify any valid git rev iirc (i.e. branch, sha, tag etc), since
berks uses the ~/.berkshelf/cookbooks as cache directory, it will store all
the versions that you have specified in your berksfile.

On Wed, Aug 21, 2013 at 12:31 PM, Mark H. Nichols chef@zanshin.net wrote:

On Aug 21, 2013, at 2:02 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

berkshelf stores the cookbooks in a directory which has their version .
So sudo cookbook will be stored as sudo-1.0.0. This wont work with chef, as
it expects a directory named sudo. You need to invoke berkshelf install
–path and use as your cookbook_path.

Okay. I see that what I think of as ‘ome_jboss’ is actually
’one_jboss_23489h-daa338348c4d14e9e1abe693ecc98dfc6d412f5c’. Actually there
are several ome_jboss cookbook versions, each with a different sha. All of
our private cookbooks are individual Git repositories on GitHub and were
populated into .berkshelf/cookbooks via a line like this in a Berksfile:

cookbook ‘ome_jboss’, github: ‘kstateome/ome_jboss’, protocol: :ssh

In reading the Berkshelf documentation I don’t see a way to specify
something other than the Git SHA to be appended to the resulting directory
name. Do I need to tag with the current version number all of our private
cookbooks so that I can pull those specific versions into Berkshelf?

Thanks,
Mark


#6

On Aug 21, 2013, at 2:34 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

you can specify any valid git rev iirc (i.e. branch, sha, tag etc), since berks uses the ~/.berkshelf/cookbooks as cache directory, it will store all the versions that you have specified in your berksfile.

I have successfully used branch before. However the resulting directory under .berkshelf/cookbooks includes the Git SHA as part of the name. Over time I’ve accumulated several versions of the same cookbook that all have different SHAs as a part of the directory name. What I can’t figure out is how to get a more meaningful name created via Berkshelf when I pull the cookbook from Github. Having to specify knife cookbook upload ome_jboss-daa338348c4d14e9e1abe693ecc98dfc6d412f5c isn’t going to be a lot of fun.


#7

this is expected right? When you say branch you it expand to the HEAD of
that branch, which might be different revision at different point in time.
If you dont want that, either use tag or revision

I am not getting why you want a meaningful name in the cache directory?
berk install -p foo will copy over the correct (as specified by
berksfile) version in foo. You can alias point cookbook_dir to a vendor
directory, and alias knife upload to invoke (berks install -p vendor &&
knife cookbook upload) berks install ,

On Wed, Aug 21, 2013 at 12:40 PM, Mark H. Nichols chef@zanshin.net wrote:

On Aug 21, 2013, at 2:34 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

you can specify any valid git rev iirc (i.e. branch, sha, tag etc),
since berks uses the ~/.berkshelf/cookbooks as cache directory, it will
store all the versions that you have specified in your berksfile.

I have successfully used branch before. However the resulting directory
under .berkshelf/cookbooks includes the Git SHA as part of the name. Over
time I’ve accumulated several versions of the same cookbook that all have
different SHAs as a part of the directory name. What I can’t figure out is
how to get a more meaningful name created via Berkshelf when I pull the
cookbook from Github. Having to specify knife cookbook upload ome_jboss-daa338348c4d14e9e1abe693ecc98dfc6d412f5c isn’t going to be a lot
of fun.


#8

On Aug 21, 2013, at 2:47 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

this is expected right? When you say branch you it expand to the HEAD of that branch, which might be different revision at different point in time. If you dont want that, either use tag or revision

I am not getting why you want a meaningful name in the cache directory?

I can’t run knife cookbook upload ome_jboss since berks added the Git SHA to the directory name in .berkshelf/cookbooks.

berk install -p foo will copy over the correct (as specified by berksfile) version in foo. You can alias point cookbook_dir to a vendor directory, and alias knife upload to invoke (berks install -p vendor && knife cookbook upload) berks install ,

It looks like your alias was cut off. I don’t follow what you intend.

On Wed, Aug 21, 2013 at 12:40 PM, Mark H. Nichols chef@zanshin.net wrote:

On Aug 21, 2013, at 2:34 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

you can specify any valid git rev iirc (i.e. branch, sha, tag etc), since berks uses the ~/.berkshelf/cookbooks as cache directory, it will store all the versions that you have specified in your berksfile.

I have successfully used branch before. However the resulting directory under .berkshelf/cookbooks includes the Git SHA as part of the name. Over time I’ve accumulated several versions of the same cookbook that all have different SHAs as a part of the directory name. What I can’t figure out is how to get a more meaningful name created via Berkshelf when I pull the cookbook from Github. Having to specify knife cookbook upload ome_jboss-daa338348c4d14e9e1abe693ecc98dfc6d412f5c isn’t going to be a lot of fun.


#9

The intention with Berkshelf is to use it to upload cookbooks. So, instead
of knife, use:

berks upload ome_jboss

On Wed, Aug 21, 2013 at 4:03 PM, Mark H. Nichols chef@zanshin.net wrote:

On Aug 21, 2013, at 2:47 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

this is expected right? When you say branch you it expand to the HEAD of
that branch, which might be different revision at different point in time.
If you dont want that, either use tag or revision

I am not getting why you want a meaningful name in the cache directory?

I can’t run knife cookbook upload ome_jboss since berks added the Git
SHA to the directory name in .berkshelf/cookbooks.

berk install -p foo will copy over the correct (as specified by
berksfile) version in foo. You can alias point cookbook_dir to a vendor
directory, and alias knife upload to invoke (berks install -p vendor &&
knife cookbook upload) berks install ,

It looks like your alias was cut off. I don’t follow what you intend.

On Wed, Aug 21, 2013 at 12:40 PM, Mark H. Nichols chef@zanshin.netwrote:

On Aug 21, 2013, at 2:34 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

you can specify any valid git rev iirc (i.e. branch, sha, tag etc),
since berks uses the ~/.berkshelf/cookbooks as cache directory, it will
store all the versions that you have specified in your berksfile.

I have successfully used branch before. However the resulting directory
under .berkshelf/cookbooks includes the Git SHA as part of the name. Over
time I’ve accumulated several versions of the same cookbook that all have
different SHAs as a part of the directory name. What I can’t figure out is
how to get a more meaningful name created via Berkshelf when I pull the
cookbook from Github. Having to specify knife cookbook upload ome_jboss-daa338348c4d14e9e1abe693ecc98dfc6d412f5c isn’t going to be a lot
of fun.