salt-common/sls/filebeat/conf.sls
2018-07-18 17:56:36 +03:00

55 lines
1.4 KiB
Python

#!pydsl
# -*- mode: python -*-
from salt.utils import dictupdate
import yaml
import json
state('/etc/filebeat/').file.directory(
create=True, mode=755, user='root', group='root')
fqdn = __salt__['grains.get']('fqdn')
fqdn_ipv6 = __salt__['grains.get']('fqdn_ipv6')
# defaults
config = {
'name': fqdn,
'path': {
'home': '/var/lib/filebeat',
'conf': '/etc/filebeat',
'logs': '/var/log',
},
'logging': {
'level': 'info',
'selectors': ["*"],
'to_files': True,
'to_syslog': False,
'files': {
'path': '/var/log/filebeat',
'name': 'filebeat.log',
'keepfiles': 7,
}},
'filebeat': {},
'output': {},
}
elastic_template = __pillar__['filebeat'].get('template', False)
config['filebeat']['prospectors'] = __pillar__['filebeat']['prospectors']
config['output'] = __pillar__['filebeat']['output']
dictupdate.update(config, __pillar__['filebeat'].get('config', {}))
state('/etc/filebeat/filebeat.yml').file.managed(
mode=640, user='root', group='root',
# check_cmd='filebeat test config -c',
contents="# This file is generated by Salt\n" + yaml.dump(config)).\
require(file="/etc/filebeat/")
if elastic_template:
state('/etc/filebeat/filebeat.template.json').file.managed(
mode=640, user='root', group='root',
contents=json.dumps(elastic_template)).\
require(file="/etc/filebeat/")
else:
state('/etc/filebeat/filebeat.template.json').file.absent