From 4420df6927556b770a45255dbfd57a892382530c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Mart=C3=ADnez=20Ballesteros?= Date: Wed, 27 May 2020 14:56:03 +0200 Subject: [PATCH] Use a template to write override.conf file (#697) --- tasks/elasticsearch-config.yml | 13 +++++++------ templates/override.conf.j2 | 7 +++++++ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 templates/override.conf.j2 diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 796730f..36d928b 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -60,7 +60,7 @@ notify: restart elasticsearch #Copy the systemd specific file if systemd is installed -- when: use_system_d and m_lock_enabled +- when: use_system_d and (m_lock_enabled or es_max_open_files is defined) become: yes block: - name: Make sure destination dir exists @@ -70,12 +70,13 @@ mode: "755" - name: Copy specific ElasticSearch Systemd config file - ini_file: - path: "{{ sysd_config_file }}" - section: Service - option: LimitMEMLOCK - value: infinity + template: + src: "override.conf.j2" + dest: "{{ sysd_config_file }}" + owner: root + group: "{{ es_group }}" mode: "644" + force: yes notify: - reload systemd configuration - restart elasticsearch diff --git a/templates/override.conf.j2 b/templates/override.conf.j2 new file mode 100644 index 0000000..38aab16 --- /dev/null +++ b/templates/override.conf.j2 @@ -0,0 +1,7 @@ +[Service] +{% if m_lock_enabled %} +LimitMEMLOCK = infinity +{% endif %} +{% if es_max_open_files is defined %} +LimitNOFILE = {{ es_max_open_files }} +{% endif %} \ No newline at end of file