厨师 - 客户开始使用流浪汉和测试厨房minitest失败

时间:2013-11-24 19:03:04

标签: automated-tests chef vagrant minitest

我正在玩耍试图让迷你们在有流浪汉的测试厨房里工作。

我自己的测试成功,但厨师 - 客户食谱包括一个测试,以启动厨师 - 客户未通过测试运行。 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@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)

我试图找到一种方法将我的客户端密钥放到测试厨房创建的流浪盒上,我假设这是通过.kitchen.yml,因为这是用于创建VagrantFile的文件。我配置我的其他流浪汉用VagrantFile找到我的客户端身份验证密钥,所以我假设这个方法应该工作。

测试厨房似乎支持流浪汉提供,但是我不清楚如何通过设置use_vagrant_provision: true来完成这项工作 https://github.com/test-kitchen/kitchen-vagrant#-use_vagrant_provision

我觉得我在这里遗漏了一些尚未发现的东西......?

2 个答案:

答案 0 :(得分:0)

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

为什么需要使用厨师 - 客户食谱?我相当确定厨房使用vagrant-omnibus来安装客户端吗?我从来不需要它,但后来我只用厨房里的东西。

如果你真的需要解决这个问题,那么也许你可以使用虚拟框同步文件夹功能/ http / ftp和一些测试帮助程序配方将密钥输入到机器上。

答案 1 :(得分:0)

尝试将私钥放入cookbook文件夹中的文件中,然后将其作为cookbook_file资源加载到vm中。

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