我正在尝试在 CentOS7 上使用 ANSIBLE 安装 mysql 并设置数据库(我不知道为什么现在世界上的每个文档都只谈论 Ubuntu 而不再谈论 CentOS...真的很可悲!)
这是我的 create_db.yml 文件
---
- name: Install Python MySQLdb
yum: name=MySQL-python state=latest
- name: Create the Drupal database
mysql_db: db={{ db_name }} state=present
- name: Create the Drupal user
mysql_user: >
name={{ db_user }}
password={{ db_password }}
priv={{ db_name }}.*:ALL
host=localhost
这也是我的 setup.yml 文件
---
- name: Install MySQL server
yum: name=mariadb-server state=latest
- name: Install php apache modules
yum: name=php-gd state=latest
- name: Install php apache modules
yum: name=php-ldap state=latest
- name: Install php apache modules
yum: name=php-odbc state=latest
- name: Install php apache modules
yum: name=php-pear state=latest
- name: Install php apache modules
yum: name=php-xml state=latest
- name: Install php apache modules
yum: name=php-xmlrpc state=latest
- name: Install php apache modules
yum: name=php-mbstring state=latest
- name: Install php apache modules
yum: name=php-snmp state=latest
- name: Install php apache modules
yum: name=php-soap state=latest
- name: Install php apache modules
yum: name=curl state=latest
- name: Install php apache modules
yum: name=curl-devel state=latest
- name: Install MySQL module for PHP
yum: name=php-mysql state=latest
现在,当 ansible 正在运行以安装它时,我收到以下错误
TASK: [mysql | Install MySQL server] ******************************************
ok: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
ok: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
ok: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
ok: [ansiblev1]
TASK: [mysql | Install php apache modules] ************************************
changed: [ansiblev1]
TASK: [mysql | Install MySQL module for PHP] **********************************
changed: [ansiblev1]
TASK: [mysql | Install Python MySQLdb] ****************************************
changed: [ansiblev1]
TASK: [mysql | Create the Drupal database] ************************************
failed: [ansiblev1] => {"failed": true}
msg: unable to connect, check login_user and login_password are correct, or alternatively check ~/.my.cnf contains credentials
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/bbusari/site.retry
ansiblev1 : ok=18 changed=10 unreachable=0 failed=1
我该怎么做才能解决这个问题?运行 CentOS 7 和 ansible-1.8.2-1.el7.noarch
谢谢
答案1
回答您关于确保 MariaDB 已启动的问题:
- name: Set MariaDB to start now and on boot
service: name=mysql state=started enabled=yes