Chef 服务器 12 和客户端 12 - 错误 503:服务不可用

Chef server 12 and Client 12 - Error 503: Service unavailable

我在 Ubuntu 14.04 机器上托管了一个独立的 Chef 服务器。按照 https://learn.chef.io/install-and-manage-your-own-chef-server/linux/ 使用最新版本安装服务器。

当我尝试 bootstrap 一个节点时,它会安装客户端版本 11.x 并运行。但是市面上大部分的cookbook都不兼容client 11,需要client 12.x。

因此,我提供了客户端版本 12.x 作为我的 bootstrap 命令的参数,该命令将客户端版本 12.x 安装到 bootstrap 的节点。但是这次我收到 HTTP 503 - 503 "Service Unavailable" 错误并且无法完成 bootstrapping.

我的工作站 (Mac 10.11.1)

$chef --version
Chef Development Kit Version: 0.10.0
chef-client version: 12.5.1
berks version: 4.0.1
kitchen version: 1.4.2

我的服务器(Ubuntu 14.04.2)

$ dpkg --status chef
Package: chef
Status: install ok installed
Priority: extra
Section: misc
Installed-Size: 107919
Maintainer: Chef Software, Inc. <maintainers@chef.io>
Architecture: amd64
Version: 11.18.12-1
Description: The full stack of chef
License: unknown
Vendor: Omnibus <omnibus@getchef.com>
Homepage: https://www.getchef.com
$ dpkg --status chef-server-core
Package: chef-server-core
Status: install ok installed
Priority: extra
Section: misc
Installed-Size: 1190291
Maintainer: Chef Software, Inc.
Architecture: amd64
Version: 12.3.1-1
Replaces: private-chef
Conflicts: private-chef
Description: The full stack of chef-server
License: unknown
Vendor: Omnibus <omnibus@getchef.com>
Homepage: https://www.chef.io

节点(Ubuntu 14.04.2)

$ chef-client -v
Chef: 12.6.0

这里是错误:

Connecting to <nodes_ip>
10.97.151.49 -----> Existing Chef installation detected
10.97.151.49 Starting the first Chef Client run...
10.97.151.49 Starting Chef Client, version 12.6.0
10.97.151.49 Creating a new client identity for web_app_ubuntu using the validator key.
10.97.151.49 [2015-12-25T14:50:47+00:00] WARN: Failed to register new client, 4 tries remaining
10.97.151.49 [2015-12-25T14:50:47+00:00] WARN: Response: HTTP 503 - 503 "Service Unavailable"
10.97.151.49 [2015-12-25T14:52:26+00:00] WARN: Failed to register new client, 3 tries remaining
10.97.151.49 [2015-12-25T14:52:26+00:00] WARN: Response: HTTP 503 - 503 "Service Unavailable"
10.97.151.49 [2015-12-25T14:54:15+00:00] WARN: Failed to register new client, 2 tries remaining
10.97.151.49 [2015-12-25T14:54:15+00:00] WARN: Response: HTTP 503 - 503 "Service Unavailable"
10.97.151.49 [2015-12-25T14:56:01+00:00] WARN: Failed to register new client, 1 tries remaining
10.97.151.49 [2015-12-25T14:56:01+00:00] WARN: Response: HTTP 503 - 503 "Service Unavailable"
10.97.151.49 [2015-12-25T14:57:48+00:00] WARN: Failed to register new client, 0 tries remaining
10.97.151.49 [2015-12-25T14:57:48+00:00] WARN: Response: HTTP 503 - 503 "Service Unavailable"
10.97.151.49
10.97.151.49 Running handlers:
10.97.151.49 [2015-12-25T14:59:36+00:00] ERROR: Running exception handlers
10.97.151.49 Running handlers complete
10.97.151.49 [2015-12-25T14:59:36+00:00] ERROR: Exception handlers complete
10.97.151.49 Chef Client failed. 0 resources updated in 10 minutes 38 seconds
10.97.151.49 [2015-12-25T14:59:36+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
10.97.151.49 [2015-12-25T14:59:36+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
10.97.151.49 [2015-12-25T14:59:36+00:00] ERROR: undefined method `closed?' for nil:NilClass
10.97.151.49 [2015-12-25T14:59:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

最后在 /var/chef/cache/chef-stacktrace.out

的堆栈跟踪
Generated at 2015-12-25 16:02:37 +0000
NoMethodError: undefined method `closed?' for nil:NilClass
/opt/chef/embedded/lib/ruby/2.1.0/net/http/response.rb:325:in `stream_check'
/opt/chef/embedded/lib/ruby/2.1.0/net/http/response.rb:199:in `read_body'
/opt/chef/embedded/lib/ruby/2.1.0/net/http/response.rb:226:in `body'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/formatters/error_inspectors/registration_error_inspector.rb:139:in `rescue in format_rest_error'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/formatters/error_inspectors/registration_error_inspector.rb:137:in `format_rest_error'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/formatters/error_inspectors/registration_error_inspector.rb:108:in `humanize_http_exception'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/formatters/error_inspectors/registration_error_inspector.rb:27:in `add_explanation'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/formatters/error_mapper.rb:32:in `registration_failed'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/formatters/base.rb:114:in `registration_failed'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/event_dispatch/dispatcher.rb:43:in `call'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/event_dispatch/dispatcher.rb:43:in `block in call_subscribers'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/event_dispatch/dispatcher.rb:34:in `each'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/event_dispatch/dispatcher.rb:34:in `call_subscribers'
(eval):2:in `registration_failed'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:623:in `rescue in register'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:603:in `register'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:255:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:261:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:249:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:249:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:215:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:203:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/client.rb:413:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/client.rb:403:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/client.rb:403:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/client.rb:393:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:58:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/chef-client:26:in `<top (required)="">'
/usr/bin/chef-client:54:in `load'
/usr/bin/chef-client:54:in `<main>'

您的系统上可能有旧版本的 knife。 运行 knife --version 确认一下,您应该会看到它是一个较旧的 11.x 版本。追踪该副本的来源(which knifetype -a knife)并将其删除。这通常意味着从 pre-existing Ruby 环境(如 RVM)中卸载 gem。

我终于想通了。 我在公司代理后面,我收到的错误“503:服务不可用”不是来自 Chef Server,而是来自代理服务器:( 无论如何,使用 "no_proxy" 选项并添加 Chef Server 的 fqdn 解决了这个问题。 是的,这仍然没有回答它如何与 chef 客户端 v11.x 一起工作的问题,但我确信这解决了问题 :)