我使用以下方法在ubuntu服务器上安装了ansible:
pip install git+git://github.com/ansible/ansible.git@devel
所以我的版本是:
ansible 2.3.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
在配置文件中我有:
# uncomment this to disable SSH key host checking
host_key_checking = False
当我运行ansible时,我得到了:
Using /etc/ansible/ansible.cfg as config file
SSH password:
PLAYBOOK: test1.yml ************************************************************
1 plays in test1.yml
PLAY [testowy playbook] ********************************************************
TASK [show version] ************************************************************
task path: /home/mszczesniak/test1.yml:8
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/network/ios/ios_command.py
<10.27.200.80> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.27.200.80> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846 `" && echo ansible-tmp-1477054111.24-214066525349846="` echo $HOME/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846 `" ) && sleep 0'
<10.27.200.80> PUT /tmp/tmpNfII7q TO /home/mszczesniak/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846/ios_command.py
<10.27.200.80> EXEC /bin/sh -c 'chmod u+x /home/mszczesniak/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846/ /home/mszczesniak/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846/ios_command.py && sleep 0'
<10.27.200.80> EXEC /bin/sh -c '/usr/bin/python /home/mszczesniak/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846/ios_command.py; rm -rf "/home/mszczesniak/.ansible/tmp/ansible-tmp-1477054111.24-214066525349846/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_zKWzh_/ansible_module_ios_command.py", line 237, in <module>
main()
File "/tmp/ansible_zKWzh_/ansible_module_ios_command.py", line 200, in main
runner.add_command(**cmd)
File "/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/netcli.py", line 147, in add_command
File "/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/network.py", line 116, in cli
File "/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/network.py", line 147, in connect
File "/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/ios.py", line 180, in connect
File "/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/shell.py", line 230, in connect
File "/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/shell.py", line 100, in open
File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 367, in connect
look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 585, in _auth
raise SSHException('No authentication methods available')
paramiko.ssh_exception.SSHException: No authentication methods available
fatal: [10.27.200.80]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "ios_command"
},
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_zKWzh_/ansible_module_ios_command.py\", line 237, in <module>\n main()\n File \"/tmp/ansible_zKWzh_/ansible_module_ios_command.py\", line 200, in main\n runner.add_command(**cmd)\n File \"/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/netcli.py\", line 147, in add_command\n File \"/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/network.py\", line 116, in cli\n File \"/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/network.py\", line 147, in connect\n File \"/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/ios.py\", line 180, in connect\n File \"/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/shell.py\", line 230, in connect\n File \"/tmp/ansible_zKWzh_/ansible_modlib.zip/ansible/module_utils/shell.py\", line 100, in open\n File \"/usr/lib/python2.7/dist-packages/paramiko/client.py\", line 367, in connect\n look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)\n File \"/usr/lib/python2.7/dist-packages/paramiko/client.py\", line 585, in _auth\n raise SSHException('No authentication methods available')\nparamiko.ssh_exception.SSHException: No authentication methods available\n",
"module_stdout": "",
"msg": "MODULE FAILURE"
}
to retry, use: --limit @/home/mszczesniak/test1.retry
PLAY RECAP *********************************************************************
10.27.200.80 : ok=0 changed=0 unreachable=0 failed=1
有什么问题?看起来配置文件中的选项没有被采用或maby在开发2.3.0版本中存在问题?
答案 0 :(得分:0)
如果您未提供任何身份验证方法,则会引发此异常。 Paramiko SSH客户端不知道使用什么方法,因此引发SSHException('No authentication methods available')
。
您应该提供密码或私钥(或两者),以使SSHClient正常工作。此外,它只是无能为力。
一点额外:
如果您look at the code,则可以看到在未尝试任何可能的auth方法时引发此异常。