Conditional Execution: Conditional expression must evaluate to True or False

All,

I’m running Ansible latest from github.

You can see the full example here:
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.

  • 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

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!

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

Mark