Ensure a user is not present

    name
        username to remove if it exists

    Examples:

    .. code-block:: yaml

        delete:
          onyx.user_absent:
            - name: daniel

def user_absent(name):
    '''
    Ensure a user is not present

    name
        username to remove if it exists

    Examples:

    .. code-block:: yaml

        delete:
          onyx.user_absent:
            - name: daniel
    '''

    ret = {'name': name,
           'result': False,
           'changes': {},
           'comment': ''}

    old_user = __salt__['onyx.cmd']('get_user', username=name)

    if not old_user:
        ret['result'] = True
        ret['comment'] = 'User does not exist'
        return ret

    if __opts__['test'] is True and old_user:
        ret['result'] = None
        ret['comment'] = 'User will be removed'
        ret['changes']['old'] = old_user
        ret['changes']['new'] = ''
        return ret

    __salt__['onyx.cmd']('remove_user', username=name)

    if __salt__['onyx.cmd']('get_user', username=name):
        ret['comment'] = 'Failed to remove user'
    else:
        ret['result'] = True
        ret['comment'] = 'User removed'
        ret['changes']['old'] = old_user
        ret['changes']['new'] = ''
    return ret