2017-07-19 67 views
0

我最近安裝ansibleansible沒有看到主機(不可到達)

[email protected]:~$ 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] 

我已經添加2行到:的/ etc/ansible /主機

[local] 
192.168.1.102 

和改變未註釋1線在ansible.cfg

# uncomment this to disable SSH key host checking 
host_key_checking = False 

不過當我這樣做:

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 
} 

1)爲什麼我的本地主機不可達

2)爲什麼這個計劃是非常聰明,它試圖通過ssh連接,即使該選項被禁用。

回答

2

要定義本地主機和使用local連接而不是使用ssh,定義主機如下:

[local] 
localhost ansible_connection=local 

這樣,我們定義locallocalhost主機與local連接。

1

選項host_key_checking = False並不意味着Ansible不會連接到主機。這是一個與ssh選項StrictHostKeyChecking相關的選項(請參閱ssh_config手冊頁)。

Ansible需要登錄到主機才能執行ping。您的本地IP地址爲192.168.1.102的主機可能沒有運行sshd守護進程,或者其他問題阻止了ssh登錄。建議您閱讀文檔http://docs.ansible.com/ansible/intro_configuration.html