def present(name, **kwargs):
    ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}

    # Comment and change messages
    comment_usergroup_created = 'User group {0} created.'.format(name)
    comment_usergroup_updated = 'User group {0} updated.'.format(name)
    comment_usergroup_notcreated = 'Unable to create user group: {0}. '.format(name)
    comment_usergroup_exists = 'User group {0} already exists.'.format(name)
    changes_usergroup_created = {name: {'old': 'User group {0} does not exist.'.format(name),
                                        'new': 'User group {0} created.'.format(name),
                                        }
                                 }

    usergroup_exists = __salt__['zabbix.usergroup_exists'](name)

    if usergroup_exists:
        usergroup = __salt__['zabbix.usergroup_get'](name)[0]
        usrgrpid = int(usergroup['usrgrpid'])
        update_debug_mode = False
        update_gui_access = False
        update_users_status = False

        if 'debug_mode' in kwargs:
            if int(kwargs['debug_mode']) != int(usergroup['debug_mode']):
                update_debug_mode = True

        if 'gui_access' in kwargs:
            if int(kwargs['gui_access']) != int(usergroup['gui_access']):
                update_gui_access = True

        if 'users_status' in kwargs:
            if int(kwargs['users_status']) != int(usergroup['users_status']):
                update_users_status = True

    # Dry run, test=true mode
    if __opts__['test']:
        if usergroup_exists:
            if update_debug_mode or update_gui_access or update_users_status:
                ret['result'] = None
                ret['comment'] = comment_usergroup_updated
            else:
                ret['result'] = True
                ret['comment'] = comment_usergroup_exists
        else:
            ret['result'] = None
            ret['comment'] = comment_usergroup_created
        return ret

    error = []

    if usergroup_exists:
        if update_debug_mode or update_gui_access or update_users_status:
            ret['result'] = True
            ret['comment'] = comment_usergroup_updated

            if update_debug_mode:
                updated_debug = __salt__['zabbix.usergroup_update'](usrgrpid, debug_mode=kwargs['debug_mode'])
                if 'error' in updated_debug:
                    error.append(updated_debug['error'])
                else:
                    ret['changes']['debug_mode'] = kwargs['debug_mode']

            if update_gui_access:
                updated_gui = __salt__['zabbix.usergroup_update'](usrgrpid, gui_access=kwargs['gui_access'])
                if 'error' in updated_gui:
                    error.append(updated_gui['error'])
                else:
                    ret['changes']['gui_access'] = kwargs['gui_access']

            if update_users_status:
                updated_status = __salt__['zabbix.usergroup_update'](usrgrpid, users_status=kwargs['users_status'])
                if 'error' in updated_status:
                    error.append(updated_status['error'])
                else:
                    ret['changes']['users_status'] = kwargs['users_status']

        else:
            ret['result'] = True
            ret['comment'] = comment_usergroup_exists
    else:
        usergroup_create = __salt__['zabbix.usergroup_create'](name, **kwargs)

        if 'error' not in usergroup_create:
            ret['result'] = True
            ret['comment'] = comment_usergroup_created
            ret['changes'] = changes_usergroup_created
        else:
            ret['result'] = False
            ret['comment'] = comment_usergroup_notcreated + str(usergroup_create['error'])

    # error detected
    if error:
        ret['changes'] = {}
        ret['result'] = False
        ret['comment'] = str(error)

    return ret
Make sure namespace gets updated when setting attributes.
dataset/ETHPy150Open saltstack/salt/salt/states/zabbix_usergroup.py/present--crossover with--dataset/ETHPy150Open SheffieldML/GPy/GPy/core/symbolic.py/Symbolic_core._set_attribute