mirror of
https://github.com/valitydev/salt-common.git
synced 2024-11-07 02:45:21 +00:00
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
#!pyobjects
|
|
## -*- mode: python -*-
|
|
from salt.utils import dictupdate
|
|
import yaml
|
|
import json
|
|
|
|
File.directory('/etc/filebeat/', create=True, mode=755, user='root', group='root')
|
|
|
|
fqdn = grains('fqdn')
|
|
fqdn_ipv6 = grains('fqdn_ipv6')
|
|
conf_path = '/etc/filebeat/'
|
|
|
|
# defaults
|
|
config = {
|
|
'name': str(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('template', False)
|
|
config['filebeat']['inputs'] = pillar('filebeat:inputs')
|
|
config['output'] = pillar('filebeat:output')
|
|
dictupdate.update(config, pillar('filebeat:config', {}))
|
|
|
|
File.managed(
|
|
conf_path + 'filebeat.yml',
|
|
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(conf_path)])
|
|
|
|
if elastic_template:
|
|
File.managed(
|
|
conf_path + 'filebeat.template.json',
|
|
mode=640, user='root', group='root',
|
|
contents=json.dumps(elastic_template),
|
|
require=[File(conf_path)])
|
|
else:
|
|
File.absent(conf_path + 'filebeat.template.json')
|
|
|
|
|