Hi Andrew,

Determining how a task should be treated as "changed" is can be controlled
using the changed_when directive.  See the documentation:
http://docs.ansible.com/playbooks_error_handling.html#overriding-the-changed-result

-name: check if DB exists
 shell: mysql -u <user> -p <password> -h <host> 'show databases;' | grep {{
db_name }}
 register: dbstatus
 changed_when: dbstatus.rc == 1 and not dbstatus.stdout

Or something like that.  Grep returns a 1 in no lines match, and there
won't be any standard out if no lines match.

This might be a good opportunity to create a MySQL facts module that
returns information about a server, from which you can use logic to decide
how to implement tasks.  Just a thought.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAK6JQEGtNRAcsdnTpAg7wFneZkKuBXifdh8_P%3DhHA-HenSqY6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to