Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/role-elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Role Variables
* *elasticsearch_node_types*: List of types of this very node. Please refer to [official docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html) for details. (default: not set. allowed value: array of types)
+ *elasticsearch_nodename*': Node name of the Elasticsearch node. (default: value of `ansible_hostname`)
* *elasticsearch_clustername*: Name the Elasticsearch Cluster (default: `elasticsearch`)
* *elasticsearch_heap*: Heapsize for Elasticsearch. (Half of free memory on host. Maximum 30GB. (default: Half of hosts memory. Min 1GB, Max 30GB)
* *elasticsearch_heap*: Heapsize for Elasticsearch. Set to `false` to follow Elastic recommendations for elasticsearch 8.x (default: Half of hosts memory. Min 1GB, Max 30GB)
* *elasticsearch_tls_key_passphrase*: Passphrase for elasticsearch certificates (default: `PleaseChangeMeIndividually`)
* *elasticsearch_cert_validity_period*: number of days that the generated certificates are valid (default: 1095).
* *elasticsearch_cert_expiration_buffer*: Ansible will renew the elasticsearch certificate if its validity is shorter than this value, which should be number of days. (default: 30)
Expand Down
1 change: 0 additions & 1 deletion roles/elasticsearch/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ elasticsearch_pamlimits: true
elasticsearch_check_calculation: false
elasticsearch_clustername: elasticsearch
elasticsearch_conf_dir: "/etc/elasticsearch/"
elasticsearch_config_jvm: "jvm.options.j2"
elasticsearch_user: elasticsearch
elasticsearch_group: elasticsearch
elasticsearch_api_host: localhost
Expand Down
31 changes: 28 additions & 3 deletions roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,40 @@
- Restart Elasticsearch
when: elasticsearch_jna_workaround | bool

- name: Copy jvm.options File
- name: Set jvm heap size
become: yes
ansible.builtin.template:
src: "{{ elasticsearch_config_jvm }}"
dest: "{{ elasticsearch_conf_dir }}/jvm.options"
src: "jvm.options.d/heap.options.j2"
dest: "{{ elasticsearch_conf_dir }}/jvm.options.d/10-heap.options"
owner: root
group: "{{ elasticsearch_group }}"
mode: "660"
force: yes
notify: Restart Elasticsearch
when: (elasticsearch_heap)

- name: Set jvm paths
become: yes
ansible.builtin.template:
src: "jvm.options.d/paths.options.j2"
dest: "{{ elasticsearch_conf_dir }}/jvm.options.d/50-paths.options"
owner: root
group: "{{ elasticsearch_group }}"
mode: "660"
force: yes
notify: Restart Elasticsearch

- name: Set jvm custom options
become: yes
ansible.builtin.template:
src: "jvm.options.d/custom.options.j2"
dest: "{{ elasticsearch_conf_dir }}/jvm.options.d/90-custom.options"
owner: root
group: "{{ elasticsearch_group }}"
mode: "660"
force: yes
notify: Restart Elasticsearch
when: (elasticsearch_jvm_custom_parameters)

# On containerized Debian 10 systemd will not recognize elasticsearch service
- name: Force systemd to reread configs on container
Expand Down Expand Up @@ -285,6 +309,7 @@
- name: Show Info about heap
ansible.builtin.debug:
msg: "Using {{ elasticsearch_heap | int * 1024 }} of {{ ansible_memtotal_mb }} MB as heap for Elasticsearch"
when: (elasticsearch_heap)

- name: Show hint about passwords
ansible.builtin.debug:
Expand Down
5 changes: 5 additions & 0 deletions roles/elasticsearch/templates/jvm.options.d/custom.options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# {{ ansible_managed }}

{% for item in elasticsearch_jvm_custom_parameters %}
{{ item }}
{% endfor %}
5 changes: 5 additions & 0 deletions roles/elasticsearch/templates/jvm.options.d/heap.options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# {{ ansible_managed }}
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms{{ elasticsearch_heap }}g
-Xmx{{ elasticsearch_heap }}g
12 changes: 12 additions & 0 deletions roles/elasticsearch/templates/jvm.options.d/paths.options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ ansible_managed }}

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath={{ elasticsearch_heap_dump_path }}

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile={{ elasticsearch_logpath }}/hs_err_pid%p.log

## GC logging
8:-Xloggc:{{ elasticsearch_logpath }}/gc.log
9-:-Xlog:gc*,gc+age=trace,safepoint:file={{ elasticsearch_logpath }}/gc.log:utctime,pid,tags:filecount=32,filesize=64m
144 changes: 0 additions & 144 deletions roles/elasticsearch/templates/jvm.options.j2

This file was deleted.