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.