2018-12-26 11:18:26 +00:00
|
|
|
#!pyobjects
|
|
|
|
## -*- mode: python -*-
|
2018-06-09 04:10:53 +00:00
|
|
|
from salt.utils import dictupdate
|
|
|
|
import yaml
|
|
|
|
import json
|
|
|
|
|
2018-12-26 11:18:26 +00:00
|
|
|
File.directory('/etc/filebeat/', create=True, mode=755, user='root', group='root')
|
2018-06-09 04:10:53 +00:00
|
|
|
|
2018-12-26 11:18:26 +00:00
|
|
|
fqdn = grains('fqdn')
|
|
|
|
fqdn_ipv6 = grains('fqdn_ipv6')
|
|
|
|
conf_path = '/etc/filebeat/'
|
2018-06-09 04:10:53 +00:00
|
|
|
|
|
|
|
# defaults
|
|
|
|
config = {
|
2018-12-26 11:18:26 +00:00
|
|
|
'name': str(fqdn),
|
2018-06-09 04:10:53 +00:00
|
|
|
'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': {},
|
|
|
|
}
|
|
|
|
|
2018-12-26 11:18:26 +00:00
|
|
|
elastic_template = pillar('template', False)
|
2019-03-29 12:07:54 +00:00
|
|
|
config['filebeat']['inputs'] = pillar('filebeat:inputs')
|
2018-12-26 11:18:26 +00:00
|
|
|
config['output'] = pillar('filebeat:output')
|
|
|
|
dictupdate.update(config, pillar('filebeat:config', {}))
|
2018-06-09 04:10:53 +00:00
|
|
|
|
2018-12-26 11:18:26 +00:00
|
|
|
File.managed(
|
|
|
|
conf_path + 'filebeat.yml',
|
2018-06-09 04:10:53 +00:00
|
|
|
mode=640, user='root', group='root',
|
2018-07-18 14:56:36 +00:00
|
|
|
# check_cmd='filebeat test config -c',
|
2018-12-26 11:18:26 +00:00
|
|
|
contents="# This file is generated by Salt\n" + yaml.dump(config),
|
|
|
|
require=[File(conf_path)])
|
2018-06-09 04:10:53 +00:00
|
|
|
|
|
|
|
if elastic_template:
|
2018-12-26 11:18:26 +00:00
|
|
|
File.managed(
|
|
|
|
conf_path + 'filebeat.template.json',
|
2018-06-09 04:10:53 +00:00
|
|
|
mode=640, user='root', group='root',
|
2018-12-26 11:18:26 +00:00
|
|
|
contents=json.dumps(elastic_template),
|
|
|
|
require=[File(conf_path)])
|
2018-06-09 04:10:53 +00:00
|
|
|
else:
|
2018-12-26 11:18:26 +00:00
|
|
|
File.absent(conf_path + 'filebeat.template.json')
|
2018-06-09 04:10:53 +00:00
|
|
|
|
|
|
|
|