files = {
    '/etc/systemd/system/vnstati.service': {
        'triggers': {
            'action:systemd-reload',
        },
    },
    '/etc/systemd/system/vnstati.timer': {
        'triggers': {
            'action:systemd-reload',
        },
    },
    '/etc/vnstat.conf': {
        'content_type': 'mako',
        'context': node.metadata['vnstat'],
        'triggers': {
            'svc_systemd:vnstat:restart',
        },
    },
    '/usr/local/bin/generate-vnstati': {
        'mode': '0755',
    },
}

if node.metadata.get('vnstat/generate-web-dashboard', False):
    files['/var/www/vnstat/index.html'] = {
        'content_type': 'mako',
        'context': node.metadata['vnstat'],
    }

svc_systemd = {
    'vnstat': {
        'needs': {
            'pkg_apt:vnstat',
            'file:/etc/vnstat.conf',
        },
    },
    'vnstati.timer': {
        'needs': {
            'file:/etc/systemd/system/vnstati.service',
            'file:/etc/systemd/system/vnstati.timer',
        },
        'running': node.metadata.get('vnstat/generate-web-dashboard', False),
        'enabled': node.metadata.get('vnstat/generate-web-dashboard', False),
    },
}
