From 82b9948090529e8aaba60ce06a81f8d59426cffd Mon Sep 17 00:00:00 2001 From: Bernardo Donadio Date: Tue, 13 Jun 2017 19:49:01 -0300 Subject: [PATCH] Use JNA temp folder on /var/lib Workaround for these 3 bugs: https://github.com/elastic/elasticsearch/issues/18406 https://github.com/elastic/elasticsearch/issues/18272 https://bugs.openjdk.java.net/browse/JDK-8135224 --- defaults/main.yml | 1 + tasks/elasticsearch-config.yml | 3 ++- tasks/elasticsearch-optional-user.yml | 18 ------------- tasks/elasticsearch-parameters.yml | 1 + tasks/elasticsearch-user.yml | 39 +++++++++++++++++++++++++++ tasks/elasticsearch.yml | 5 ++-- templates/jvm.options.j2 | 3 +++ 7 files changed, 48 insertions(+), 22 deletions(-) delete mode 100644 tasks/elasticsearch-optional-user.yml create mode 100644 tasks/elasticsearch-user.yml diff --git a/defaults/main.yml b/defaults/main.yml index 59f01afd..94e0eae3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,6 +18,7 @@ es_group: elasticsearch es_config: {} #Need to provide default directories es_pid_dir: "/var/run/elasticsearch" +es_tmp_dir: "/var/lib/elasticsearch/tmp" es_data_dirs: "/var/lib/elasticsearch" es_log_dir: "/var/log/elasticsearch" es_max_open_files: 65536 diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 6debfaf5..f3545051 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -8,13 +8,14 @@ - "{{pid_dir}}" - "{{log_dir}}" - "{{conf_dir}}" + - "{{tmp_dir}}" - name: Create Data Directories file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} with_items: + - "{{es_data_dirs}}" - "{{data_dirs}}" - #Copy the config template - name: Copy Configuration File template: src=elasticsearch.yml.j2 dest={{conf_dir}}/elasticsearch.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes diff --git a/tasks/elasticsearch-optional-user.yml b/tasks/elasticsearch-optional-user.yml deleted file mode 100644 index 5cf1d387..00000000 --- a/tasks/elasticsearch-optional-user.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -#Add the elasticsearch user before installing from packages. -- name: Ensure optional elasticsearch group is created with the correct id. - group: - state: present - name: "{{ es_group }}" - system: yes - gid: "{{ es_group_id }}" - -- name: Ensure optional elasticsearch user is created with the correct id. - user: - state: present - name: "{{ es_user }}" - comment: elasticsearch system user - system: yes - createhome: no - uid: "{{ es_user_id }}" - group: "{{ es_group }}" diff --git a/tasks/elasticsearch-parameters.yml b/tasks/elasticsearch-parameters.yml index 0a6dce03..97e8ed5a 100644 --- a/tasks/elasticsearch-parameters.yml +++ b/tasks/elasticsearch-parameters.yml @@ -46,4 +46,5 @@ - set_fact: instance_suffix={{inventory_hostname}}-{{ es_instance_name }} - set_fact: pid_dir={{ es_pid_dir }}/{{instance_suffix}} - set_fact: log_dir={{ es_log_dir }}/{{instance_suffix}} +- set_fact: tmp_dir={{ es_tmp_dir }}/{{instance_suffix}} - set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }} diff --git a/tasks/elasticsearch-user.yml b/tasks/elasticsearch-user.yml new file mode 100644 index 00000000..417d8578 --- /dev/null +++ b/tasks/elasticsearch-user.yml @@ -0,0 +1,39 @@ +--- +#Add the elasticsearch user before installing from packages. +- name: Ensure elasticsearch group is created + group: + state: present + name: "{{ es_group }}" + system: yes + when: es_group_id is not defined + +- name: Ensure elasticsearch group is created with the correct id. + group: + state: present + name: "{{ es_group }}" + system: yes + gid: "{{ es_group_id }}" + when: es_group_id is defined + +- name: Ensure elasticsearch user is created + user: + state: present + name: "{{ es_user }}" + comment: elasticsearch system user + system: yes + createhome: no + home: "{{ es_data_dirs }}" #WORKAROUND: https://github.com/elastic/elasticsearch/issues/18272 + group: "{{ es_group }}" + when: es_user_id is not defined + +- name: Ensure elasticsearch user is created with the correct id. + user: + state: present + name: "{{ es_user }}" + comment: elasticsearch system user + system: yes + createhome: no + home: "{{ es_data_dirs }}" #WORKAROUND: https://github.com/elastic/elasticsearch/issues/18272 + uid: "{{ es_user_id }}" + group: "{{ es_group }}" + when: es_user_id is defined diff --git a/tasks/elasticsearch.yml b/tasks/elasticsearch.yml index e2361d49..79121d86 100644 --- a/tasks/elasticsearch.yml +++ b/tasks/elasticsearch.yml @@ -1,8 +1,7 @@ --- -- name: Include optional user and group creation. - when: (es_user_id is defined) and (es_group_id is defined) - include: elasticsearch-optional-user.yml +- name: Include user and group creation. + include: elasticsearch-user.yml - name: Include specific Elasticsearch include: elasticsearch-Debian.yml diff --git a/templates/jvm.options.j2 b/templates/jvm.options.j2 index 7d750aa1..ce61a153 100644 --- a/templates/jvm.options.j2 +++ b/templates/jvm.options.j2 @@ -67,6 +67,9 @@ # use our provided JNA always versus the system one -Djna.nosys=true +# use a custom tmp folder for JNA as some systems don't allow exec on tmp +-Djna.tmpdir={{tmp_dir}} + # flags to keep Netty from being unsafe -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true