On 06.02.17 09:27 bablu wrote: > > How to ignore failed command or in case the result set has no output. I > need the output should be success if it won't find anything relevant > mentioned in the condition.
failed_when is your friend. https://docs.ansible.com/ansible/playbooks_error_handling.html#controlling-what-defines-failure > node1 | FAILED | rc=1 >> That is because grep returns that error. > /usr/bin/ansible node1 -a "grep 'value1' /tmp/test.log" -a > "ignore_errors= yes" Make that an -e instead of an -a and try again. But I am not sure if this is only valid in playbooks or if it can be used with ansible ad-hoc commands. > node1 | FAILED | rc=2 >> > [Errno 2] No such file or directory This is because you made the command look like this: grep 'value1 ignore_errors= yes Johannes -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fe323f43-598d-cd05-934d-8c36bed901c2%40ojkastl.de. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature
