Resolve recursive git cookbook dependencies with Berkshelf

送分小仙女□ 提交于 2019-12-01 03:04:19

问题


tl;dr version: Is Berkshelf able to resolve recursive dependencies within Git-based cookbooks and if yes - how?

I try to manage my Chef cookbook dependencies with Berkshelf. The cookbooks are all stored in internal Git repositories. The dependencies are as follows:

env_dockerhub_dev 
  >>depends on>> app_dockerhub 
    >>depends on>> app_docker

The main Berksfile in my project looks like this:

source "https://supermarket.chef.io"

cookbook "env_dockerhub_dev", git: "git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git"

The env_dockerhub_dev cookbook has a metadata.rb like this:

name             'env_dockerhub_dev'
...
depends          'app_dockerhub'
depends          'base_ubuntu'

and a Berksfile like this:

source "https://supermarket.chef.io"

cookbook "app_dockerhub", git: "git@URL_TO_GIT_SERVER/chef_app_dockerhub.git"
cookbook "base_ubuntu", git: "git@URL_TO_GIT_SERVER/chef_base_ubuntu.git"

When I now run berks install I get the following error message:

Resolving cookbook dependencies...

Fetching 'env_dockerhub_dev' from git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git (at master)
Fetching cookbook index from https://supermarket.chef.io...
Unable to satisfy constraints on package app_dockerhub, which does not exist, due to solution constraint (env_dockerhub_dev = 0.1.0). Solution constraints that may result in a constraint on app_dockerhub:     [(env_dockerhub_dev = 0.1.0) -> (app_dockerhub >= 0.0.0)]
Missing artifacts: app_dockerhub,base_ubuntu
Demand that cannot be met: (env_dockerhub_dev = 0.1.0)
Unable to find a solution for demands: env_dockerhub_dev (0.1.0)

I can fix the problem, when I add all the Git URLs for all my internal cookbooks into the "main" Berksfile (the Berksfile in the root of my project) like this:

source "https://supermarket.chef.io"

# the main cookbook
cookbook "env_dockerhub_dev", git: "git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git"

# the cookbooks that are "recursively" 
cookbook "app_dockerhub", git: "git@gURL_TO_GIT_SERVER/chef_app_dockerhub.git"
cookbook "app_docker", git: "git@URL_TO_GIT_SERVER/chef_app_docker.git"

Anyhow - I think this should not be the solution for this problem.

Thx a lot for your help!


回答1:


Ok - reading this https://github.com/berkshelf/berkshelf/pull/304 I think I found out that this is really not possible. Still don't get why - but that's another issue :-)

As mentioned in my question, a solution is to add all cookbook dependencies and their git URL in the toplevel Berksfile:

source "https://supermarket.chef.io"

# the main cookbook
cookbook "env_dockerhub_dev", git: "git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git"

# other cookbook dependencies (resolved recursively)
cookbook "app_dockerhub", git: "git@gURL_TO_GIT_SERVER/chef_app_dockerhub.git"
cookbook "app_docker", git: "git@URL_TO_GIT_SERVER/chef_app_docker.git"



回答2:


My countermeasure is to use a Berkshelf API server. Instead of loading the repositories from the Git repos, I am pointing the Berks API server to our Chef Server.



来源:https://stackoverflow.com/questions/29603281/resolve-recursive-git-cookbook-dependencies-with-berkshelf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!