From b846d3bff97f66eca6fc24d3e6e2bba58eb16605 Mon Sep 17 00:00:00 2001 From: Antsiferov Grigory Date: Thu, 23 Mar 2017 18:45:50 +0300 Subject: [PATCH] Add elasticsearch.curator configuration states; --- sls/elasticsearch/curator.sls | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sls/elasticsearch/curator.sls diff --git a/sls/elasticsearch/curator.sls b/sls/elasticsearch/curator.sls new file mode 100644 index 0000000..e94f42c --- /dev/null +++ b/sls/elasticsearch/curator.sls @@ -0,0 +1,40 @@ +#!pydsl +# -*- mode: python -*- +from salt.utils import dictupdate +import yaml + +hosts = __salt__['pillar.get']('elastic:hosts', []) + +# defaults +config = { + 'client': { + 'hosts': hosts, + 'master_only': False + }, + 'logging': { + 'loglevel': 'INFO', + 'logformat': 'default' + } +} + +dictupdate.update(config, __salt__['pillar.get']('elastic:curator:config', {})) + +include('python.dev-python.elasticsearch-curator') + +state('/etc/elasticsearch/curator.yml').file.managed( + mode=644, user='root', group='root', makedirs=True, + contents="# This file is generated by Salt\n" + yaml.dump(config)) + +state('/etc/elasticsearch/curator-actions.yml').file.managed( + mode=644, user='root', group='root', makedirs=True, + contents="# This file is generated by Salt\n" + yaml.dump({ + 'actions': __salt__['pillar.get']('elastic:curator:actions', {}) + })) + +cron = __salt__['pillar.get']('elastic:curator:cron') +if cron: + state('curator-cron').cron.present( + identifier='curator-cron', hour=cron.get('hour', '1'), minute=cron.get('minute', '0'), + user=cron.get('user', 'elasticsearch'), + name='curator --config /etc/elasticsenarch/curator.yml /etc/elasticsearch/curator-actions.yml').\ + require(pkg='dev-python/elasticsearch-curator')