2017-08-10 74 views
-1

我有以下代碼不執行,如果software_version等於12 但not_if不工作,我不知道我使用的語法是否正確。如何測試變量與廚師not_if警衛

software_version = `command that pulls version` 
bash 'extract_installer' do 
cwd '/opt/tmp/' 
code <<-EOH 
tar -xvf #{cwd}/#{r_file} 
.... 
... 
EOH 
not_if "software_version".equal?(12) 
end 
+0

我相信「software_version」變量包含一個字符串,你用整數比較。你可以請做一個小調試「放」的呢? –

回答

0

not_if { shell_out!('command that pulls version').stdout == '12' }

+0

儘管這段代碼似乎回答了這個問題,但請提供一些額外的上下文,以便我們其他人可以理解答案,可能會減少我們將來的錯誤。 –

+0

不幸的是,當問題給出的這麼少的上下文時,沒有什麼可做的,只是給出正確的代碼並繼續前進。 – coderanger