Chef

廚師:上傳菜譜時連接被拒絕

  • September 7, 2017

溫柔點,我是廚師新手,正在嘗試設置我的環境並有一些新食譜要上傳到我的新廚師伺服器。我能夠執行一些命令,並且能夠訪問knife bootstrap新節點,所以我很確定我的配置是正確的。

當我打開詳細日誌記錄時,它似乎正在嘗試上傳到本地主機。我在我的伺服器中設置了一個伺服器knife.rb,我還嘗試在刀命令中指定一個伺服器,-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'

提前致謝。

https://github.com/chef/irc_log_archives/blob/master/chef/2013/2/23.log總結 IRC 會議:

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

引用自:https://serverfault.com/questions/483957