# how to search inside variables or debug ?

**URL:** <https://forum.ansible.com/t/how-to-search-inside-variables-or-debug/26504>\
**Category:** Ansible Project\
**Created:** [January 17, 2018, 5:04pm UTC](https://forum.ansible.com/t/how-to-search-inside-variables-or-debug/26504 "2018-01-17T17:04:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [January 17, 2018, 5:04pm UTC](https://forum.ansible.com/t/how-to-search-inside-variables-or-debug/26504/1 "2018-01-17T17:04:22Z")

</div>

Ref: [http://blog.toast38coza.me/custom-ansible-module-hello-world/](http://blog.toast38coza.me/custom-ansible-module-hello-world/)

play.yml

- hosts: test tasks:

- name: Test that my module works  
logmonitor\_v1:  
register: result

- debug: var=result

- name: Checking if there is any Error in log files  
fail: msg="{{ ansible\_hostname }} , Error Found - "  
when: result == “1”

Python code

```auto

response = {"Error_Code": self.error_code}
module.exit_json(changed=False, meta=response)

```

```auto

```

```auto
When i run it : -

```

```auto

```

```auto

```

```auto
PLAY [test **************************************************************

TASK [setup] *******************************************************************
ok: [test]

TASK [Test that my module works] ***********************************************
ok: [test]

TASK [debug] *******************************************************************
ok: [test] => {
    "result": {
        "changed": false,
        "meta": {
            "Error_Code": "0"
        }
    }
}

TASK [Checking if there is any Error in log files] *****************************
skipping: [test]

PLAY RECAP *********************************************************************
test : ok=3 changed=0 unreachable=0 failed=0

```

```auto

```

```auto

```

```auto
What i am trying do this : if Error_code Equal to 1, then give Fail message.

```

```auto
but it seems thsi Error_code is not storing into result .

```

```auto
Can you please help how can i do this ?

```

```auto

```

```auto
Thanks for the help.

```

```auto

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 17, 2018, 5:11pm UTC](https://forum.ansible.com/t/how-to-search-inside-variables-or-debug/26504/2 "2018-01-17T17:11:52Z")

</div>

As you can see, the Error\_Code is under meta.

So your when need to be  
&nbsp;&nbsp;when: result.meta.Error\_code == "1"

---

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [January 17, 2018, 5:19pm UTC](https://forum.ansible.com/t/how-to-search-inside-variables-or-debug/26504/3 "2018-01-17T17:19:18Z")

</div>

Perfect!!

Thanks for the quick help
