ruby - 无法将菜谱从 Knife 上传到 Chef 服务器

标签 ruby ubuntu amazon-ec2 chef-infra knife

我在 ubuntu ec2 实例上运行开源 Chef 服务器。我正在尝试使用 Knife 将 Recipe 从我的工作站上传到 Chef 服务器,但出现以下错误

/home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `initialize': getaddrinfo: Name or service not known (SocketError)
    from /home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `open'
    from /home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
    from /home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
    from /home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:877:in `connect'
    from /home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /home/jeevan/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/rest-client-1.6.7/lib/restclient/resource.rb:76:in `put'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.6.0/lib/chef/cookbook_uploader.rb:151:in `block in uploader_function_for'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.6.0/lib/chef/cookbook_uploader.rb:25:in `call'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.6.0/lib/chef/cookbook_uploader.rb:25:in `block (3 levels) in setup_worker_threads'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.6.0/lib/chef/cookbook_uploader.rb:24:in `loop'
    from /home/jeevan/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.6.0/lib/chef/cookbook_uploader.rb:24:in `block (2 levels) in setup_worker_threads'

当我在详细模式下运行相同的命令时,我发现我的笔记本电脑上安装的 Knife 或工作站或 Chef 客户端正在尝试连接到 ubuntu ec2 实例的私有(private) IP。

如何防止小 Knife 停止连接ubuntu ec2实例的私有(private)ip,连接到服务器的子域/域或弹性ip。

请帮帮我

最佳答案

检查您如何配置 chef_server_url 在您的chef configuration file .

您可能希望将 fqdn 配置到您的服务器,而不仅仅是主机名。

例如,如果您的机器名为 myhserver.mycompany.com 那么如果你配置了(在你的knife.rb中)

chef_server_url 'myserver:8080'



那么您的服务器可能会解析为私有(private) ip,如果您配置了

chef_server_url 'myserver.mycompany.com:8080'



然后它可能会解析到您的公共(public)IP。这取决于您的 DNS 是如何配置的。

注意:也可以考虑配置 chef_server_url 指向您的 IP(而不是主机名/fqdn)。

关于ruby - 无法将菜谱从 Knife 上传到 Chef 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18870361/

相关文章:

ruby - 使用 Ruby 取消转义字符串中的字符

ruby-on-rails - ElasticSearch在生产环境中的行为有所不同

ubuntu - 如何将 SSL 证书用于在同一服务器实例中运行的两个端口

ruby-on-rails - 是否仍然可以在 Rails 4 中使用测试单元?

ruby - 404 找不到资源 : domain with Google Directory API

python - PyTorch 安装要求 python=3.1 。安装的Python版本: 3. 10.0

google-chrome - Ubuntu 18.04 - 如何使 Chrome 窗口可调整大小?

apache - Docker 在子域上运行

node.js - 我想将扩展名的文件上传到 aws s3,但它不会上传扩展名的文件

linux - CentOS7 的 EC2 根卷扩展