Friday, 15 July 2011

Ubuntu chef cookbook recipe condition need it -



Ubuntu chef cookbook recipe condition need it -

i have next lines:

execute "hostname -f >> /etc/mail/local-host-names" command "hostname -f >> /etc/mail/local-host-names" end

i add together condition, in case hostname exists in file , command should not add together 1 time again hostname in file.

the /etc/mail/local-host-names might contain other hostname, overwriting not solution.

thank you!

you should utilize bash script , grep command. grep command returns 0 if name found, 1 if not found. (# declares comment in bash). in add-on must set variable $hostname, desired hostname want each time

#!bin/sh if grep -fxq "$hostname" /etc/mail/local-host-names # execute "hostname -f >> /etc/mail/local-host-names" command "hostname -f >> /etc/mail/local-host-names" end else #do nothing? fi

ubuntu cookbook

No comments:

Post a Comment