一、在ansible安装完毕后一般需要以SSH的方式连接到需要进行管理的目标主机,一开始遇到了如下问题:

192.168.15.4 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", 
    "unreachable": true
}
192.168.15.55 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", 
    "unreachable": true

原因分析:
没有在ansible管理节点(即安装ansible的节点)上添加目标节点(即需要管理的节点)的ssh认证信息。

解决步骤:

1:管理节点生成SSH-KEY
#ssh-keygen
成功后在~/.ssh/路径下将生成ssh密钥文件:id_rsa及id_rsa.pub
2:添加目标节点的SSH认证信息
#ssh-copy-id root@目标节点IP
这里root是在目标节点上登录的用户,@符号后面接目标节点IP即可,之后会提示输入目标节点root用户密码,输入即可。
添加认证信息后,目标节点主机的~/.ssh/目录下将会出现一个authorized_keys文件,里面包含了ansible管理节点的公钥信息,可以检查一下是否存在。
3:在确定目标主机的SSH认证信息都已正确添加且目标主机的~/.ssh/目录都存在管理节点的公钥信息后,再执行之前出错的ansible ping指令:

#ansible -m ping all

192.168.15.4 | SUCCES对之前未连接的主机进行连结时报错如下:S => {
    "changed": false, 
    "ping": "pong"
}
192.168.15.55 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

二、对之前未连接的主机进行连结时报错如下:

[root@puppet ~]# ansible webservers -m command -a 'ls ~' -k
SSH password: 
192.168.15.10 | FAILED | rc=0 >>
Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host.

解决步骤:

修改ansible.cfg文件

vi /etc/ansible/ansible.cfg

找到以下行,让host_key_checking=False这行生效

# uncomment this to disable SSH key host checking
host_key_checking = False

三、ansible requires a json module, none found!

SSH password:192.168.15.123 | FAILED >> {   "failed": true,   "msg": "Error: ansible requires a json module, nonefound!",   "parsed": false}

解决步骤:
python版本过低,要不升级python要不就升级安装python-simplejson。yum install -y python-simplejson

四、第一次系统初始化运行生成本机ansible用户key时报错

failed: [127.0.0.1] =>{"checksum": "f5f2f20fc0774be961fffb951a50023e31abe920","failed": true}msg: Aborting, target uses selinux but pythonbindings (libselinux-python) aren't installed!FATAL: all hosts have already failed –aborting

解放步骤:
yum install libselinux-python -y

五、使用命令报错

·····Traceback (most recent call last):  File "/usr/bin/ansible", line 197, in <module>    (runner, results) = cli.run(options, args)  File "/usr/bin/ansible", line 163, in run    extra_vars=extra_vars,  File "/usr/lib/python2.6/site-packages/ansible/runner/__init__.py", line 233, in __init__    cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)  File "/usr/lib64/python2.6/subprocess.py", line 639, in __init__    errread, errwrite)  File "/usr/lib64/python2.6/subprocess.py", line 1228, in _execute_child    raise child_exceptionOSError: [Errno 2] No such file or directory

解决步骤:
yum install openssh-clients

Ansible 连接主机显示报错的处理方案的更多相关文章

  1. rtmp一些状态信息详解-as连接FMS服务器报错状态汇总~~

    原地址:http://help.adobe.com/zh_CN/AIR/1.5/jslr/flash/events/NetStatusEvent.html 下表说明了 code 和 level 属性可 ...

  2. Arcgis Desktop连接GIS Servers报错“Proxy server got bad address from remote server ...”

    今天打开Arcgis Desktop时突然发现连接GIS Servers报错“Proxy server got bad address from remote server ...” 网上查找到解决方 ...

  3. 关于springboot 连接mysql 数据库报错问题

    springboot连接MySQL运行报错: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more ...

  4. 【PostgreSQL】PostgreSQL添加新服务器连接时,报错“Server doesn't listen ”,已解决。

    PostgreSQL添加新的服务器连接时,报错:

  5. flashftp连接虚拟机centos报错的解决方法

    flashftp连接虚拟机centos报错,一般情况可能是因为端口(22)的权限没有开放 先在centos中检查并开放22端口,执行:iptables -I INPUT -p tcp --dport ...

  6. eclipse连接远程Hadoop报错,Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。

    eclipse连接远程Hadoop报错,Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接.全部报错信息如下: Exception in thread & ...

  7. 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized...解决方法

    今天连接mysql数据库报错如下: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or r ...

  8. Navicat 用ssh通道连接时总是报错 (报错信息:SSH:expected key exchange group packet form serve

    转:https://blog.csdn.net/qq_27463323/article/details/76830731 之前下了一个Navicat 11.0 版本 用ssh通道连接时总是报错 (报错 ...

  9. ubuntu上跑python连接pg,报错 ImportError: No module named psycopg2

    ubuntu上跑python连接pg,报错  ImportError: No module named psycopg2 root@pgproxy1:~# python /home/zxw/PGWri ...

随机推荐

  1. Installing Oracle Database 12c Release 2(12.2) RAC on RHEL7.3 in Silent Mode

    概要 在RHEL7静默方式安装oracle database 12.2 RAC. 一.环境配置 1. 配置hosts文件 cp /etc/hosts /etc/hosts_$(date +%Y%d%m ...

  2. iPhone X进入DFU模式

    下面把iphoneX进dfu模式的方法分享给大家.在开机状态下,按一下音量加键后松开,然后按一下音量减键后松开,接着按住电源键,屏幕完全熄灭后,松开电源键,接着同时按住电源键和音量减,保持5秒左右,再 ...

  3. windows7使用Sphinx+PHP+MySQL详细介绍

    安装(Windows) 1.官方下载 Sphinx下载地址: 下载 2.解压并重命名 此处下载版本为3.0.3,将 sphinx 文件夹命名为sphinx 3.文件夹目录介绍 sphinx --api ...

  4. 测试html报告 github python3版本

    github源码下载地址:https://github.com/huilansame/HTMLTestRunner_PY3/archive/master.zip 解压后进入文件找到文件:HTMLTes ...

  5. Carthage 的使用

    第一步,当然是安装 Carthage,网上找吧 第二步,找到你要用的那个仓库,eg:https://github.com/jiutianhuanpei/SHBPlayer 第三步,cd 到工程根目录下 ...

  6. 如何修改sharepoint中alert发送邮件模板

    In my post last week I talked about customizing alert notifications and alert templates. Sometimes y ...

  7. MariaDB快速批量插入数据的几种办法

    前言 当要向MariaDB中插入新的数据时,以下过程会影响插入所消耗的时间:(按时间消耗长短降序排序) 将数据sync到磁盘上(它是事务结束的一部分) 添加新的键值.索引越大,更新键值所消耗的时间就越 ...

  8. gulp安装搭建前端项目自动化

    下面是今天在配置gulp运行项目时遇到的问题几个问题及其完整的安装过程: 1.安装node.js .gulp是基于nodejs使用的 查看版本node   -v 2.npm install gulp ...

  9. 【转】SVG与HTML、JavaScript的三种调用方式

    原文:https://www.cnblogs.com/guohu/p/5085045.html SVG与HTML.JavaScript的三种调用方式 一.在HTMl中访问SVG的DOM 1 2 3 4 ...

  10. 大数据入门第二天——基础部分之zookeeper(下)

    一.集群自启动脚本 1.关闭zk [root@localhost bin]# jps Jps QuorumPeerMain [root@localhost bin]# //kill或者stop都是可以 ...