diff --git a/.kitchen.yml b/.kitchen.yml index 3c3650b..4f13ffa 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -60,6 +60,9 @@ suites: lang-python: lang-python jvm_opts: - '# Test String' + jvm_opts_d: + memory: + - '-Xms1g' verifier: name: shell diff --git a/elasticsearch/init.sls b/elasticsearch/init.sls index e483250..4815a24 100644 --- a/elasticsearch/init.sls +++ b/elasticsearch/init.sls @@ -3,5 +3,6 @@ include: - elasticsearch.config - elasticsearch.sysconfig - elasticsearch.jvmopts + - elasticsearch.jvmoptsd - elasticsearch.service - elasticsearch.plugins diff --git a/elasticsearch/jvmoptsd.sls b/elasticsearch/jvmoptsd.sls new file mode 100644 index 0000000..fbb6d83 --- /dev/null +++ b/elasticsearch/jvmoptsd.sls @@ -0,0 +1,30 @@ +include: + - elasticsearch.service + +{% from "elasticsearch/settings.sls" import elasticsearch with context %} + +{% if elasticsearch.major_version >= 7 %} +{%- set jvm_opts_d_dir = '/etc/elasticsearch/jvm.options.d' %} +{%- set jvm_opts_d = salt['pillar.get']('elasticsearch:jvm_opts_d', {}) %} +{%- set all_files = salt['file.find'](jvm_opts_d_dir, type='f', name='*.options', print='name', maxdepth=1) %} + +{%- for exists_file in all_files %} +{%- if exists_file | regex_replace("\.options$", "") not in jvm_opts_d.keys() %} +{{ jvm_opts_d_dir }}/{{ exists_file }}: + file.absent: + - watch_in: + - service: elasticsearch +{%- endif %} +{%- endfor %} + +{%- for filename, val in jvm_opts_d.items() %} +{{ jvm_opts_d_dir }}/{{ filename }}.options: + file.managed: + - mode: 0660 + - user: elasticsearch + - group: elasticsearch + - contents: {{ val | yaml }} + - watch_in: + - service: elasticsearch +{% endfor -%} +{% endif -%} diff --git a/test/integration/version-5.0/testinfra/test_elasticsearch.py b/test/integration/version-5.0/testinfra/test_elasticsearch.py index 50978c7..f96379f 100644 --- a/test/integration/version-5.0/testinfra/test_elasticsearch.py +++ b/test/integration/version-5.0/testinfra/test_elasticsearch.py @@ -16,3 +16,6 @@ def test_service_is_running_and_enabled(Service): def test_jvm_opts(File): assert File('/etc/elasticsearch/jvm.options').contains('# Test String') + +def test_jvm_opts_d(File): + assert File('/etc/elasticsearch/jvm.options.d/memory.options').contains('-Xms1g') \ No newline at end of file