How can I reduce the following bash script?
grep -P \"STATUS: (?!Perfect)\" recess.txt && exit 1
exit 0
It seems like I should be able
Since someone already posted a Puppet solution, I might as well add how to invert a shell command run by Ansible:
- name: Check logs for errors
command: grep ERROR /var/log/cassandra/system.log
register: log_errors
failed_when: "log_errors.rc == 0"
I.e. you just set the failed condition to the return code being 0. So this command fails if we do find the word ERROR in our logs.
I chose this rather than grep -v
as that also inverts grep's output, so we would receive all DEBUG/INFO/WARN lines in log_errors.stdout_lines
which we do not want.