I am trying to create a new MySQL database with Ansible controller running on Mac OSX. When I first got msg: the python mysqldb module is required
error message, I added a task to install the MySQL-python
with pip
. It got installed correctly, however still I am still getting an error from Ansible demanding its installation.
My minimal playbook is:
- hosts: all
tasks:
- name: Ensure MySQL-python module is installed
pip:
name: MySQL-python
executalbe: /usr/local/Cellar/python/2.7.10_2/bin/pip
- name: Create test_db MySQL database
mysql_db:
name: test_db
state: present
when I run the playbook with:
ansible-playbook -i "localhost," -c local mysql-test.yml
I get the following result (with changed
for the first task upon first run):
TASK: [Ensure MySQL-python module is installed] **************************************
ok: [localhost]
TASK: [Create test_db MySQL database] *********************************************
failed: [localhost] => {"failed": true}
msg: the python mysqldb module is required
pip show MySQL-python
shows the package got installed correctly.
I am running Python 2.7.10 and Ansible 1.9.4 both installed with homebrew
, thus I don't use sudo
.
What is missing?
I checked the playbook against
ubuntu/trusty64
Vagrant machine and it worked with no problem (with OSX being the Ansible controller, the only difference was a requirement forsudo
inpip
module).I checked the playbook on a second Mac both locally with
-c local
and remotely via SSH and got the same error as in original question (forpip
to work correctly through SSH I had to addexecutalbe=/usr/local/Cellar/python/2.7.10_2/bin/pip
otherwise it reportedmsg: Failed to find required executable pip
)
The results of the task when run with -c local -vvvv
:
<localhost> REMOTE_MODULE mysql_db name=test_db state=present
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1446497958.1-90296161052037 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1446497958.1-90296161052037 && echo $HOME/.ansible/tmp/ansible-tmp-1446497958.1-90296161052037']
<localhost> PUT /var/folders/nw/2vnhg_gj77v_cyfv0p1vdfj80000gn/T/tmpK3DT_j TO /Users/techraf/.ansible/tmp/ansible-tmp-1446497958.1-90296161052037/mysql_db
<localhost> EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /Users/techraf/.ansible/tmp/ansible-tmp-1446497958.1-90296161052037/mysql_db; rm -rf /Users/techraf/.ansible/tmp/ansible-tmp-1446497958.1-90296161052037/ >/dev/null 2>&1']
failed: [localhost] => {"failed": true}
msg: the python mysqldb module is required