本地主机中的SSH SSH错误连接 [英] Ansible SSH ERROR connection in localhost

查看:656
本文介绍了本地主机中的SSH SSH错误连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

针对本地主机启动我的剧本时出现此错误.

I have this error when I launch my playbook against the localhost host.

TASK [setup] *******************************************************************
fatal: [127.0.0.1]: UNREACHABLE! => {"changed": false, "msg": "SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}
to retry, use: --limit @deploy-test-env.retry

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=0    changed=0    unreachable=1    failed=0

我的主机文件具有以下配置:

And my hosts file have this config:

[local]
127.0.0.1

出什么问题了?

谢谢!

推荐答案

默认情况下,Ansible尝试通过ssh连接.对于本地主机,应将连接设置为local.

Ansible by default tries to connect through ssh. For localhost you should set the connection to local.

您可以在调用剧本时定义它:

You can define this when calling the playbook:

ansible-playbook playbook.yml --connection=local

在您的剧本中定义它:

- hosts: local
  connection: local

或者,更可取的是,将其定义为仅用于localhost/127.0.0.1.的主机变量.使用以下内容相对于您的剧本创建文件host_vars/127.0.0.1:

Or, preferable, define it as a host var just for localhost/127.0.0.1. Create a file host_vars/127.0.0.1 relative to your playbook with this content:

ansible_connection: local

您还可以将其作为组变量添加到库存中:

You also could add it as a group var in your inventory:

[local]
127.0.0.1

[local:vars]
ansible_connection=local

或作为主机变量:

[local]
127.0.0.1   ansible_connection=local

请参见文档中的行为参数.

这篇关于本地主机中的SSH SSH错误连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆