List the modules loaded on the minion

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' sys.list_state_modules

    State module names can be specified as globs.

    .. versionadded:: 2015.5.0

    .. code-block:: bash

        salt '*' sys.list_state_modules 'mysql_*'

def list_state_modules(*args):
    '''
    List the modules loaded on the minion

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' sys.list_state_modules

    State module names can be specified as globs.

    .. versionadded:: 2015.5.0

    .. code-block:: bash

        salt '*' sys.list_state_modules 'mysql_*'

    '''
    st_ = salt.state.State(__opts__)
    modules = set()

    if not args:
        for func in st_.states:
            log.debug('func %s', func)
            modules.add(func.split('.')[0])
        return sorted(modules)

    for module in args:
        if '*' in module:
            for func in fnmatch.filter(st_.states, module):
                modules.add(func.split('.')[0])
        else:
            for func in st_.states:
                mod_test = func.split('.')[0]
                if mod_test == module:
                    modules.add(mod_test)
    return sorted(modules)