Signal the minion to refresh the pillar data.

    .. versionchanged:: Neon
        The ``async`` argument has been added. The default value is True.

    CLI Example:

    .. code-block:: bash

        salt '*' saltutil.refresh_pillar
        salt '*' saltutil.refresh_pillar async=False

def refresh_pillar(**kwargs):
    '''
    Signal the minion to refresh the pillar data.

    .. versionchanged:: Neon
        The ``async`` argument has been added. The default value is True.

    CLI Example:

    .. code-block:: bash

        salt '*' saltutil.refresh_pillar
        salt '*' saltutil.refresh_pillar async=False
    '''
    asynchronous = bool(kwargs.get('async', True))
    try:
        if asynchronous:
            #  If we're going to block, first setup a listener
            ret = __salt__['event.fire']({}, 'pillar_refresh')
        else:
            eventer = salt.utils.event.get_event(
                'minion', opts=__opts__, listen=True)
            ret = __salt__['event.fire']({'notify': True}, 'pillar_refresh')
            # Wait for the finish event to fire
            log.trace('refresh_pillar waiting for pillar refresh to complete')
            # Blocks until we hear this event or until the timeout expires
            eventer.get_event(
                tag=salt.defaults.events.MINION_PILLAR_COMPLETE, wait=30)
    except KeyError:
        log.error('Event module not available. Pillar refresh failed.')
        ret = False  # Effectively a no-op, since we can't really return without an event system
    return ret