【问题标题】:How do I configure a berks API server?如何配置 berks API 服务器?
【发布时间】:2015-06-15 00:07:33
【问题描述】:

我想在我的基础架构中实现 Berks API,包括 Jenkins、Git 服务器和 Chef 12 Enterprise 服务器。根据 Berkshelf 方式,每本食谱都在 Git 服务器中它自己的存储库中。基本上,我只希望我的顶级 Berksfile 仅包含角色说明书,然后“让”Berkshelf 从我的 Git 服务器中提取传递依赖项。

我已经阅读了关于服务器安装的Berks API README,但是我应该在“哪里”安装说明书?我是否将其安装在我的 Git 服务器上?我已经阅读了 Chef 服务器已准备好 Berks API,但我并没有从那里提取我的食谱,而是在那里“上传”它们。

请帮助解决我的困惑。

更新 2

我可以通过将 Berksfile 中的源代码行从 https 更改为 http 来修复我的 SSL 错误,即

source "http://myserver.domain.com:26200"

更新

我已经通过 ~/.berkshelf/api-server/config.json 中的以下 config.json 文件配置了我的 berks-api 服务器的端点

{
  "endpoints": [
    {
      "type": "chef_server",
       "options": {
       "url": "https://myserver.domain.com/organizations/berks-api",
       "client_name": "jenkins",
       "client_key": "/etc/berkshelf/api-server/jenkins.pem",
       "ssl_verify" : false
      }
    }
  ]
}

然后我运行 berks-api,并在我的终端上看到前几行,所以我知道它正在运行

[2015-04-14T18:49:12.737950 #10033] INFO -- : Cache manager starting...
I, [2015-04-14T18:49:12.738207 #10033] INFO -- : Loading save from /root/.berkshelf/api-server/cerch
W, [2015-04-14T18:49:12.739368 #10033] WARN -- : Endpoints in config have changed - invalidating cache
I, [2015-04-14T18:49:12.739465 #10033] INFO -- : Cache contains 0 items
I, [2015-04-14T18:49:12.740341 #10033] INFO -- : Cache Builder starting...
I, [2015-04-14T18:49:12.846975 #10033] INFO -- : REST Gateway listening on 0.0.0.0:26200
I, [2015-04-14T18:49:12.887143 #10033] INFO -- : Processing chef_server: https://myserver.domain.com/organizations/berks-api
I, [2015-04-14T18:49:12.963418 #10033] INFO -- : Found 25 cookbooks from chef_server: https://myserver.domain.com/organizations/berks-api
I, [2015-04-14T18:49:12.964527 #10033] INFO -- : Processing metadata for 25 cookbooks with 0 remaining on chef_server: https://myserver.domain.com/organizations/berks-api

我的一本食谱上的 Berksfile 中有这一行

source "https://myserver.domain.com:26200"

但是,当我在我的一个 Chef 工作站上安装 berks 时,我得到了

Fetching cookbook index from https://myserver.domain.com:26200...
/opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:920:in `connect': SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A (Faraday::SSLError)
from /opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
from /opt/chef/embedded/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
from /opt/chef/embedded/lib/ruby/2.1.0/timeout.rb:101:in `call'
from /opt/chef/embedded/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
from /opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:920:in `connect'
from /opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
from /opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:852:in `start'
from /opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:1369:in `request'
from /opt/chef/embedded/lib/ruby/2.1.0/net/http.rb:1128:in `get'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:80:in `perform_request'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40:in `block in call'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32:in `call'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/request/retry.rb:110:in `call'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/connection.rb:140:in `get'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-api-client-1.2.1/lib/berkshelf/api_client/connection.rb:62:in `universe'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-3.2.3/lib/berkshelf/source.rb:22:in `build_universe'
from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-3.2.3/lib/berkshelf/installer.rb:21:in `block (2 levels) in build_universe'

【问题讨论】:

    标签: chef-infra berkshelf berksfile


    【解决方案1】:

    我建议调查pipeline cookbook。它演示了一个 Jenkins 解决方案,我认为它证明您不需要 Berkshelf API 服务器。

    说明书创建了一个非常标准的 Jenkins 作业,它使用 Berkshelf 下载说明书并上传您的角色、数据包和环境(来自您的 chef repo)。烹饪书的聪明之处在于,它还会自动为您在 GIT 中的烹饪书生成特殊的烹饪书作业,并针对它们运行诸如 foodcritic 和 test kitchen 等有用的工具。

    希望它对你有用。

    更新

    Berkshelf API 是一个索引器。如果您决定使用它,那么您需要设置一个额外的 Chef 服务器/组织来保存说明书并在 Berkshelf API 配置中进行配置。然后,您的 Jenkins 构建服务器会将食谱更改加载到此 Chef 服务器中,因此它就像您“已发布”的食谱的二进制存储库一样。

    Berkshelf 客户端能够从 API 服务器检索每本说明书的位置,但仍负责实际下载。对我来说,这是一个“陷阱”。我的说明书加载过程的含义是我需要两个配置文件:

    berks install -c ~/.berkshelf/config-cookbooks.json
    berks upload 
    

    默认 berkshelf 配置文件指向我的目标厨师服务器,但我需要第二个配置文件,其中包含保存我的食谱的厨师服务器的凭据。

    更复杂的设置(可能会避免上述凭据问题)是将厨师服务器换成厨师超市的本地实例。

    https://github.com/opscode-cookbooks/supermarket

    总之,我认为这不是你真正想要的。它类似于我个人使用的工作流程,但大多数人会认为它过于复杂。

    【讨论】:

    • 谢谢,但这并不能回答我的问题:(
    • @ChrisF 答案已更新。我个人犯的错误之一是误解了 Berkshelf API 的功能。它是一个索引器,不包含食谱版本,因为您需要额外的基础架构。
    • 我现在明白了。所以我真的有两个独立的进程,涉及两个不同的 Chef 服务器。第一个过程使用一个 Berksfile,从 git 存储库(berks install)下载所有食谱,并将它们上传到充当 Berks API 的 Chef 服务器(berks 上传)。第二个过程使用不同的 Berksfile,然后将从 Berks-API/Chef 服务器(berks 安装)下载所需的说明书,并将它们上传到用于实际产品安装的不同 Chef 服务器。 “不同的 Chef 服务器”当然可以表示同一 Chef 服务器上的不同组织。我明白了吗?
    • 是的,两个厨师服务员(或两个厨师组织)。一个用作说明书构建过程的一部分并存储说明书版本。这是在 berkshelf API 配置中配置的主厨服务器。第二个厨师服务器是您的节点所连接的服务器。我确实警告过你,“管道”食谱工作流程更简单。
    • 好的,我已经被警告过了,但我仍然想追求 Berkshelf 解决方案,如果有什么要学习的话。我在我的 Chef 12 服务器上建立了一个 berks-api 组织,并且有一个 Berksfile,它有一个“source berks-api-server.domain.com/organizations/berks-api”行。现在,当我进行 berks 安装时,我得到“从源中检索 Universe 时出错:berks-api-server.domain.com/organizations/berks-api。”我缺少一个配置步骤
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 2016-03-20
    相关资源
    最近更新 更多