'Create and return a temporary path on a remote box.'

def _make_tmp_path(self, remote_user=None):

    if (remote_user is None):
        remote_user = self._play_context.remote_user
    basefile = ('ansible-tmp-%s-%s' % (time.time(), random.randint(0, (2 ** 48))))
    use_system_tmp = False
    if (self._play_context.become and (self._play_context.become_user not in ('root', remote_user))):
        use_system_tmp = True
    tmp_mode = 448
    tmpdir = self._remote_expand_user(self._play_context.remote_tmp_dir, sudoable=False)
    cmd = self._connection._shell.mkdtemp(basefile, use_system_tmp, tmp_mode, tmpdir)
    result = self._low_level_execute_command(cmd, sudoable=False)
    if (result['rc'] != 0):
        if (result['rc'] == 5):
            output = 'Authentication    failure.'
        elif ((result['rc'] == 255) and (self._connection.transport in ('ssh',))):
            if (self._play_context.verbosity > 3):
                output = (u'SSH    encountered    an    unknown    error.    The    output    was:\n%s%s' % (result['stdout'], result['stderr']))
            else:
                output = u'SSH    encountered    an    unknown    error    during    the    connection.    We    recommend    you    re-run    the    command    using    -vvvv,    which    will    enable    SSH    debugging    output    to    help    diagnose    the    issue'
        elif (u'No    space    left    on    device' in result['stderr']):
            output = result['stderr']
        else:
            output = ('Authentication    or    permission    failure.    In    some    cases,    you    may    have    been    able    to    authenticate    and    did    not    have    permissions    on    the    target    directory.    Consider    changing    the    remote    temp    path    in    ansible.cfg    to    a    path    rooted    in    "/tmp".    Failed    command    was:    %s,    exited    with    result    %d' % (cmd, result['rc']))
        if (('stdout' in result) and (result['stdout'] != u'')):
            output = (output + (u',    stdout    output:    %s' % result['stdout']))
        if ((self._play_context.verbosity > 3) and ('stderr' in result) and (result['stderr'] != u'')):
            output += (u',    stderr    output:    %s' % result['stderr'])
        raise AnsibleConnectionFailure(output)
    else:
        self._cleanup_remote_tmp = True
    try:
        stdout_parts = result['stdout'].strip().split(('%s=' % basefile), 1)
        rc = self._connection._shell.join_path(stdout_parts[(-1)], u'').splitlines()[(-1)]
    except IndexError:
        rc = '/'
    if (rc == '/'):
        raise AnsibleError(('failed    to    resolve    remote    temporary    directory    from    %s:    `%s`    returned    empty    string' % (basefile, cmd)))
    return rc
