Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

Don't remove cookbook paths, just add to list berkshelf cookbook path #9

Closed
wants to merge 3 commits into from

Conversation

le0pard
Copy link

@le0pard le0pard commented Mar 30, 2013

Don't remove cookbook paths, just add to list berkshelf cookbook path.

The problem what I can have also own directories with cookbooks:

config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["site-cookbooks", "cookbooks"]
end

berkshelf should add own directory to this list (shouldn't remove my list).

@reset
Copy link
Contributor

reset commented Mar 31, 2013

It's a known issue right now that you can't manipulate the cookbooks_path configuration value, but it was a conscious choice.

The problem is that the value of cookbooks_path contains ./cookbooks by default. If any directories are not present which the configuration specifies, then the Vagrant run will fail.

The suggested way to operate with Berkshelf is to NOT have a "cookbooks" directory at all.

@le0pard
Copy link
Author

le0pard commented Mar 31, 2013

Thanks, @reset . But I also need site-cookbooks directory with my custom cookbooks. This is standart directory for Chef Solo - http://matschaffer.github.com/knife-solo/. And right now it is not work without this fix.

@le0pard
Copy link
Author

le0pard commented Mar 31, 2013

And also I set this folders, so I should deside have I "cookbooks" folders or doesn't on my mashine. If I don't have such folder I can write:

chef.cookbooks_path = ["site-cookbooks"]

And its very easy. In berkshelf-vagrant, which installed by "vagrant plugin" and run even if you don't have berkshelf in your project user can fix this problem only by manual editing this file in "~/.vagrant.d" directory (or just remove "berkshelf-vagrant" for valid workflow).

@le0pard
Copy link
Author

le0pard commented Mar 31, 2013

I also added new option "disabled" to berkshelf-vagrant. For now:

Vagrant.configure("2") do |config|
  config.vm.box = "rwpreise64"
  config.berkshelf.disabled = true
end

Will work without any error with installed berkshelf-vagrant and project, which not use berkshelf.

If you wish I can push this change as separate pull request.

@mconigliaro
Copy link

If you want to pull in cookbooks from your local cookbooks directory, you can just add something like this to your Berksfile:

Dir[File.join(File.expand_path('site-cookbooks', File.dirname(__FILE__)), '*')].select { |obj| File.directory?(obj) }.each do |path|
  cookbook File.basename(path), path: path
end

@tmatilai
Copy link
Contributor

You can also use metadata to fetch also all dependencies of your own cookbooks. E.g.:

Dir.glob(File.expand_path('../site-cookbooks/*', __FILE__)).each do |path|
  metadata :path => path
end

Actually this seems to be so common pattern for me that I was thinking if Berkshelf could support it natively. Maybe cookbook_path "site-cookbooks" or something? If @RiotGames thinks it would be a good idea I can even try to implement it.

@ivey
Copy link
Contributor

ivey commented Apr 19, 2013

@tmatilai The Berkshelf way is somewhat antithetical to cookbooks/site-cookbooks, so my initial reaction is that that should be a plugin and not in Berkshelf, and that I'd love to spend 10 minutes in chat convincing you to give up site-cookbooks. Worth having the discussion on adding this as a feature in RiotGames/berkshelf though. (I like @mconigliaro's better, personally, since it uses cookbook and not metadata)

@ivey
Copy link
Contributor

ivey commented Apr 19, 2013

@le0pard as @reset mentioned, the suggested way to operate with Berkshelf is without a "cookbooks" or "site-cookbooks" directory. As a workaround, you can disable the plugin with config.berkshelf.enabled = false and do berks install --path cookbooks or use one of the hacks suggested.

I'm going to close this, but if people feel strongly that we're wrong on this, please feel free to re-open.

Also, happy to discuss in IRC anytime.

@ivey ivey closed this Apr 19, 2013
@tmatilai
Copy link
Contributor

@ivey heh, I might have exaggerated a bit. =)
Definitely I prefer separate cookbook repos, although due to historical reasons and lack of time that is not always the case.

But the case where I still mostly create site-cookbooks are projects that spin up and provision a server for one time use. Or something that is a better fit for chef-solo anyway. In the same repository I have setup for local testing with Vagrant and "the real thing" with knife-solo. Normally these projects have one or a couple of cookbooks that are specific to that project and thus I feel it is more efficient to develop with tight integration.

@MasseGuillaume
Copy link

you can manage it like that.

`cookbook "artifact", path: "/Users/reset/code/artifact-cookbook"``

I think appending is more intuitive

@timruffles
Copy link

"It's a known issue right now that you can't manipulate the cookbooks_path configuration value, but it was a conscious choice."

So I'd suggest at least a warning message if people do set the path? Not great to break a lot of very standard chef setups, especially with loads of people moving from vagrant v1 and v2.

@v-yarotsky
Copy link

I second that warning thing, as this behaviour was totally unexpected for me. Also, a note in the readme and on http://berkshelf.com/ would be quite helpful.

@chino
Copy link

chino commented May 30, 2014

I think everyone is wasting collective cycles with the lack of a clear warning message and/or documentation.

@reset
Copy link
Contributor

reset commented May 30, 2014

Pull requests welcomed on that warning message

@berkshelf berkshelf locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants