用Berkshelf解析递归的git cookbook依赖关系 [英] Resolve recursive git cookbook dependencies with Berkshelf

查看:204
本文介绍了用Berkshelf解析递归的git cookbook依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tl; dr版本: Berkshelf是否可以在基于Git的食谱中解析递归依赖关系,如果是 - 如何?

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

我尝试用Berkshelf管理我的厨师菜谱依赖。这些食谱都存储在内部的Git存储库中。依赖关系如下:

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

我的项目中的主Berksfile如下所示:

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"

env_dockerhub_dev cookbook有一个 metadata.rb 像这样:

The env_dockerhub_dev cookbook has a metadata.rb like this:

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

Berksfile 像这样:

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"

当我现在运行 berks install 我收到以下错误消息:

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)

我可以解决这个问题,当我添加所有我的Git URL内部的菜谱进入主要Berksfile(在我项目的根目录中的Berksfile)如下:

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很多为您的帮助!

Thx a lot for your help!

推荐答案

Ok - 阅读此 https://github.com/berkshelf/berkshelf/pull/304 我想我发现这是不可能的。仍然不明白为什么 - 但这是另一个问题: - )

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 :-)

正如我的问题所提到的,一个解决方案是将所有的cookbook依赖项及其git URL添加到toplevel Berksfile:

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"

这篇关于用Berkshelf解析递归的git cookbook依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆