我正在尝试使用在 Mac OSX 上运行的 Ansible 控制器创建一个新的 MySQL 数据库。当我第一次得到msg: the python mysqldb module is required
错误消息,我添加了一个任务来安装MySQL-python
with pip
。它已正确安装,但我仍然收到 Ansible 要求安装的错误。
我的最小剧本是:
- 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
当我运行剧本时:
ansible-playbook -i "localhost," -c local mysql-test.yml
我得到以下结果(changed
对于第一次运行时的第一个任务):
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
显示软件包已正确安装。
我正在运行 Python 2.7.10 和 Ansible 1.9.4,两者都安装了homebrew
,因此我不使用sudo
.
缺什么?
我检查了剧本ubuntu/trusty64
Vagrant 机器和它一起工作没问题(OSX 是 Ansible 控制器,唯一的区别是需要sudo
in pip
模块)。
我在本地的第二台 Mac 上检查了剧本-c local
并通过 SSH 远程并得到相同的结果error正如原来的问题(对于pip
为了通过 SSH 正常工作,我必须添加executalbe=/usr/local/Cellar/python/2.7.10_2/bin/pip
否则它报告msg: Failed to find required executable pip
)
运行时任务的结果-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