当前位置:   article > 正文

Failed to connect to the host via ssh: Control socket connect(/root/.ansible/cp/xxx): Connect_msg": "failed to connect to the host via ssh: auth

msg": "failed to connect to the host via ssh: authorized users only. all act

这里写自定义目录标题

Failed to connect to the host via ssh

当前环境:ansible 运行在docker容器当中,并且可以连接对应的机器

$ ansible all -m ping
server1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Control socket connect(/root/.ansible/cp/570a47a2a4): Connection refused\r\nFailed to connect to new control master\r\n",
    "unreachable": true
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

修改ansible的默认连接方式 为paramiko解决此类问题

$ ansible all -m ping -c paramiko
server1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
  • 1
  • 2
  • 3
  • 4
  • 5

python3.6 ansible的inventory的文件在/usr/local/lib/python3.6/site-packages/ansible/galaxy/data/default/tests目录下面

[root@codo-cmdb tests]# pwd
/usr/local/lib/python3.6/site-packages/ansible/galaxy/data/apb/tests
[root@codo-cmdb tests]# ls
inventory  test.yml.j2
  • 1
  • 2
  • 3
  • 4

修改对应的配置信息
如果你想用ssh mode ,而不是 paramiko, 你需要修改如下配置信息

vi /usr/local/lib/python3.6/site-packages/ansible/galaxy/data/apb/tests/ansible.cfg
[defaults]
inventory=./inventory
transport = ssh
host_key_checking = False

[ssh_connection]
ssh_args =
scp_if_ssh = True

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

本文参考连接
https://github.com/ansible-tw/AMA/issues/20

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/144587
推荐阅读
相关标签
  

闽ICP备14008679号