Berkshelf & Librarian Chef integration

Andrew Marshall edited this page Dec 21, 2016 · 3 revisions

OK, here we go. The integration touches two commands: knife solo init and knife solo cook (which is also used internally by knife solo bootstrap).

Init command

Currently knife solo init defaults to --berkshelf. Then if berkshelf gem is not installed but Berksfile exists, a warning is issued while cooking.

Rules to select the default action (first one that matches):

  1. If Berksfile or Cheffile is found, default to the corresponding option (prefer Berkshelf). We don't override existing files, so this might only write .chef/knife.rb (relates to #239).
  2. If berkshelf gem is found, default to --berkshelf. I.e. generate Berksfile etc.
  3. If librarian-chef is found, default to --librarian. I.e. generate Cheffile etc.
  4. Default to --no-berkshelf --no-librarian, but maybe display some information to promote the use of one or the other?

You can also turn these integrations off permanently by setting the following options in knife.rb:

knife[:berkshelf] = false
knife[:librarian] = false

Cook command

Berkshelf integration

  • Enabled by default
  • Can be disabled with --no-berkshelf option or knife[:berkshelf] = false configuration
  • Disabled if ./Berksfile is not found
  • Disabled if "berkshelf" gem is not installed
  • Installs/vendors the cookbooks to a directory whose path
    • can be specified with knife[:berkshelf_path] (init sets it to "cookbooks" to follow the convention of "cookbooks" vs. "site-cookbooks")
    • defaults to ~/.berkshelf/knife-solo/<hash>/, where <hash> is calculated from the absolute path of the kitchen
  • Adds the path automatically to cookbook_path array so it will be uploaded and configured to the node

Librarian-Chef integration

  • Enabled by default
  • Can be disabled with --no-librarian option or knife[:librarian] = false configuration
  • Disabled if ./Cheffile is not found
  • Disabled if "librarian-chef" gem is not installed (or "librarian" gem v<0.1.0)
  • Installs/vendors the cookbooks to a directory which is configured to Librarian (defaults to ./cookbooks)
  • Adds the path automatically to cookbook_path array so it will be uploaded and configured to the node

--

Pretty simple, isn't it? ;)

One common problem seems to be that users have berkshelf or librarian-chef gem installed when they run knife solo init which then creates Berksfile or Cheffile even if they do not plan using them. Then they put local cookbooks to ./cookbooks/ directory which gets nuked when knife solo cook runs berks install or librarian-chef install. So it should be pointed out that local cookbooks should be put to ./site-cookbooks/ (or even better, to own repos which are pulled in by Berkshelf/Librarian).

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.