Ansible错误 - 无法连接,检查登录凭据(login_user和login_password,可以在〜/ .my.cnf中定义)

时间:2017-05-04 17:36:49

标签: ansible ansible-2.x ansible-1.x

我是ansible的新手,我想像这样执行我的命令

zcat /usr/share/doc/zabbix-server-mysql-3.0.9/create.sql.gz| mysql -u zabbix -p zabbixdb

Ansible_code:

- name: Import the initial schema
  mysql_db:
          state: import
          login_user: zabbix
          login_password: 1234
          name: zabbixdb
          target: /usr/share/doc/zabbix-server-mysql-3.0.9/create.sql.gz
  run_once: true

Output_error:

     failed: [10.100.140.230] => {"failed": true}
msg: unable to connect, check login credentials (login_user, and login_password, which can be defined in ~/.my.cnf), check that mysql socket exists and mysql server is running

我无法使用模板创建此文件〜/ .my.cnf,因为我使用的是ansible 1.9.6和配置文件,用于更高版本的ansible 有人可以建议我解决这个问题。

Ansible_Version:

ansible --version
ansible 1.9.6 (stable-1.9 b377301195) last updated 2017/04/09 00:47:37 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 746d51d1ff) last updated 2017/04/09 00:47:59 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 2c073442b0) last updated 2017/04/09 00:48:19 (GMT -400)
  configured module search path = /opt/ansible/library

1 个答案:

答案 0 :(得分:1)

首先,您需要在客户端上安装python-mysqldb软件包。可以吗?

然后,您还没有设置主机。这是正常的吗?

  mysql_db:
    login_host: "127.0.0.1"
    login_user: "xxx"
    login_password: "xxx"
    name: "mydatabase"
    state: import
    target: /tmp/mydump.dump

埃里克