Something like this should work ...not_if
do
File
.exists?(HOME + "/.ssh/id_dsa.pub"
)
end
Joshuahttp://wiki.opscode.com/display/chef/Resources#Resources-ScriptOn Jan 13, 2010, at 12:56 PM, Sébastien Pierre wrote:Hello,I would like to know how to write "conditional" parts for recipies.For instance, I would like to check if there is a "~/.ssh/id_dsa.pub" file and create it if necessary. Right now, the solution is rather inelegantscript "ssh-keygen" dointerpreter "bash"user "manage"cwd (HOME)code "mkdir ssh-temp"code "ssh-keygen -t dsa -f ssh-temp/id_dsa << EOF\n\nEOF"code <<-EOHif [ ! -f .ssh/id_dsa.pub ]; thenmv ssh-temp/* .ssh/firm -rf ssh-tempEOHendwhile I would preferunless (File exists (HOME + "/.ssh/id_dsa.pub") script dointerpreter "bash"user "manage"cwd (HOME)code "ssh-keygen -t dsa -f ssh-temp/id_dsa << EOF\n\nEOF"endIs there a way to do this properly ?-- Sébastien
Archive powered by MHonArc 2.6.16.