IndexError: list index out of range

Hi Everyone, I am using ansible since 2 months. It was working fine uptill now. But, now it is giving error to every ansible command.
For Ex. I am running ping command it is giving following error

ansible -vvvv 172.27.59.27 -m ping

<172.27.59.27> ESTABLISH CONNECTION FOR USER: root
<172.27.59.27> REMOTE_MODULE ping
<172.27.59.27> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 172.27.59.27 /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1423718954.13-54115388015450 && echo $HOME/.ansible/tmp/ansible-tmp-1423718954.13-54115388015450’
172.27.59.27 | FAILED => Traceback (most recent call last):
File “/usr/lib/python2.7/site-packages/ansible/runner/init.py”, line 590, in _executor
exec_rc = self._executor_internal(host, new_stdin)
File “/usr/lib/python2.7/site-packages/ansible/runner/init.py”, line 792, in _executor_internal
return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
File “/usr/lib/python2.7/site-packages/ansible/runner/init.py”, line 1025, in _executor_internal_inner
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
File “/usr/lib/python2.7/site-packages/ansible/runner/action_plugins/normal.py”, line 57, in run
return self.runner._execute_module(conn, tmp, module_name, module_args, inject=inject, complex_args=complex_args)
File “/usr/lib/python2.7/site-packages/ansible/runner/init.py”, line 475, in _execute_module
tmp = self._make_tmp_path(conn)
File “/usr/lib/python2.7/site-packages/ansible/runner/init.py”, line 1267, in _make_tmp_path
result = self._low_level_exec_command(conn, cmd, None, sudoable=False)
File “/usr/lib/python2.7/site-packages/ansible/runner/init.py”, line 1173, in _low_level_exec_command
in_data=in_data)
File “/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/ssh.py”, line 291, in exec_command
not_in_host_file = self.not_in_host_file(self.host)
File “/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/ssh.py”, line 236, in not_in_host_file
if tokens[0].find(self.HASHED_KEY_MAGIC) == 0:
IndexError: list index out of range

From the “not_in_host_file” it sounds like possibly something on the ssh side. Are you able to ssh to 172.27.59.27 manually (either with a password or with the certificate that command is trying to use)?

Cheers,
Daniel

Hi Everyone, I am using ansible since 2 months. It was working fine
uptill
now. But, now it is giving error to every ansible command.
For Ex. I am running ping command it is giving following error

[...]

"/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/ssh.py",
line 236, in not_in_host_file
    if tokens[0].find(self.HASHED_KEY_MAGIC) == 0:
*IndexError: list index out of range*

Something is wrong with your "~/.ssh/known_hosts" file?

Giovanni

Hi Giovanni ,
Thanks for your valuable solution. I deleted all entries in known_hosts file and it resolved my issue.

A stacktrace is still a bug in our opinion, this PR https://github.com/ansible/ansible/pull/10238 should skip bad data in the file.