Only_if not working

If have a file with either 0 or 1

I need to execute something only_if file content is 0

Currently file has 0
However my

only_if (0 == cat /pathtofile/file} always return blocked due to only_if

note cat is in backtick

Appreciate any help.



For better readability please use the code blocks available in this forum in the future. Regarding your problem there are many many solutions and here are two of them:

only_if "grep 0 /path/to/file"
only_if {'/path/to/file').chomp == 0 }

Mind that simple strings indicate that shell code is executed on the server and the return value is taken as condition. Curly braces indicate that Ruby code is executed and depending on wether it evaluates to TrueClass or FalseClass your resource will be executed or not.


This helps!