

def configfile(name, config):
    ret = {
        'name': name,
        'changes': {
            
        },
        'result': None,
        'comment': '',
    }
    configs = __salt__['apache.config'](name, config, edit=False)
    current_configs = ''
    if os.path.exists(name):
        with salt.utils.fopen(name) as config_file:
            current_configs = config_file.read()
    if (configs == current_configs.strip()):
        ret['result'] = True
        ret['comment'] = 'Configuration is up to date.'
        return ret
    elif __opts__['test']:
        ret['comment'] = 'Configuration will update.'
        ret['changes'] = {
            'old': current_configs,
            'new': configs,
        }
        ret['result'] = None
        return ret
    try:
        with salt.utils.fopen(name, 'w') as config_file:
            print(configs, file=config_file)
        ret['changes'] = {
            'old': current_configs,
            'new': configs,
        }
        ret['result'] = True
        ret['comment'] = 'Successfully created configuration.'
    except Exception as exc:
        ret['result'] = False
        ret['comment'] = 'Failed to create apache configuration.'
    return ret

dataset/ETHPy150Open saltstack/salt/salt/states/apache.py configfile/original