如何在已经完成的情况下停止厨师食谱的运行

时间:2012-03-29 21:44:28

标签: chef vagrant

我为安装了phpunit的流浪者制作了一个食谱,但是当我使用流浪汉停止然后流浪汉时,它会一直失败。

execute "discover phpunit" do
  command "pear channel-discover pear.phpunit.de"
  action :run
end

execute "config phpunit" do
  command "pear config-set auto_discover 1"
  action :run
end

execute "install phpunit" do
  command "pear install pear.phpunit.de/PHPUnit"
  action :run
end

我明白了:

[default] [Thu, 29 Mar 2012 14:39:57 -0700] ERROR: execute[discover phpunit] (phpunit::default line 39) has had an error
[Thu, 29 Mar 2012 14:39:57 -0700] ERROR: execute[discover phpunit] (/tmp/vagrant-chef-1/chef-solo-1/phpunit/recipes/default.rb:39:in `from_file') had an error:
execute[discover phpunit] (phpunit::default line 39) had an error: Chef::Exceptions::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of pear channel-discover pear.phpunit.de ----
STDOUT: Channel "pear.phpunit.de" is already initialized

2 个答案:

答案 0 :(得分:4)

看起来正在发生的事情是每次执行vagrant up时都会运行此脚本。

你可能想要这样的东西:

execute "discover phpunit" do
  command "pear channel-discover pear.phpunit.de"
  action :run
  not_if "which phpunit"
end

请确保phpunit

中有$PATH

答案 1 :(得分:0)

我可能会将not_if设置为

not_if { File.exists?('/path/to/phpunit')

而不是依赖它在$ PATH中找到。