When i am trying to use Ansible, I am getting the following errors on
all hosts in my playbook.
Any ideas ?
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/ansible/runner/connection_plugins/paramiko_ssh.py",
line 318, in close
self.ssh.load_system_host_keys()
File "/usr/lib/python2.6/site-packages/paramiko/client.py", line
149, in load_system_host_keys
self._system_host_keys.load(filename)
File "/usr/lib/python2.6/site-packages/paramiko/hostkeys.py", line
155, in load
e = HostKeyEntry.from_line(line)
File "/usr/lib/python2.6/site-packages/paramiko/hostkeys.py", line
67, in from_line
key = RSAKey(data=base64.decodestring(key))
File "/usr/lib64/python2.6/base64.py", line 321, in decodestring
return binascii.a2b_base64(s)
Error: Incorrect padding
Resurrecting this thread in case other Ansible users encounter this again.
I encountered this on one of my developer’s systems and the root cause was a ssh known_host’s line missing the “==” at the end.
Based on the comments of the paramiko from_line() method, the input is assumed to be in “OpenSSH known hosts format”, which in this case, the text is not (as it was mangled accidentally). Some simplistic regex could be implemented to either skip the line, or eat the exception in the load() method?
I would assume that Paramiko would want to ignore bad lines vs. just barf on them. If anyone from the Ansible team picks this up and has an opinion, I am all ears, otherwise I’ll open an issue with the Paramiko folks and see if they are failing fatally here by design and if they are open to a pull request. From an ansible user perspective, especially when attempting to automating things like developer workstation maintenance, being tolerant of managled host files is a not-very-important, but useful thing to do.