mysql_db import fails the second time / "ignore_errors : yes" not working

Hi All,

I have a task that imports a db file into mysql but it fails the second time I re-run the playbook.

In order to overcome the failure I need to login to the mysql server and drop the database in order to import successfully in the second play, this is not possible in a production environment and doesn’t make my code idempotent. Using the ignore errors I still get the same problem causing Ansible to stop the execution on the next play and exit .

Task :

  • name: import DB
    mysql_db: login_host={{ DB_ADDRESS }} login_user={{ DB_MASTER_USERNAME }} login_password={{ DB_MASTER_PASSWORD }} name=mmdb state=import target=roles/mmdb/templates/mmdb-init-tables.sql.j2
    ignore_errors : yes

Error message

failed: [localhost] => {“failed”: true}
msg: ERROR 1062 (23000) at line 4: Duplicate entry ‘CM’ for key ‘PRIMARY’

In other tasks the “ignore_errors: yes” works just fine but that doesn’t seem to be the case for an import failure using the mysql_db module.

Wondering if I’m doing something wrong or I should submit a ticket ?

Regards,
Nicolas.

what is ‘ansible --version’ ?

(In any case, ignore_errors is task agnostic, I suspect the problem is the trailing space before the colon, which is new to me – I’d suspect that to be ignored but seems like it is not. The valid parameter names are checked though so I’d suspect this to raise an error, so again curious about your ansible version.)

Thanks!

ansible 1.4 (devel 6008ea40ee) last updated 2013/11/12 12:34:58 (GMT +000)

removing the space before the colon didn’t fix it.

Please file a bug and I'll try to reproduce/fix. Thanks!

done.

https://github.com/ansible/ansible/issues/4878

Regards,
Nicolas.