diff --git a/.kitchen.yml b/.kitchen.yml index ca66c5f..359de9e 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -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 @@ -60,6 +62,9 @@ suites: lang-python: lang-python jvm_opts: - '# Test String' + systemd: + Service: + '# Test': String verifier: name: shell diff --git a/README.rst b/README.rst index 8d450cd..c6813dd 100644 --- a/README.rst +++ b/README.rst @@ -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 ===== diff --git a/elasticsearch/files/systemd.conf b/elasticsearch/files/systemd.conf new file mode 100644 index 0000000..477921e --- /dev/null +++ b/elasticsearch/files/systemd.conf @@ -0,0 +1,6 @@ +{%- for section, unit in systemd.iteritems() -%} +[{{ section }}] +{% for key, value in unit.iteritems() -%} +{{ key }}={{ value }} +{% endfor %} +{% endfor %} diff --git a/elasticsearch/init.sls b/elasticsearch/init.sls index f4c1b3e..6ed3912 100644 --- a/elasticsearch/init.sls +++ b/elasticsearch/init.sls @@ -4,5 +4,6 @@ include: - elasticsearch.config - elasticsearch.sysconfig - elasticsearch.jvmopts + - elasticsearch.systemd - elasticsearch.service - elasticsearch.plugins diff --git a/elasticsearch/systemd.sls b/elasticsearch/systemd.sls new file mode 100644 index 0000000..078ab4c --- /dev/null +++ b/elasticsearch/systemd.sls @@ -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 %} diff --git a/test/integration/version-5.0/testinfra/test_elasticsearch.py b/test/integration/version-5.0/testinfra/test_elasticsearch.py index 50978c7..e26100a 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_systemd_config(File): + assert File('/etc/systemd/system/elasticsearch.service.d/elasticsearch.conf').contains('# Test=String')