【问题标题】:chef-client start fails minitest using vagrant and test kitchenchef-client start 使用 vagrant 和 test kitchen 失败了 minitest
【发布时间】:2014-02-18 04:02:54
【问题描述】:

我正在尝试让迷你测试在测试厨房中与 vagrant 一起工作。

我自己的测试成功,但 chef-client 食谱包含一个启动 chef-client 的测试,但该测试运行失败。 chef-client 启动失败的原因是它无法通过我的厨师服务器进行身份验证,因为该框没有我的客户端验证密钥。

# Running tests:       

chef-client::service#test_0001_starts the chef-client service = 0.03 s = F       
ntp::default#test_0001_starts the NTP daemon = 0.15 s = .       
ntp::default#test_0003_creates the ntp.conf = 0.01 s = .       
ntp::default#test_0002_creates the leapfile = 0.00 s = .       
recipe::my_cookbook::default::greeting file#test_0001_creates the greeting file = 0.00 s = .       
recipe::my_cookbook::default::greeting file#test_0002_continas what's stored in the 'greeting' node attribute = 0.00 s = .       


Finished tests in 0.199086s, 30.1377 tests/s, 55.2525 assertions/s.       

  1) Failure:       
chef-client::service#test_0001_starts the chef-client service [/var/chef/minitest/chef-client/service_test.rb:25]:       
Expected: true       
  Actual: false       


6 tests, 11 assertions, 1 failures, 0 errors, 0 skips       
[2013-11-24T13:07:45+00:00] INFO: Report handlers complete       
[2013-11-24T13:07:45+00:00] ERROR: Running exception handlers       
[2013-11-24T13:07:45+00:00] ERROR: Exception handlers complete       
[2013-11-24T13:07:45+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-solo/cache/chef-stacktrace.out       
Chef Client failed. 38 resources updated       
[2013-11-24T13:07:45+00:00] ERROR: MiniTest failed with 1 failure(s) and 0 error(s).       
Failure:       
chef-client::service#test_0001_starts the chef-client service [/var/chef/minitest/chef-client/service_test.rb:25]:       
Expected: true       
  Actual: false       

[2013-11-24T13:07:45+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)       
>>>>>> Converge failed on instance <default-ubuntu-1204>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1204.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen-chef-solo/solo.rb --json-attributes /tmp/kitchen-chef-solo/dna.json  --log_level info]
>>>>>> ----------------------

这是在测试厨房旋转的 vagrant box 上运行的手动 chef-client 的输出:

vagrant@default-ubuntu-1204:~$ sudo chef-client
[2013-11-24T18:29:21+00:00] WARN: *****************************************
[2013-11-24T18:29:21+00:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2013-11-24T18:29:21+00:00] WARN: *****************************************
Starting Chef Client, version 11.8.0
Creating a new client identity for default-ubuntu-1204.vagrantup.com using the validator key.
[2013-11-24T18:29:21+00:00] WARN: Failed to read the private key /etc/chef/validation.pem: #<Errno::ENOENT: No such file or directory - /etc/chef/validation.pem>

================================================================================
Chef encountered an error attempting to create the client "default-ubuntu-1204.vagrantup.com"
================================================================================


Private Key Not Found:
----------------------
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.



Relevant Config Settings:
-------------------------
validation_key "/etc/chef/validation.pem"



[2013-11-24T18:29:21+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2013-11-24T18:29:21+00:00] ERROR: I cannot read /etc/chef/validation.pem, which you told me to use to sign requests!
[2013-11-24T18:29:21+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

我试图找到一种方法将我的客户端密钥放到由 test kitchen 创建的 vagrant box 上,我认为这将通过 .kitchen.yml,因为这是用于创建 VagrantFile 的文件.我将其他流浪者配置为使用 VagrantFile 查找我的客户端身份验证密钥,因此我认为此方法应该有效。

Test Kitchen 似乎支持 vagrant 提供,但我不太清楚这应该如何通过设置 use_vagrant_provision: true 来完成 https://github.com/test-kitchen/kitchen-vagrant#-use_vagrant_provision

我觉得我在这里遗漏了一些我还没有想到的明显的东西......?

【问题讨论】:

  • 别忘了接受正确答案!!

标签: automated-tests chef-infra vagrant minitest


【解决方案1】:

“正确”的解决方案是让您在厨房里说“不要运行这些测试,只运行食谱”,但我不知道这样的功能。您是否可以这样做可能值得一看。

为什么需要使用 chef-client 食谱?我相当肯定厨房使用 vagrant-omnibus 来安装客户端?我从来不需要它,但我只在厨房用品上单独使用。

如果您真的需要解决这个问题,那么也许您可以使用虚拟盒同步文件夹功能 / http / ftp 和一些测试助手配方来获取机器上的密钥。

【讨论】:

    【解决方案2】:

    尝试将您的私钥放在食谱文件夹中的文件中,然后将其作为食谱中的 cookbook_file 资源加载到您的虚拟机上。

    cookbook_file "/home/user/.chef/user.pem" do
      source user.pem
      action :create_if_missing
    end
    

    【讨论】:

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