<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _config(key, mandatory=True, opts=None):
    '''
    Return a value for 'name' from master config file options or defaults.
    '''
    try:
        if opts:
            value = opts['auth.ldap.{0}'.format(key)]
        else:
            value = __opts__['auth.ldap.{0}'.format(key)]
    except KeyError:
        try:
            value = __defopts__['auth.ldap.{0}'.format(key)]
        except KeyError:
            if mandatory:
                msg = 'missing auth.ldap.{0} in master config'.format(key)
                raise SaltInvocationError(msg)
            return False
    return value