# Finding a string within an stdout\_lines array

**URL:** <https://forum.ansible.com/t/finding-a-string-within-an-stdout-lines-array/21777>\
**Category:** Ansible Project\
**Created:** [June 14, 2016, 6:02pm UTC](https://forum.ansible.com/t/finding-a-string-within-an-stdout-lines-array/21777 "2016-06-14T18:02:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesvader13](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jamesvader13](https://forum.ansible.com/u/jamesvader13)\
**Post date:** [June 14, 2016, 6:02pm UTC](https://forum.ansible.com/t/finding-a-string-within-an-stdout-lines-array/21777/1 "2016-06-14T18:02:51Z")

</div>

I am trying to find whether a certain letter exists in an stdout\_lines array.

I want the role to run if there is a ‘P’ found in the stdout\_output.

The stdout\_lines array looks like this “stdout”: “P\r\nA\r\nS\r\nI\r\n”, **“stdout\_lines”: [“P”, “A”, “S”, “I”]**

myrole.yml

---

<div class="post-metadata">

**Author:** ![jamesvader13](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jamesvader13](https://forum.ansible.com/u/jamesvader13)\
**Post date:** [June 14, 2016, 7:31pm UTC](https://forum.ansible.com/t/finding-a-string-within-an-stdout-lines-array/21777/2 "2016-06-14T19:31:43Z")

</div>

The error message is strange and I can not reproduce it in Ansible 2. But your condition still will not work, a list does not have a find method. In Ansible you can search a list with `in`:

```auto
roles:
  - all_servers
  - {role: production_server, when: '"P" in prod_fact'}

```
