【问题标题】:chef-solo ssl warning when provisioning配置时的 chef-solo ssl 警告
【发布时间】:2015-01-28 03:04:14
【问题描述】:

当使用 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
```

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

很高兴知道厨师在 Vagrantfile 中需要什么样的设置来解决这个问题。

【问题讨论】:

    标签: chef-infra vagrant chef-solo


    【解决方案1】:

    此警告是在 Chef 11.12.0 中引入的。详情见release notes

    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 将 local 文件 Vagrantfile.chef 的内容包含到生成的 solo.rb 中,因此该文件需要存在于您的主机系统上,而不是虚拟机上。

    然后,在您还保存 Vagrantfile 的目录中创建一个新文件 Vagrantfile.chef,其中包含以下内容:

    Chef::Config.ssl_verify_mode = :verify_peer
    

    vagrant provision 的下一次运行不应再打印警告。

    【讨论】:

      【解决方案2】:

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

      如果你也是这样,注意这个值也可以直接在.kitchen.yml里面配置。

      如果您的标准配置程序块如下所示:

      provisioner:
        name: chef_solo
      

      您可以使用ssl_verify_mode 选项添加solo_rb 键:

      provisioner:
        name: chef_solo
        solo_rb:
          ssl_verify_mode: verify_peer
      

      并且生成的 solo.rb 将设置此选项。

      【讨论】:

        【解决方案3】:

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

        ssl_verify_mode :verify_peer
        

        knife-solo gem 将采用该值并将其放入上传到服务器的solo.rb 文件中,该文件是传递给chef-solo 的主要配置文件。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多