2012-03-29 4 views
4

Я сделал рецепт для бродяг, который устанавливает 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 
+0

Какую версию бродяги вы используете? –

+0

@MichaelIrey версия 0.8.7 – NathanBrakk

ответ

4

Похоже, что происходит это запущен скрипт каждый раз, когда vagrant up выполняется.

Вы, вероятно, хотите что-то вроде этого:

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

Просто убедитесь, что phpunit в вас $PATH

+0

Это правда. Неплохо! Вот еще вопрос: как я могу заставить его выйти из рецепта, если у него есть phpunit? – NathanBrakk

+0

@NathanBrakk нет никакого способа (я знаю), чтобы «выйти» из рецепта, так как это в основном процедурный скрипт – Andrew

+1

Другими словами: Вы должны сделать свою куклую идемпотентной. – manojlds

0

я бы, вероятно, установить not_if в

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

, а не полагаться на него найти в $ PATH.