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

Specify ES configuration for OSes with systemd #38

Open
wants to merge 2 commits 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
5 changes: 5 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ platforms:
- name: ubuntu-14.04
driver_config:
provision_command:
- apt-get install locales
- locale-gen en_US.UTF-8
- name: ubuntu-16.04
driver_config:
provision_command:
- apt-get install locales
- locale-gen en_US.UTF-8
run_command: /sbin/init

Expand Down Expand Up @@ -60,6 +62,9 @@ suites:
lang-python: lang-python
jvm_opts:
- '# Test String'
systemd:
Service:
'# Test': String

verifier:
name: shell
Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ Configures defaults/sysconfig env vars for the Elasticsearch service.

Allows configuration of elasticsearch plugins.

``elasticsearch.systemd``
-------------------------

Configure system limits for the Elasticsearch service [on systems that use systemd](https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#systemd).


Notes
=====
Expand Down
6 changes: 6 additions & 0 deletions elasticsearch/files/systemd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%- for section, unit in systemd.iteritems() -%}
[{{ section }}]
{% for key, value in unit.iteritems() -%}
{{ key }}={{ value }}
{% endfor %}
{% endfor %}
1 change: 1 addition & 0 deletions elasticsearch/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ include:
- elasticsearch.config
- elasticsearch.sysconfig
- elasticsearch.jvmopts
- elasticsearch.systemd
- elasticsearch.service
- elasticsearch.plugins
31 changes: 31 additions & 0 deletions elasticsearch/systemd.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
include:
- elasticsearch.pkg

{%- if salt['pillar.get']('elasticsearch:systemd') %}
/etc/systemd/system/elasticsearch.service.d:
file.directory:
- user: root
- group: root
- mode: 0755
- makedirs: True
- require_in:
- service: elasticsearch

/etc/systemd/system/elasticsearch.service.d/elasticsearch.conf:
file.managed:
- source: salt://elasticsearch/files/systemd.conf
- user: root
- group: root
- mode: 0644
- template: jinja
- require:
- sls: elasticsearch.pkg
- watch_in:
- service: elasticsearch_service
- context:
systemd: {{ salt['pillar.get']('elasticsearch:systemd') }}
module.run:
- name: service.systemctl_reload
- onchanges:
- file: /etc/systemd/system/elasticsearch.service.d/elasticsearch.conf
{%- 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_systemd_config(File):
assert File('/etc/systemd/system/elasticsearch.service.d/elasticsearch.conf').contains('# Test=String')