'Initialize the local facts
Args:
facts (dict): local facts to set
additive_facts_to_overwrite (list): additive facts to overwrite in jinja
\'.\' notation ex: [\'master.named_certificates\']
openshift_env (dict): openshift env facts to set
protected_facts_to_overwrite (list): protected facts to overwrite in jinja
\'.\' notation ex: [\'master.master_count\']
Returns:
dict: The result of merging the provided facts with existing
local facts'

def init_local_facts(self, facts=None, additive_facts_to_overwrite=None, openshift_env=None, openshift_env_structures=None, protected_facts_to_overwrite=None):

    changed = False
    facts_to_set = dict()
    if (facts is not None):
        facts_to_set[self.role] = facts
    if ((openshift_env != {}) and (openshift_env is not None)):
        for (fact, value) in iteritems(openshift_env):
            oo_env_facts = dict()
            current_level = oo_env_facts
            keys = self.split_openshift_env_fact_keys(fact, openshift_env_structures)[1:]
            if ((len(keys) > 0) and (keys[0] != self.role)):
                continue
            for key in keys:
                if (key == keys[(-1)]):
                    current_level[key] = value
                elif (key not in current_level):
                    current_level[key] = dict()
                    current_level = current_level[key]
            facts_to_set = merge_facts(orig=facts_to_set, new=oo_env_facts, additive_facts_to_overwrite=[], protected_facts_to_overwrite=[])
    local_facts = get_local_facts_from_file(self.filename)
    migrated_facts = migrate_local_facts(local_facts)
    new_local_facts = merge_facts(migrated_facts, facts_to_set, additive_facts_to_overwrite, protected_facts_to_overwrite)
    if ('docker' in new_local_facts):
        for cat in ['additional', 'blocked', 'insecure']:
            key = '{0}_registries'.format(cat)
            if (key in new_local_facts['docker']):
                val = new_local_facts['docker'][key]
                if isinstance(val, string_types):
                    val = [x.strip() for x in val.split(',')]
                seen = set()
                new_local_facts['docker'][key] = list()
                for registry in val:
                    if ((registry not in seen) and (registry != '')):
                        seen.add(registry)
                        new_local_facts['docker'][key].append(registry)
        if (('log_options' in new_local_facts['docker']) and isinstance(new_local_facts['docker']['log_options'], string_types)):
            new_local_facts['docker']['log_options'] = new_local_facts['docker']['log_options'].split(',')
    new_local_facts = self.remove_empty_facts(new_local_facts)
    if (new_local_facts != local_facts):
        self.validate_local_facts(new_local_facts)
        changed = True
        if (not module.check_mode):
            save_local_facts(self.filename, new_local_facts)
    self.changed = changed
    return new_local_facts
