- From: Alex Soto <
>
- To:
- Subject: [chef] Re: Conditional resource creation / script execution
- Date: Wed, 13 Jan 2010 13:12:08 -0800
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:references:from:content-type:in-reply-to:message-id:date:to :mime-version:x-mailer; b=A5M1ef3ryC14S73fOnrYnS8mdjEn4q5z76ifi2WFwk4J/Ww8Al8IV2D/7bIC1R5n4N nTslqzcWGCJNvXu1tnWAHEAL1LfOmYEv6jbW/oW2fznKtaIidh345FOScKdtF9psDKtU KCQflyWlQmg5IKPlEAfrZVFvQK8lKbIgqh9bA=
I think using the Execute resource and specifying 'creates' while do what you want.
On 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 inelegant
script "ssh-keygen" do interpreter "bash"
user "manage"
cwd (HOME)
code "mkdir ssh-temp"
code "ssh-keygen -t dsa -f ssh-temp/id_dsa << EOF\n\nEOF"
code <<-EOH
if [ ! -f .ssh/id_dsa.pub ]; then
mv ssh-temp/* .ssh/
fi
rm -rf ssh-temp
EOH
end
while I would prefer
unless (File exists (HOME + "/.ssh/id_dsa.pub") script do
interpreter "bash"
user "manage"
cwd (HOME)
code "ssh-keygen -t dsa -f ssh-temp/id_dsa << EOF\n\nEOF"
end
Is there a way to do this properly ?
-- Sébastien
|
Archive powered by MHonArc 2.6.16.