厨师:食谱上传连接被拒绝

厨师:食谱上传连接被拒绝

温柔一点,我是 Chef 新手,正在尝试设置环境并将一些新食谱上传到我的新 Chef 服务器。我可以执行一些命令,并且可以访问knife bootstrap新节点,因此我很确定我的配置是正确的。

当我打开详细日志记录时,它似乎正在尝试上传到本地主机。我在我的 中设置了一个服务器knife.rb,并且我还尝试在 knife 命令中使用 指定一个服务器-s,但无济于事。

$ knife cookbook upload -a
Uploading base         [0.1.0]
Uploading dovecot      [0.1.0]
Uploading postfix      [0.1.0]
/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)

使用指定服务器:

$ knife cookbook upload -a -s https://mychefserver
Uploading base         [0.1.0]
Uploading dovecot      [0.1.0]
Uploading postfix      [0.1.0]
/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)

使用 -V 的话:

$ knife cookbook upload -a -s https://mychefserver -V
Uploading base         [0.1.0]
Uploading dovecot      [0.1.0]
Uploading postfix      [0.1.0]
INFO: Validating ruby files
INFO: Validating templates
INFO: Syntax OK
INFO: Validating ruby files
INFO: Validating templates
INFO: Syntax OK
INFO: Validating ruby files
INFO: Validating templates
INFO: Syntax OK
INFO: Saving base
INFO: Saving dovecot
INFO: Saving postfix
INFO: Uploading files
INFO: Uploading /Users/.../...-chef/cookbooks/base/recipes/default.rb (checksum hex = b3e608cb34530c1126b9df9a630af8f7) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-b3e608cb34530c1126b9df9a630af8f7?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=Yzq%2B97btwNYPEHiGwpVJjaEYs8k%3D
INFO: Uploading /Users/.../...-chef/cookbooks/base/CHANGELOG.md (checksum hex = f1df44f4bb93cd7273932708a6686e51) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-f1df44f4bb93cd7273932708a6686e51?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=/QThzu8xUqEVyzuMmIp1XPiGG28%3D
INFO: Uploading /Users/.../...-chef/cookbooks/base/metadata.json (checksum hex = 163c72c0947d9cf8c99442b215a8de44) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-163c72c0947d9cf8c99442b215a8de44?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=8oD9AJmgTk5cgpltIXMFTeQ2oi0%3D
INFO: Uploading /Users/.../...-chef/cookbooks/base/metadata.rb (checksum hex = 6608c1ae5e3ce19a777fe1059e7264c1) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-6608c1ae5e3ce19a777fe1059e7264c1?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=/fF5I2cNbupm1auyVkpzxdVaubs%3D
INFO: Uploading /Users/.../...-chef/cookbooks/base/README.md (checksum hex = 6a4d0867b35a496d39f4d2da92c86879) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-6a4d0867b35a496d39f4d2da92c86879?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=kWX4LhSquvdw68NBHxgD2s%2BPOH4%3D
INFO: Uploading /Users/.../...-chef/cookbooks/dovecot/recipes/default.rb (checksum hex = f122f4ccdcc72d81e880c467122a7606) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-f122f4ccdcc72d81e880c467122a7606?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=WAxlIpN3U5mrrUm7BGGwlbAD8lM%3D
INFO: Uploading /Users/.../...-chef/cookbooks/dovecot/CHANGELOG.md (checksum hex = 8c447bfd4084f175bbd758b330abb0a1) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-8c447bfd4084f175bbd758b330abb0a1?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=BFiSvfDIMmBUFehMvLSPru9TWwg%3D
INFO: Uploading /Users/.../...-chef/cookbooks/dovecot/metadata.json (checksum hex = a8206f560ccb896cb73be7e97cde3cbc) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-a8206f560ccb896cb73be7e97cde3cbc?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=dAqms7EwUJkmnto8kz6yrqV40kk%3D
log writing failed. Connection refused - connect(2)
log writing failed. Connection refused - connect(2)
INFO: Uploading /Users/.../...-chef/cookbooks/dovecot/metadata.rb (checksum hex = 81eccd27bf23c5ec35e8759fe80a3a7a) to https://localhost:443/bookshelf/organization-00000000000000000000000000000000/checksum-81eccd27bf23c5ec35e8759fe80a3a7a?AWSAccessKeyId=c1856885418af6721fb2be208ec54665cb869971&Expires=1362163782&Signature=Mf/KIRRgeVgpNM7DlngY5Atf%2BIQ%3D
log writing failed. Connection refused - connect(2)
log writing failed. Connection refused - connect(2)/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:762:in `open'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from /opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
from /opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/resource.rb:76:in `put'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_uploader.rb:142:in `block in uploader_function_for'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_uploader.rb:25:in `call'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_uploader.rb:25:in `block (3 levels) in setup_worker_threads'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_uploader.rb:24:in `loop'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_uploader.rb:24:in `block (2 levels) in setup_worker_threads'

提前致谢。

答案1

总结 IRC 会议https://github.com/chef/irc_log_archives/blob/master/chef/2013/2/23.log

Chef-server 在其组件(在本例中为 erchef 和 bookshelf)之间重定向 api 客户端。这些重定向基于 chef-server 的 FQDN。如果服务器在安装时没有有效的 FQDN,则可能导致重定向到https://localhost:443

一种解决方案是修复 chef-server 上的 FQDN 并运行chef-server-ctl reconfigure

另一个解决方案是设置一些选项/etc/chef-server/chef-server.rb(我必须创建这个文件)然后运行chef-server-ctl reconfigure

server_name = "192.168.114.11"
api_fqdn server_name

nginx['url'] = "https://#{server_name}"
nginx['server_name'] = server_name
lb['fqdn'] = server_name
bookshelf['vip'] = server_name

答案2

哇,我完全以为这是我的错,但我设法找到了这个聊天线程: https://github.com/chef/irc_log_archives/blob/master/chef/2013/2/23.log

看起来,omnibus 安装程序使用 fqdn 作为某些配置项的值。我无法弄清楚如何修复它,所以我只是通过 RPM 重新安装了 chef 服务器(在为该框配置了真实主机名之后),然后再次尝试了 knife 命令,它们就像魔术一样起作用了。

相关内容