ansible 看不到主机(无法访问)

Dem*_*unt 2 ansible

我最近安装了ansible

demaunt@demaunt-pc:~$ ansible --version
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
Run Code Online (Sandbox Code Playgroud)

我添加了 2 行到:/etc/ansible/hosts

[local]
192.168.1.102
Run Code Online (Sandbox Code Playgroud)

并更改ansible.cfg中未注释的 1 行:

# uncomment this to disable SSH key host checking
host_key_checking = False
Run Code Online (Sandbox Code Playgroud)

当我这样做时:

ansible all -m ping
192.168.1.102 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.1.102' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,password).\r\n", 
    "unreachable": true
}
Run Code Online (Sandbox Code Playgroud)

1)为什么我的本地主机无法访问

2) 为什么这个程序如此聪明,即使禁用了这个选项,它也会尝试通过 ssh 连接。

Kon*_*rov 6

要定义 localhost 并使用local连接而不是 ssh,请按如下方式定义主机:

[local]
localhost ansible_connection=local
Run Code Online (Sandbox Code Playgroud)

通过这种方式,我们local使用localhost带有local连接的主机定义组。