# ansible and grep

**URL:** <https://forum.ansible.com/t/ansible-and-grep/19116>\
**Category:** Ansible Project\
**Created:** [August 26, 2015, 1:40pm UTC](https://forum.ansible.com/t/ansible-and-grep/19116 "2015-08-26T13:40:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitar\_Hristov](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Dimitar\_Hristov](https://forum.ansible.com/u/Dimitar_Hristov)\
**Post date:** [August 26, 2015, 1:40pm UTC](https://forum.ansible.com/t/ansible-and-grep/19116/1 "2015-08-26T13:40:05Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 26, 2015, 2:06pm UTC](https://forum.ansible.com/t/ansible-and-grep/19116/2 "2015-08-26T14:06:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dimitar\_Hristov](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Dimitar\_Hristov](https://forum.ansible.com/u/Dimitar_Hristov)\
**Post date:** [August 27, 2015, 10:29am UTC](https://forum.ansible.com/t/ansible-and-grep/19116/3 "2015-08-27T10:29:20Z")

</div>

Yes, when I set ignore\_errys the tasks work properly. Thanks!
