标签:
在集成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
jenkins集成ansible注意事项Failed to connect to the host via ssh.
标签:
原文地址:http://www.cnblogs.com/rwxwsblog/p/5658703.html