Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should be able to put settings in jvm.options.d #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ suites:
lang-python: lang-python
jvm_opts:
- '# Test String'
jvm_opts_d:
memory:
- '-Xms1g'

verifier:
name: shell
Expand Down
1 change: 1 addition & 0 deletions elasticsearch/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ include:
- elasticsearch.config
- elasticsearch.sysconfig
- elasticsearch.jvmopts
- elasticsearch.jvmoptsd
- elasticsearch.service
- elasticsearch.plugins
30 changes: 30 additions & 0 deletions elasticsearch/jvmoptsd.sls
Original file line number Diff line number Diff line change
@@ -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 -%}
3 changes: 3 additions & 0 deletions test/integration/version-5.0/testinfra/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')