ansible playbook出错:python mysqldb模块是必需的
作者:互联网
我正在尝试通过将构建服务器中的wordpress实例部署到另一台主机服务器来教自己.两个服务器都是Ubuntu 16.04,一切正常,直到构建运行mysql tasks main.yml文件时,我得到以下错误:
“需要python mysqldb模块”
我在我的server / tasks / main.yml文件中包含了python-mysqldb,所以不确定错误是什么.有人能指出我正确的方向吗?
MySQL的/任务/ main.yml
---
# tasks file for mysql
- name: Create mysql database
mysql_db: name={{ wp_mysql_db }} state=present
- name: Create mysql user
mysql_user:
name={{ wp_mysql_user }}
password={{ wp_mysql_password }}
priv=*.*:ALL
服务器/任务/ main.yml
---
# tasks file for server
- name: Update apt cache
apt: update_cache=yes cache_valid_time=3600
sudo: yes
- name: Install required software
apt: name={{ item }} state=present
sudo: yes
with_items:
- apache2
- python-mysqldb
- mysql-server
- mysql-client
- php7.0
- php7.0-mysql
- libapache2-mod-php7.0
- php7.0-cli
- php7.0-cgi
- php7.0-gd
- php7.0-mcrypt
运行时出现控制台输出错误:ansible-playbook playbook.yml -i hosts -u jbloggs -K
TASK [mysql : Create mysql database] *******************************************
task path: /etc/ansible/roles/mysql/tasks/main.yml:3
fatal: [wordpress1]: FAILED! => {"changed": false, "failed": true, "msg": "the python mysqldb module is required"}
解决方法:
您可以按要求安装它:
- name: Install required software
apt: name={{ item }} state=present
sudo: yes
with_items:
- apache2
- build-essential
- python-dev
- libmysqlclient-dev
- python-mysqldb
- mysql-server
- mysql-client
- php7.0
- php7.0-mysql
- libapache2-mod-php7.0
- php7.0-cli
- php7.0-cgi
- php7.0-gd
- php7.0-mcrypt
如果这不起作用,那么你可以这样做:
- name: Install required software
apt: name={{ item }} state=present
sudo: yes
with_items:
- apache2
- build-essential
- python-dev
- libmysqlclient-dev
- python-pip
- mysql-server
- mysql-client
- php7.0
- php7.0-mysql
- libapache2-mod-php7.0
- php7.0-cli
- php7.0-cgi
- php7.0-gd
- php7.0-mcrypt
- name: Install the MySQL-python through pip
sudo: yes
pip:
name: "{{ item }}"
state: forcereinstall
with_items:
- pip
- MySQL-python
标签:python,ansible,ubuntu-16-04,mysql-python 来源: https://codeday.me/bug/20190828/1753557.html