ansible and grep

Hi Guys,

I’m working on a playbook, which sets up sftp accounts and changes some rules in iptables. What I need is to check whether an IP address is added in the firewall. My tasks, when I use “grep”, fail. Here are the tasks:

it seems to be working 'as written', grep is not finding the ip, so it
returns rc=1 which ansible interprets as the task failing, you can use
ignore_errors or failed_when to bypass this 'failure' as you just seem
to care if the grep found something or not.

Yes, when I set ignore_errys the tasks work properly. Thanks!