为什么 Chef 使用本地 IP 地址来同步我的食谱?

Why is Chef using local IP address to synchronize my cookbooks?

对于不在我的本地网络上并且我成功引导的服务器,我注意到 Chef 将尝试使用本地 IP 地址同步食谱。这是设计使然吗?没有意义。

例如当我这样做时

knife ssh collab "sudo chef-client" --manual-list --ssh-user user  --ssh-password '***'

这将失败并显示错误消息,例如

collab Starting Chef Client, version 11.18.6
collab resolving cookbooks for run list: ["ok"]
collab Synchronizing Cookbooks:
collab [2015-04-22T08:35:12+02:00] ERROR: Error connecting to https://192.168.1.132/bookshelf/organization-bf7e66f665c6aa8c3ae2e3e39bf13aee/checksum-835c9d84484e285baa65e05771e42868?AWSAccessKeyId=e61fd655bf64a6cfa43f147867c9e5aa46fc84b5&Expires=1429713256&Signature=RbykDisyo4qo569Mv9e22WGPf1k%3D, retry 1/5

所以 Chef 使用的是我的 Chef 服务器的本地 IP 地址 192.168.1.132。为什么不使用 FQDN?

我本地 knife.rb 中的 chef_server_url 有 FQDN。节点上的 /etc/chef/client.rb 相同。

所以没有配置应该使用这个IP。 Chef 为什么要这样做?

更新

我尝试更新 /etc/opscode/chef-server.rb

api_fqdn = "chef.mydomain.com"
bookshelf['vip'] = "chef.mydomain.com"

sudo chef-server-ctl reconfigure 之后,我可以在 /etc/opscode/chef-server-running.json 中看到我的域名,但错误消息仍然存在。

我还尝试完全重启 Chef 服务器计算机,以确保万无一失。

该地址仍出现在 json 文件中

ostraaten@chef:~$ sudo grep '192.168.1.132' /etc/opscode/chef-server-running.json
[sudo] password for ostraaten: 
      "vrrp_instance_ipaddress": "192.168.1.132",   
      "vrrp_instance_vrrp_unicast_bind": "192.168.1.132", 

更新

日志显示 chef_server_url 现在是正确的

 ....
 collab   Networking Error:
 collab   -----------------
 collab   Error connecting to https://192.168.1.132/bookshelf/organization-bf7e66f665c6aa8c3ae2e3e39bf13aee/checksum-835c9d84484e285baa65e05771e42868?AWSAccessKeyId=e61fd655bf64a6cfa43f147867c9e5aa46fc84b5&Expires=1429721409&Signature=BiPwn2iUia3klWTYQGwKDPs8kAQ%3D - Connection timed out - connect(2)
.... (lines deleted)
collab   
collab   Your chef_server_url may be misconfigured, or the network could be down.
collab   
collab   Relevant Config Settings:
collab   -------------------------
collab   chef_server_url  "https://chef.mydomain.com/organizations/gbx"

错误针对 bookshelf,Chef 服务器的类似 s3 的存储服务。

要使用虚拟 IP(来自防火墙或服务器上特定接口的 NAT),您必须调整 chef-server.rb 文件,请参阅 this documentation

厨师 12 和企业厨师 11 的文件位于 /etc/opscode

如果您在开源 Chef 服务器 11 上,它在 /etc/chef-server.

您可能会在名为 chef-server-running.json 的文件中的同一位置看到实际配置(格式略有不同,但您会看到需要更改的密钥)

更改为使用 VIP 的密钥:

api_fqdn = "my_server.domain.local"
bookshelf['vip'] = "my_server.domain.local"

在此之后 运行 chef-server-ctl reconfigure 并检查 .json 文件中任何剩余的本地 IP/hostname。

在 HA 拓扑的情况下,还有一些其他配置选项可以根据 this:

进行设置
keepalived['vrrp_instance_ipaddress'] = "IP to return"

这应该够了。


关于我的特殊情况的信息(警告 我正在使用 Chef Server 11 开源)我已经结束了:

bookshelf['ha'] = true
bookshelf['vip'] = "server.domain.local"
bookshelf['url'] = "https://server.domain.local"
bookshelf['listen'] = "0.0.0.0"
chef_expander['ha']  = true
chef_solr['ha'] = true
erchef['ha'] = true
lb['vip'] = "my vip (existing vrrp IP on the server)"
lb['api_fqdn'] = 'myserver.domain.local'
lb['web_ui_fqdn']  = 'myserver.domain.local'
lb['debug'] = false
nginx['ha']  = true
nginx['server_name'] = 'myserver.domain.local'
nginx['url'] = 'https://myserver.domain.local'
nginx['non_ssl_port']=800
postgresql['ha']  = true
rabbitmq['ha']  = true
chef_server_webui['ha']  = true