当进行配置时,Chef Solo出现SSL警告

31

当使用Vagrant和Chef作为配置管理工具时,我收到了这个警告:

[web] Chef 11.12.2 Omnibus package is already installed.
[web] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2014-04-10T14:48:46+00:00] INFO: Forking chef instance to converge...
[2014-04-10T14:48:46+00:00] WARN:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

```
  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true
```

To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:

```
  knife ssl check -c /tmp/vagrant-chef-1/solo.rb
```

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

希望知道chef在Vagrantfile中需要哪些设置来解决这个问题。

3个回答

49
此警告是在Chef 11.12.0中引入的。有关详细信息,请参见发布说明

ssl_verify_mode设置为:verify_none时,Chef将打印警告。使用knife ssl check测试SSL连接,然后将ssl_verify_mode :verify_peer添加到配置文件中以修复此警告。尽管:verify_none目前是默认值,但这将在未来版本中更改,因此鼓励用户积极测试和更新其SSL配置。

要在Vagrant中解决此警告,您需要修改VM中创建的solo.rb配置文件。在Vagrant中,您可以使用custom_config_path选项完成此操作。

因此,您可以像这样修改Vagrantfile:
Vagrant.configure("2") do |config|
  config.vm.provision "chef_solo" do |chef|
    # the next line is added
    chef.custom_config_path = "Vagrantfile.chef"
  end
end

这将使Vagrant将Vagrantfile.chef文件中local的内容包含在生成的solo.rb文件中,因此该文件需要存在于您的主机系统上,而不是虚拟机中。

然后,在存放Vagrantfile的目录下创建一个名为Vagrantfile.chef的新文件,并填入以下内容:

Chef::Config.ssl_verify_mode = :verify_peer
下一次运行vagrant provision时,不再会打印警告。

12

我在使用test-kitchen时遇到了这个问题。

如果你也遇到了同样的问题,请注意这个值也可以直接在.kitchen.yml中进行配置。

如果你的标准provisioner块看起来像:

provisioner:
  name: chef_solo

您只需使用ssl_verify_mode选项添加solo_rb密钥:

provisioner:
  name: chef_solo
  solo_rb:
    ssl_verify_mode: verify_peer

生成的 solo.rb 文件将具有此选项设置。


8

我知道最初的问题是关于Vagrant的,但对于使用knife-solo gem并遇到此错误的人,只需将以下行添加到.chef/knife.rb中即可:

ssl_verify_mode :verify_peer
knife-solo gem会将这个值放入上传到服务器的solo.rb文件中,该文件是传递给chef-solo的主要配置文件。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接