'Handles the loading and templating of the module code through the
modify_module() function.'

def _configure_module(self, module_name, module_args, task_vars=None):

    if (task_vars is None):
        task_vars = dict()
    for mod_type in self._connection.module_implementation_preferences:
        if (mod_type == '.ps1'):
            if ((module_name in ('stat', 'file', 'copy')) and (self._task.action != module_name)):
                module_name = ('win_%s' % module_name)
            if ((module_name in ('win_stat', 'win_file', 'win_copy', 'slurp')) and module_args and hasattr(self._connection._shell, '_unquote')):
                for key in ('src', 'dest', 'path'):
                    if (key in module_args):
                        module_args[key] = self._connection._shell._unquote(module_args[key])
        module_path = self._shared_loader_obj.module_loader.find_plugin(module_name, mod_type)
        if module_path:
            break
    else:
        if ('.ps1' in self._connection.module_implementation_preferences):
            ping_module = 'win_ping'
        else:
            ping_module = 'ping'
        module_path2 = self._shared_loader_obj.module_loader.find_plugin(ping_module, self._connection.module_implementation_preferences)
        if (module_path2 is not None):
            raise AnsibleError(('The    module    %s    was    not    found    in    configured    module    paths' % module_name))
        else:
            raise AnsibleError(("The    module    %s    was    not    found    in    configured    module    paths.    Additionally,    core    modules    are    missing.    If    this    is    a    checkout,    run    'git    pull    --rebase'    to    correct    this    problem." % module_name))
    final_environment = dict()
    self._compute_environment_string(final_environment)
    (module_data, module_style, module_shebang) = modify_module(module_name, module_path, module_args, task_vars=task_vars, module_compression=self._play_context.module_compression, async_timeout=self._task.async, become=self._play_context.become, become_method=self._play_context.become_method, become_user=self._play_context.become_user, become_password=self._play_context.become_pass, environment=final_environment)
    return (module_style, module_shebang, module_data, module_path)
