So im trying to import a MySQL dump that contains two databases with Ansible on a Windows box. The Ansible playbook should be correct.
- hosts: win
gather_facts: no
tasks:
- name: Import DB
win_command: 'mysql -uroot -p12345678910 -hlocalhost < "C:\sql\dump.sql"'
args:
chdir: C:\Program Files\MySQL\MySQL Server 5.6\bin\
On the windows box if I open CMD and run
cd C:\Program Files\MySQL\MySQL Server 5.6\bin\
and then 'mysql -uroot -p12345678910 -hlocalhost < "C:\sql\dump.sql"'
it works perfectly.
Im getting a giant error. What am I doing wrong?
Im able to check the DB with a very similar Playbook:
- hosts: win
gather_facts: no
tasks:
- name: Check DB
win_command: 'mysql -uroot -p12345678910 -e "SHOW DATABASES;"'
args:
chdir: C:\Program Files\MySQL\MySQL Server 5.6\bin\
The problem might be input redirection. Perhaps you can try something like:
win_command: 'Get-Content C:\sql\dump.sql | mysql -uroot -p12345678910 -hlocalhost'