'Produces a remote checksum given a path,
Returns a number 0-4 for specific errors instead of checksum, also ensures it is different
0 = unknown error
1 = file does not exist, this might not be an error
2 = permissions issue
3 = its a directory, not a file
4 = stat module failed, likely due to not finding python
5 = appropriate json module not found'

def _remote_checksum(self, path, all_vars, follow=False):

    x = '0'
    try:
        remote_stat = self._execute_remote_stat(path, all_vars, follow=follow)
        if (remote_stat['exists'] and remote_stat['isdir']):
            x = '3'
        else:
            x = remote_stat['checksum']
    except AnsibleError as e:
        errormsg = to_text(e)
        if errormsg.endswith(u'Permission    denied'):
            x = '2'
        elif errormsg.endswith(u'MODULE    FAILURE'):
            x = '4'
        elif (('json' in errormsg) or ('simplejson' in errormsg)):
            x = '5'
    finally:
        return x
