def ansibleResults(result, extraKeys=()):
    """
  Returns a dictionary containing at least:

  stderr
  stdout
  returncode (None if the process didn't complete)
  error if an exception was raised
  """
    result = result.clean_copy()
    resultDict = {'returncode': result._check_key('rc')}
    keyMap = {'msg': ['msg'], 'error': ['exception', 'module_stderr'],
        'stdout': ['stdout', 'module_stdout']}
    for name, keys in keyMap.items():
        for key in keys:
            val = result._check_key(key)
            if val:
                resultDict[name] = val
                break
    for key in extraKeys:
        resultDict[key] = result._check_key(key)
    return resultDict
