mirror of
https://github.com/valitydev/salt-common.git
synced 2024-11-06 10:25:23 +00:00
Define and use {conf,data,log}_path in ES configuration
This commit is contained in:
parent
09e1dc995b
commit
c57ad5e5c4
@ -3,14 +3,24 @@
|
||||
from salt.utils import dictupdate
|
||||
import yaml
|
||||
|
||||
conf_path = '/etc/elasticsearch'
|
||||
data_path = '/var/lib/elasticsearch'
|
||||
log_path = '/var/log/elasticsearch'
|
||||
|
||||
File.directory(
|
||||
'/etc/elasticsearch/',
|
||||
conf_path,
|
||||
create=True, mode=755, user='root', group='root')
|
||||
|
||||
fqdn = grains('fqdn')
|
||||
fqdn_ipv6 = grains('fqdn_ipv6')
|
||||
hosts = pillar('elastic:hosts', [])
|
||||
|
||||
data_count = pillar('elastic:data-dir-count', False)
|
||||
if data_count:
|
||||
data_dir = ','.join([data_path + '/data' + str(i) for i in range(0, data_count)])
|
||||
else:
|
||||
data_dir = data_path
|
||||
|
||||
limits = pillar('elastic:limits', {})
|
||||
l_nofile = limits.get('nofile', 1048576)
|
||||
l_memlock = limits.get('memlock', 'unlimited')
|
||||
@ -45,12 +55,12 @@ config['discovery']['zen']['ping']['unicast']['hosts'] = filter(
|
||||
dictupdate.update(config, pillar('elastic:config'))
|
||||
|
||||
File.managed(
|
||||
'/etc/elasticsearch/elasticsearch.yml',
|
||||
conf_path + '/elasticsearch.yml',
|
||||
mode=644, user='root', group='root',
|
||||
contents="# This file is generated by Salt\n" + yaml.dump(config))
|
||||
|
||||
File.managed(
|
||||
'/etc/elasticsearch/jvm.options',
|
||||
conf_path + '/jvm.options',
|
||||
mode=644, user='root', group='root',
|
||||
template='jinja', source='salt://elasticsearch/files/jvm.options.tpl',
|
||||
defaults={'heap_size': jvm_heap_size, 'stack_size': jvm_stack_size,
|
||||
@ -60,8 +70,10 @@ File.managed(
|
||||
'/etc/conf.d/elasticsearch',
|
||||
mode=644, user='root', group='root',
|
||||
template='jinja', source="salt://elasticsearch/files/elasticsearch.confd.tpl",
|
||||
defaults={'es_java_opts': '', 'l_nofile': l_nofile, 'l_memlock': l_memlock,
|
||||
'max_map_count': max_map_count, 'max_threads': max_threads, 'es_startup_sleep_time': 10})
|
||||
defaults={
|
||||
'conf_dir': conf_path, 'log_dir': log_path, 'data_dir': data_dir,
|
||||
'es_java_opts': '', 'l_nofile': l_nofile, 'l_memlock': l_memlock,
|
||||
'max_map_count': max_map_count, 'max_threads': max_threads, 'es_startup_sleep_time': 10})
|
||||
|
||||
File.managed(
|
||||
'/etc/security/limits.d/elasticsearch.conf',
|
||||
|
@ -6,19 +6,13 @@
|
||||
#JAVA_HOME=
|
||||
|
||||
# Elasticsearch configuration directory
|
||||
CONF_DIR=/etc/elasticsearch
|
||||
CONF_DIR="{{ conf_dir }}"
|
||||
|
||||
# Elasticsearch data directory
|
||||
{% set data_path = '/var/lib/elasticsearch' %}
|
||||
{% set data_count = salt['pillar.get']('elastic:data-dir-count', False) %}
|
||||
{% if data_dir_count %}
|
||||
DATA_DIR="{{ ','.join([data_path + '/data' + str(i) for i in range(0, data_count)]) }}"
|
||||
{% else %}
|
||||
DATA_DIR="{{ data_path }}"
|
||||
{% endif %}
|
||||
DATA_DIR="{{ data_dir }}"
|
||||
|
||||
# Elasticsearch logs directory
|
||||
LOG_DIR=/var/log/elasticsearch
|
||||
LOG_DIR="{{ log_dir }}"
|
||||
|
||||
# Additional Java OPTS
|
||||
ES_JAVA_OPTS="{{ es_java_opts if es_java_opts is defined else '' }}"
|
||||
|
Loading…
Reference in New Issue
Block a user