Reputation: 277
I need to run a sed
command when 2 conditions are met-
MYFILE.txt
)/home/user/tools/
)I know I can use only_if
guard in chef, but I don't know how to mention second condition in the bash command.
Sample code:
bash 'changing path' do
code <<-EOH
cd /path
sed -i -e "s:/home/user/tools/:/NEWPATH:" MYFILE.txt
EOH
only_if { ::File.exist?(MYFILE.txt && <<WHAT SHOULD COME HERE FOR (2)>> }
end
Upvotes: 0
Views: 940
Reputation: 54181
Check out the line
cookbook, it has helpers for this kind of thing which are automatically convergent.
Upvotes: 1