Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit d3c98fd

Browse files
authored
Merge pull request #637 from jmlrt/use-default-config-files
Use default config files
2 parents 5480ac6 + 0b240ef commit d3c98fd

15 files changed

+281
-239
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ In addition to es_config, the following parameters allow the customization of th
405405
* ```update_java``` Updates Java to the latest version. (true or false (default))
406406
* ```es_max_map_count``` maximum number of VMA (Virtual Memory Areas) a process can own. Defaults to 262144.
407407
* ```es_max_open_files``` the maximum file descriptor number that can be opened by this process. Defaults to 65536.
408-
* ```es_max_threads``` the maximum number of threads the process can start. Defaults to 2048 (the minimum required by elasticsearch).
409408
* ```es_debian_startup_timeout``` how long Debian-family SysV init scripts wait for the service to start, in seconds. Defaults to 10 seconds.
410409
* ```es_use_repository``` Setting this to `false` will stop Ansible from using the official Elastic package from any repository configured on the system.
411410
* ```es_add_repository``` Setting this to `false` will stop Ansible to add the official Elastic package repositories (if es_use_repository is true) if you want to use a repo already present.

defaults/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ es_templates: false
2020
es_user: elasticsearch
2121
es_group: elasticsearch
2222
es_config: {}
23-
es_config_log4j2: log4j2.properties.j2
23+
es_config_default: "elasticsearch.j2"
24+
es_config_log4j2: ""
25+
es_config_jvm: "jvm.options.j2"
2426
#Need to provide default directories
2527
es_conf_dir: "/etc/elasticsearch"
2628
es_pid_dir: "/var/run/elasticsearch"
@@ -29,7 +31,6 @@ es_data_dirs:
2931
es_log_dir: "/var/log/elasticsearch"
3032
es_action_auto_create_index: true
3133
es_max_open_files: 65536
32-
es_max_threads: 8192
3334
es_max_map_count: 262144
3435
es_allow_downgrades: false
3536
es_xpack_features: []

files/logging/log4j2.properties.custom.j2

Lines changed: 0 additions & 76 deletions
This file was deleted.

tasks/elasticsearch-config.yml

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,101 @@
44
#Create conf directory
55
- name: Create Configuration Directory
66
become: yes
7-
file: path={{ es_conf_dir }} state=directory owner=root group={{ es_group }} mode=2750
7+
file:
8+
path: "{{ es_conf_dir }}"
9+
state: directory
10+
owner: root
11+
group: "{{ es_group }}"
12+
mode: "2750"
813

914
#Create pid directory
1015
- name: Create PID Directory
1116
become: yes
12-
file: path={{ es_pid_dir }} state=directory owner={{ es_user }} group={{ es_group }} mode=0755
17+
file:
18+
path: "{{ es_pid_dir }}"
19+
state: directory
20+
owner: "{{ es_user }}"
21+
group: "{{ es_group }}"
22+
mode: "755"
1323

1424
#Create required directories
1525
- name: Create Others Directories
1626
become: yes
17-
file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} mode=2750
27+
file:
28+
path: "{{ item }}"
29+
state: directory
30+
owner: "{{ es_user }}"
31+
group: "{{ es_group }}"
32+
mode: "2750"
1833
with_items:
1934
- "{{ es_log_dir }}"
2035
- "{{ es_data_dirs }}"
2136

2237
#Copy the config template
2338
- name: Copy Configuration File
2439
become: yes
25-
template: src=elasticsearch.yml.j2 dest={{ es_conf_dir }}/elasticsearch.yml owner=root group={{ es_group }} mode=0660 force=yes
40+
template:
41+
src: elasticsearch.yml.j2
42+
dest: "{{ es_conf_dir }}/elasticsearch.yml"
43+
owner: root
44+
group: "{{ es_group }}"
45+
mode: "660"
46+
force: yes
2647
register: system_change
2748
notify: restart elasticsearch
2849

2950
#Copy the default file
3051
- name: Copy Default File
3152
become: yes
32-
template: src=elasticsearch.j2 dest={{ default_file }} owner=root group={{ es_group }} mode=0660 force=yes
53+
template:
54+
src: "{{ es_config_default }}"
55+
dest: "{{ default_file }}"
56+
owner: root
57+
group: "{{ es_group }}"
58+
mode: "660"
59+
force: yes
3360
notify: restart elasticsearch
3461

3562
#Copy the systemd specific file if systemd is installed
3663
- when: use_system_d and m_lock_enabled
3764
become: yes
3865
block:
3966
- name: Make sure destination dir exists
40-
file: path={{ sysd_config_file | dirname }} state=directory mode=0755
67+
file:
68+
path: "{{ sysd_config_file | dirname }}"
69+
state: directory
70+
mode: "755"
4171

4272
- name: Copy specific ElasticSearch Systemd config file
43-
ini_file: path={{ sysd_config_file }} section=Service option=LimitMEMLOCK value=infinity mode=0644
73+
ini_file:
74+
path: "{{ sysd_config_file }}"
75+
section: Service
76+
option: LimitMEMLOCK
77+
value: infinity
78+
mode: "644"
4479
notify:
4580
- reload systemd configuration
4681
- restart elasticsearch
4782

48-
#Copy the logging.yml
49-
- name: Copy log4j2.properties File
83+
- name: Copy jvm.options File
5084
become: yes
51-
template: src={{ es_config_log4j2 }} dest={{ es_conf_dir }}/log4j2.properties owner=root group={{ es_group }} mode=0660 force=yes
85+
template:
86+
src: "{{ es_config_jvm }}"
87+
dest: "{{ es_conf_dir }}/jvm.options"
88+
owner: root
89+
group: "{{ es_group }}"
90+
mode: "660"
91+
force: yes
5292
notify: restart elasticsearch
5393

54-
- name: Copy jvm.options File
94+
- name: Copy log4j2.properties File
5595
become: yes
56-
template: src=jvm.options.j2 dest={{ es_conf_dir }}/jvm.options owner=root group={{ es_group }} mode=0660 force=yes
96+
template:
97+
src: "{{ es_config_log4j2 }}"
98+
dest: "{{ es_conf_dir }}/log4j2.properties"
99+
owner: root
100+
group: "{{ es_group }}"
101+
mode: "660"
102+
force: yes
57103
notify: restart elasticsearch
104+
when: es_config_log4j2 != ''

tasks/elasticsearch-ssl.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
state: directory
1414
owner: root
1515
group: "{{ es_group }}"
16-
mode: 0750
16+
mode: "750"
1717

1818
- name: Upload SSL/TLS keystore
1919
copy:
2020
src: "{{ es_ssl_keystore }}"
2121
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_keystore | basename }}"
2222
owner: "{{ es_user }}"
2323
group: "{{ es_group }}"
24-
mode: 0640
24+
mode: "640"
2525
when: es_ssl_keystore and es_ssl_truststore
2626
notify: restart elasticsearch
2727
register: copy_keystore
@@ -32,7 +32,7 @@
3232
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_truststore | basename }}"
3333
owner: "{{ es_user }}"
3434
group: "{{ es_group }}"
35-
mode: 0640
35+
mode: "640"
3636
when: es_ssl_keystore and es_ssl_truststore
3737
notify: restart elasticsearch
3838
register: copy_truststore
@@ -43,7 +43,7 @@
4343
dest: "{{ es_ssl_certificate_path }}/{{ item | basename }}"
4444
owner: "{{ es_user }}"
4545
group: "{{ es_group }}"
46-
mode: 0640
46+
mode: "640"
4747
with_items:
4848
- "{{ es_ssl_key }}"
4949
- "{{ es_ssl_certificate }}"
@@ -58,7 +58,7 @@
5858
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_certificate_authority | basename }}"
5959
owner: "{{ es_user }}"
6060
group: "{{ es_group }}"
61-
mode: 0640
61+
mode: "640"
6262
#Restart if this changes
6363
notify: restart elasticsearch
6464
when: es_ssl_certificate_authority | bool

tasks/elasticsearch-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
state: directory
77
owner: root
88
group: "{{ es_group }}"
9-
mode: 2750
9+
mode: "2750"
1010

1111
- name: Copy templates to elasticsearch
1212
copy: src={{ item }} dest={{ es_conf_dir }}/templates owner=root group={{ es_group }} mode=0660

templates/elasticsearch.j2

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,23 @@ ES_HOME={{es_home}}
99
#JAVA_HOME=
1010

1111
# Elasticsearch configuration directory
12-
CONF_DIR={{ es_conf_dir }}
1312
ES_PATH_CONF={{ es_conf_dir }}
1413

15-
# Elasticsearch data directory
16-
DATA_DIR={{ es_data_dirs | array_to_str }}
17-
18-
# Elasticsearch logs directory
19-
LOG_DIR={{ es_log_dir }}
20-
2114
# Elasticsearch PID directory
2215
PID_DIR={{ es_pid_dir }}
2316

24-
ES_JVM_OPTIONS={{ es_conf_dir }}/jvm.options
17+
# Additional Java OPTS
18+
ES_JAVA_OPTS=
2519

2620
# Configure restart on package upgrade (true, every other setting will lead to not restarting)
27-
#ES_RESTART_ON_UPGRADE=true
28-
29-
# Path to the GC log file
30-
#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log
21+
#RESTART_ON_UPGRADE=true
3122

3223
################################
3324
# Elasticsearch service
3425
################################
3526

27+
# SysV init.d
28+
#
3629
# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
3730
ES_STARTUP_SLEEP_TIME=5
3831

@@ -43,17 +36,17 @@ ES_STARTUP_SLEEP_TIME=5
4336
# Specifies the maximum file descriptor number that can be opened by this process
4437
# When using Systemd, this setting is ignored and the LimitNOFILE defined in
4538
# /usr/lib/systemd/system/elasticsearch.service takes precedence
39+
#MAX_OPEN_FILES=65535
4640
{% if es_max_open_files is defined %}
47-
#MAX_OPEN_FILES
4841
MAX_OPEN_FILES={{es_max_open_files}}
4942
{% endif %}
5043

5144
# The maximum number of bytes of memory that may be locked into RAM
5245
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
53-
# in elasticsearch.yml
54-
# When using Systemd, the LimitMEMLOCK property must be set
55-
# in /usr/lib/systemd/system/elasticsearch.service
56-
#MAX_LOCKED_MEMORY=
46+
# in elasticsearch.yml.
47+
# When using systemd, LimitMEMLOCK must be set in a unit file such as
48+
# /etc/systemd/system/elasticsearch.service.d/override.conf.
49+
#MAX_LOCKED_MEMORY=unlimited
5750
{% if m_lock_enabled %}
5851
MAX_LOCKED_MEMORY=unlimited
5952
{% endif %}
@@ -65,9 +58,3 @@ MAX_LOCKED_MEMORY=unlimited
6558
{% if es_max_map_count is defined %}
6659
MAX_MAP_COUNT={{es_max_map_count}}
6760
{% endif %}
68-
69-
# Specifies the maximum number of threads that can be started.
70-
# Elasticsearch requires a minimum of 2048.
71-
{% if es_max_threads is defined %}
72-
MAX_THREADS={{ es_max_threads }}
73-
{% endif %}

0 commit comments

Comments
 (0)