# A way to check the error message returned by module in "msg"

**URL:** <https://forum.ansible.com/t/a-way-to-check-the-error-message-returned-by-module-in-msg/20153>\
**Category:** Ansible Project\
**Created:** [January 8, 2016, 2:01pm UTC](https://forum.ansible.com/t/a-way-to-check-the-error-message-returned-by-module-in-msg/20153 "2016-01-08T14:01:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosbug](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@cosbug](https://forum.ansible.com/u/cosbug)\
**Post date:** [January 8, 2016, 2:01pm UTC](https://forum.ansible.com/t/a-way-to-check-the-error-message-returned-by-module-in-msg/20153/1 "2016-01-08T14:01:59Z")

</div>

Hi All,

Is there any way to check the check the message error text returned by module in msg against some pattern?

I want to skip execution of next task if msg contains “LoadBalancerNotFound” string.

`  
TASK: [elb | Wait ELB to deassociate from SG] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [127.0.0.1] =\> {“attempts”: 0, “failed”: true}  
msg: LoadBalancerNotFound: Cannot find Load Balancer test

FATAL: all hosts have already failed – aborting

`

Thanks,  
Regards

---

<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:** [January 8, 2016, 3:19pm UTC](https://forum.ansible.com/t/a-way-to-check-the-error-message-returned-by-module-in-msg/20153/2 "2016-01-08T15:19:53Z")

</div>

use register to put the return info into a var, then you can use it to  
scan for the match.

---

<div class="post-metadata">

**Author:** ![cosbug](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@cosbug](https://forum.ansible.com/u/cosbug)\
**Post date:** [January 8, 2016, 4:14pm UTC](https://forum.ansible.com/t/a-way-to-check-the-error-message-returned-by-module-in-msg/20153/3 "2016-01-08T16:14:09Z")

</div>

I registered variable. What’s the best way to scan for the match?
