mirror of
https://github.com/valitydev/salt-common.git
synced 2024-11-06 10:25:23 +00:00
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
#!pyobjects
|
|
# -*- mode: python -*-
|
|
from salt.utils import dictupdate
|
|
import yaml
|
|
|
|
conf_path = '/etc/elasticsearch/'
|
|
log_path = '/var/log/elasticsearch/'
|
|
include('python.dev-python.elasticsearch-curator')
|
|
|
|
hosts = pillar('elastic:curator:hosts', pillar('elastic:nodes:master', []))
|
|
|
|
# defaults
|
|
config = {
|
|
'client': {
|
|
'hosts': hosts,
|
|
'master_only': False
|
|
},
|
|
'logging': {
|
|
'loglevel': 'INFO',
|
|
'logformat': 'json',
|
|
'logfile': log_path + 'curator.json'
|
|
}
|
|
}
|
|
|
|
tls = pillar('elastic:curator:tls', {})
|
|
if tls:
|
|
config['client']['use_ssl'] = True
|
|
proto = 'http'
|
|
for pemtype in ('cert', 'key', 'ca'):
|
|
pem_path = conf_path + 'curator-' + proto + '-' + pemtype + '.pem'
|
|
if pemtype == 'ca':
|
|
config['client']['certificate'] = pem_path
|
|
else:
|
|
config['client']['client_' + pemtype] = pem_path
|
|
File.managed(
|
|
pem_path, mode=600, user='root', group='root',
|
|
contents=tls[proto].get(pemtype, tls.get(pemtype, '')))
|
|
|
|
dictupdate.update(config, pillar('elastic:curator:config', {}))
|
|
|
|
File.managed(
|
|
conf_path + 'curator.yml',
|
|
mode=644, user='root', group='root', makedirs=True,
|
|
contents="# This file is generated by Salt\n" + yaml.dump(config))
|
|
|
|
for name, actions in pillar('elastic:curator:actions', {}).items():
|
|
File.managed(
|
|
conf_path + 'curator-' + name + '-actions.yml',
|
|
mode=644, user='root', group='root', makedirs=True,
|
|
contents="# This file is generated by Salt\n" + yaml.dump(
|
|
{'actions': actions}))
|