What Lorin pointed you at is good but if you're running the script against
a remote sql server you might have to create a task ahead of the sql script
task, which checks if the schema exists and store the result in a register
variable. That way you can check if it's created or not. Something like
this:
tasks:
- action: command /some/script/to/check_if_shema_exists.sql
register: schema_exists
- action: command /script/to/create_shema.sql
when_string: "'${schema_exists.stdout}' == "no"