ubuntu python3 mysql_Ansible+Ubuntu 18.04+MySQL=“需要PyMySQL(Python 2.7和Python 3.X)或MySQLpython(Python...

在 Ubuntu 18.04 上使用 Ansible 2.8 进行数据库操作时遇到问题,错误提示需要 PyMySQL(Python 2.7 和 Python 3.X)或 MySQL-python(Python 2.X)模块。尽管系统中同时安装了 Python 2.7 和 Python 3.6,但 Ansible 在执行过程中仍尝试使用 Python 2.7 版本,导致 playbook 失败。此问题出现在多台 Drupal 服务器的配置中,且在旧版 Ubuntu 上未发生。通过 `-vvv` 选项跟踪输出,发现 Ansible 在远程主机上尝试执行 `mysql_db.py` 模块时因缺少上述依赖而失败。
摘要由CSDN通过智能技术生成

我在ubuntu18.04上使用ansible2.8在多个playbooks上看到了上述消息。为了简单起见,我在单节点Drupal服务器上使用了这个基本的playbook来复制它。https://github.com/geerlingguy/ansible-for-devops/tree/master/drupal;这个剧本在早期版本的ubuntu上运行得很好,但是在18.04版本上就不行了,我知道默认情况下包括python3。在

我使用vagrant创建了基本机器,它显示了以下内容:$ which python

/usr/bin/python

$ which python2

/usr/bin/python2

$ which python3

/usr/bin/python3

$ python --version

Python 2.7.15rc1

$ python2 --version

Python 2.7.15rc1

$ python3 --version

Python 3.6.7

这似乎告诉我Python2和Python3都已安装,但2.7是默认值,因为这是对$python--version的响应。在

但没有什么会影响信息。从playbook运行中编辑的-vvv输出如下。有没有人对这个问题或解决方案有更多的想法。在TASK [Remove the MySQL test database.] ****************************************************************************************************************************

task path: /vagrant/provisioning/playbook.yml:96

<10.1.1.11> ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user

<10.1.1.11> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o

.

.

.

Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/database/mysql/mysql_db.py

<10.1.1.11> PUT /home/mt-tools-user/.ansible/tmp/ansible-local-21287bh5dK5/tmp7pOKOH TO /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-16683638151793

1/AnsiballZ_mysql_db.py

<10.1.1.11> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthent

ication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=

10 -o ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 '[10.1.1.11]'

<10.1.1.11> (0, 'sftp> put /home/mt-tools-user/.ansible/tmp/ansible-local-21287bh5dK5/tmp7pOKOH /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-166836

381517931/AnsiballZ_mysql_db.py\n', '')

<10.1.1.11> ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user

<10.1.1.11> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthenticatio

n=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=10 -o

ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 10.1.1.11 '/bin/sh -c '"'"'chmod u+x /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-1668363815

17931/ /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-166836381517931/AnsiballZ_mysql_db.py && sleep 0'"'"''

<10.1.1.11> (0, '', '')

<10.1.1.11> ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user

<10.1.1.11> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthenticatio

n=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=10 -o

ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 -tt 10.1.1.11 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-qwjewg

qckuyapsxnkbqoegainrkyiinc ; /usr/bin/python3 /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-166836381517931/AnsiballZ_mysql_db.py'"'"'"'"'"'"'"'"' &

& sleep 0'"'"''

<10.1.1.11> (1, 'BECOME-SUCCESS-qwjewgqckuyapsxnkbqoegainrkyiinc\r\n\r\n{"msg": "The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is req

uired.", "failed": true, "invocation": {"module_args": {"db": "test", "state": "absent", "name": "test", "login_host": "localhost", "login_port": 3306, "encoding":

"", "collation": "", "connect_timeout": 30, "config_file": "/root/.my.cnf", "single_transaction": false, "quick": true, "ignore_tables": [], "login_user": null, "

login_password": null, "login_unix_socket": null, "target": null, "client_cert": null, "client_key": null, "ca_cert": null}}}\r\n', 'Shared connection to 10.1.1.11

closed.\r\n')

<10.1.1.11> Failed to connect to the host via ssh: Shared connection to 10.1.1.11 closed.

<10.1.1.11> ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user

<10.1.1.11> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthenticatio

n=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=10 -o

ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 10.1.1.11 '/bin/sh -c '"'"'rm -f -r /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-16683638151

7931/ > /dev/null 2>&1 && sleep 0'"'"''

<10.1.1.11> (0, '', '')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值