jenkins集成ansible注意事项Failed to connect to the host via ssh.

简介:

在集成jenkins和ansible实现自动化部署时,root用户下执行ansible命令时可以正常运行。由于是通过jenkins用户去执行ansible命令,而jenkins用户却报如下异常:

XXXXXXX | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh.", 
    "unreachable": true
}

   找了好久也没找到相应的解决办法,后来在http://superuser.com/questions/1081609/ansible-how-to-set-a-default-ssh-user-for-all-hosts上找到了相应的解决办法。

  设置以root用户执行ansible,将remote_user = root前的注释符去掉,再次运行即可。

# default user to use for playbooks if user is not specified
# (/usr/bin/ansible will use current user as default)
remote_user = root

  再次执行,成功返回执行信息。

-bash-4.2$ ansible webservers -m command -a "free -m"
xxxx | SUCCESS | rc=0 >>
             total       used       free     shared    buffers     cached
Mem:          1518        292       1225          0         42        125
-/+ buffers/cache:        125       1393
Swap:            0          0          0












本文转自秋楓博客园博客,原文链接:http://www.cnblogs.com/rwxwsblog/p/5658703.html,如需转载请自行联系原作者

目录
相关文章
|
12小时前
|
jenkins Java 持续交付
【项目集成工具】Jenkins
【项目集成工具】Jenkins
|
6月前
|
jenkins 持续交付 网络安全
Jenkins安装SSH插件
Jenkins安装SSH插件
79 0
|
7月前
|
安全 jenkins 网络安全
Jenkins中node节点添加之SSH方式2
Jenkins中node节点添加之SSH方式2
223 1
|
12小时前
|
安全 网络安全 数据安全/隐私保护
ansible 建立ssh信任并分发到各个机器
ansible 建立ssh信任并分发到各个机器
27 0
|
11小时前
|
安全 网络安全
jsch 报错 no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha>问题处理方法
【5月更文挑战第10天】jsch 报错 no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha>问题处理方法
8 0
|
11小时前
|
算法 网络安全
no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 问题解决
【5月更文挑战第8天】no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 问题解决
13 0
|
11小时前
|
算法 网络安全
Unable to negotiate with 127.0.0.1 port 29215: no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 解决
【5月更文挑战第5天】Unable to negotiate with 127.0.0.1 port 29215: no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 解决
29 7
|
11小时前
|
分布式计算 Hadoop 网络安全
[m1pro ] ssh: connect to host localhost port 22: Connection refused
[m1pro ] ssh: connect to host localhost port 22: Connection refused
|
12小时前
|
jenkins Java 持续交付
Docker搭建持续集成平台Jenkins最简教程
Jenkins 是一个广泛使用的开源持续集成工具,它能够自动化构建、测试和部署软件项目。在本文中,我们将使用 Docker 搭建一个基于 Jenkins 的持续集成平台。
144 2