# Conditional Execution: Conditional expression must evaluate to True or False

**URL:** <https://forum.ansible.com/t/conditional-execution-conditional-expression-must-evaluate-to-true-or-false/12839>\
**Category:** Ansible Project\
**Created:** [May 21, 2013, 1:02pm UTC](https://forum.ansible.com/t/conditional-execution-conditional-expression-must-evaluate-to-true-or-false/12839 "2013-05-21T13:02:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Mandel](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Mark\_Mandel](https://forum.ansible.com/u/Mark_Mandel)\
**Post date:** [May 21, 2013, 1:02pm UTC](https://forum.ansible.com/t/conditional-execution-conditional-expression-must-evaluate-to-true-or-false/12839/1 "2013-05-21T13:02:42Z")

</div>

All,

I’m running Ansible latest from github.

You can see the full example here:  
[http://pastebin.com/LpKdhRBD](http://pastebin.com/LpKdhRBD)

But I have a conditional from a variable I’ve registered. I took the example pretty much straight out of [http://ansible.cc/docs/playbooks2.html#register-variables](http://ansible.cc/docs/playbooks2.html#register-variables).

- name: create wordpress database  
command: sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress {{ host }}  
when: mysql\_dbs.find(‘wordpress’) != -1

Every time I run the above, I get back the error:  
_Conditional expression must evaluate to True or False: {% if (mysql\_dbs.find(‘wordpress’) != -1) %} True {% else %} False {% endif %}_

I’ve tried it, with the brackets, without the brackets, as ‘-1’ and -1. I’m not sure what I’ve done wrong here.

Can someone please point me in the right direction?

Thanks!

Mark

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 21, 2013, 11:03pm UTC](https://forum.ansible.com/t/conditional-execution-conditional-expression-must-evaluate-to-true-or-false/12839/2 "2013-05-21T23:03:06Z")

</div>

The documentation is missing something and I need to push an update.

mysql\_dbs.stdout.find(‘wordpress’) != -1

will do what you want.

A good way to see what the commands return is to run the playbook with “-v” where you can see the full returns from each module, and the standard out is in “stdout”.

Apologies on the docs error, this is already fixed in source, will push update soon!

---

<div class="post-metadata">

**Author:** ![Mark\_Mandel](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Mark\_Mandel](https://forum.ansible.com/u/Mark_Mandel)\
**Post date:** [May 21, 2013, 11:18pm UTC](https://forum.ansible.com/t/conditional-execution-conditional-expression-must-evaluate-to-true-or-false/12839/3 "2013-05-21T23:18:18Z")

</div>

Thanks for the response! Figured it would be something like that!

Mark
