def save():
    '''
    Save all beacons on the minion

    :return:                Boolean and status message on success or failure of save.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.save
    '''

    ret = {'comment': [],
           'result': True}

    beacons = list_(return_yaml=False)

    # move this file into an configurable opt
    sfn = '{0}/{1}/beacons.conf'.format(__opts__['config_dir'],
                                        os.path.dirname(__opts__['default_include']))
    if beacons:
        tmp = {'beacons': beacons}
        yaml_out = yaml.safe_dump(tmp, default_flow_style=False)
    else:
        yaml_out = ''

    try:
        with salt.utils.fopen(sfn, 'w+') as fp_:
            fp_.write(yaml_out)
        ret['comment'] = 'Beacons saved to {0}.'.format(sfn)
    except (__HOLE__, OSError):
        ret['comment'] = 'Unable to write to beacons file at {0}. Check permissions.'.format(sfn)
        ret['result'] = False
    return ret
dataset/ETHPy150Open saltstack/salt/salt/modules/beacons.py/save