# Buggy code
def hash_known_hosts(user=None, config=None):
    """

    Hash all the hostnames in the known hosts file.

    .. versionadded:: 2014.7.0

    user
        hash known hosts of this user

    config
        path to known hosts file: can be absolute or relative to user's home
        directory

    CLI Example:

    .. code-block:: bash

        salt '*' ssh.hash_known_hosts

    """
    full = _get_known_hosts_file(config=config, user=user)

    if isinstance(full, dict):
        return full  # full contains error information

    if not os.path.isfile(full):
        return {
            "status": "error",
            "error": "Known hosts file {0} does not exist".format(full),
        }
    origmode = os.stat(full).st_mode
    cmd = ["ssh-keygen", "-H", "-f", full]
    cmd_result = __salt__["cmd.run"](cmd, python_shell=False)
    os.stat(full, origmode)
    # ssh-keygen creates a new file, thus a chown is required.
    if os.geteuid() == 0 and user:
        uinfo = __salt__["user.info"](user)
        os.chown(full, uinfo["uid"], uinfo["gid"])
    return {"status": "updated", "comment": cmd_result}


# Traceback (TypeError)
ID: bitbucket.org
Function: ssh_known_hosts.present
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1744, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1702, in wrapper
return f(*args, **kwargs)
File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.6/site-packages/salt/utils/context.py", line 48, in func_globals_inject
yield
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1702, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/ssh_known_hosts.py", line 142, in present
timeout=timeout)
File "/usr/lib/python2.6/site-packages/salt/modules/ssh.py", line 1053, in set_known_host
cmd_result = __salt__['ssh.hash_known_hosts'](user=user, config=full)
File "<string>", line 2, in hash_known_hosts
File "/usr/lib/python2.6/site-packages/salt/utils/decorators/__init__.py", line 186, in wrapped
return function(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/modules/ssh.py", line 1168, in hash_known_hosts
os.stat(full, origmode)
TypeError: stat() takes exactly 1 argument (2 given)
Started: 14:15:46.412315
Duration: 21.117 ms
Changes:

# Fixed code
def hash_known_hosts(user=None, config=None):
    """

    Hash all the hostnames in the known hosts file.

    .. versionadded:: 2014.7.0

    user
        hash known hosts of this user

    config
        path to known hosts file: can be absolute or relative to user's home
        directory

    CLI Example:

    .. code-block:: bash

        salt '*' ssh.hash_known_hosts

    """
    full = _get_known_hosts_file(config=config, user=user)

    if isinstance(full, dict):
        return full  # full contains error information

    if not os.path.isfile(full):
        return {
            "status": "error",
            "error": "Known hosts file {0} does not exist".format(full),
        }
    origmode = os.stat(full).st_mode
    cmd = ["ssh-keygen", "-H", "-f", full]
    cmd_result = __salt__["cmd.run"](cmd, python_shell=False)
    os.chmod(full, origmode)
    # ssh-keygen creates a new file, thus a chown is required.
    if os.geteuid() == 0 and user:
        uinfo = __salt__["user.info"](user)
        os.chown(full, uinfo["uid"], uinfo["gid"])
    return {"status": "updated", "comment": cmd_result}