def get_facts_dict(junos_module):
    """Retreive PyEZ facts and convert to a standard dict w/o custom types.

    Ansible >= 2.0 doesn't like custom objects in a modules return value.
    Because PyEZ facts are a custom object rather than a true dict they must be
    converted to a standard dict. Since facts are read-only, we must begin by
    copying facts into a dict. Since PyEZ facts are "on-demand", the
    junos_module.dev instance must be an open PyEZ Device instance ojbect
    before this function is called.

    Args:
        junos_module: An instance of a JuniperJunosModule.

    Returns:
        A dict containing the device facts.
    """
    # Retrieve all PyEZ-supported facts and copy to a standard dict.
    facts = dict(junos_module.dev.facts)
    # Add two useful facts that are implement as PyEZ Device attributes.
    facts['re_name'] = junos_module.dev.re_name
    facts['master_state'] = junos_module.dev.master
    # Ansible doesn't allow keys starting with numbers.
    # Replace the '2RE' key with the 'has_2RE' key.
    if '2RE' in facts:
        facts['has_2RE'] = facts['2RE']
        del facts['2RE']
    # The value of the 'version_info' key is a custom junos.version_info
    # object. Convert this value to a dict.
    if 'version_info' in facts and facts['version_info'] is not None:
        facts['version_info'] = dict(facts['version_info'])
    # The values of the ['junos_info'][re_name]['object'] keys are
    # custom junos.version_info objects. Convert all of these to dicts.
    if 'junos_info' in facts and facts['junos_info'] is not None:
        for key in facts['junos_info']:
            facts['junos_info'][key]['object'] = dict(
                facts['junos_info'][key]['object'])
    return facts