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

Use default config files #637

Merged
merged 11 commits into from
Dec 5, 2019
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ In addition to es_config, the following parameters allow the customization of th
* ```update_java``` Updates Java to the latest version. (true or false (default))
* ```es_max_map_count``` maximum number of VMA (Virtual Memory Areas) a process can own. Defaults to 262144.
* ```es_max_open_files``` the maximum file descriptor number that can be opened by this process. Defaults to 65536.
* ```es_max_threads``` the maximum number of threads the process can start. Defaults to 2048 (the minimum required by elasticsearch).
* ```es_debian_startup_timeout``` how long Debian-family SysV init scripts wait for the service to start, in seconds. Defaults to 10 seconds.
* ```es_use_repository``` Setting this to `false` will stop Ansible from using the official Elastic package from any repository configured on the system.
* ```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.
Expand Down
5 changes: 3 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ es_templates: false
es_user: elasticsearch
es_group: elasticsearch
es_config: {}
es_config_log4j2: log4j2.properties.j2
es_config_default: "elasticsearch.j2"
es_config_log4j2: ""
es_config_jvm: "jvm.options.j2"
#Need to provide default directories
es_conf_dir: "/etc/elasticsearch"
es_pid_dir: "/var/run/elasticsearch"
Expand All @@ -29,7 +31,6 @@ es_data_dirs:
es_log_dir: "/var/log/elasticsearch"
es_action_auto_create_index: true
es_max_open_files: 65536
es_max_threads: 8192
es_max_map_count: 262144
es_allow_downgrades: false
es_xpack_features: []
Expand Down
76 changes: 0 additions & 76 deletions files/logging/log4j2.properties.custom.j2

This file was deleted.

71 changes: 59 additions & 12 deletions tasks/elasticsearch-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,101 @@
#Create conf directory
- name: Create Configuration Directory
become: yes
file: path={{ es_conf_dir }} state=directory owner=root group={{ es_group }} mode=2750
file:
path: "{{ es_conf_dir }}"
state: directory
owner: root
group: "{{ es_group }}"
mode: "2750"

#Create pid directory
- name: Create PID Directory
become: yes
file: path={{ es_pid_dir }} state=directory owner={{ es_user }} group={{ es_group }} mode=0755
file:
path: "{{ es_pid_dir }}"
state: directory
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: "755"

#Create required directories
- name: Create Others Directories
become: yes
file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} mode=2750
file:
path: "{{ item }}"
state: directory
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: "2750"
with_items:
- "{{ es_log_dir }}"
- "{{ es_data_dirs }}"

#Copy the config template
- name: Copy Configuration File
become: yes
template: src=elasticsearch.yml.j2 dest={{ es_conf_dir }}/elasticsearch.yml owner=root group={{ es_group }} mode=0660 force=yes
template:
src: elasticsearch.yml.j2
dest: "{{ es_conf_dir }}/elasticsearch.yml"
owner: root
group: "{{ es_group }}"
mode: "660"
force: yes
register: system_change
notify: restart elasticsearch

#Copy the default file
- name: Copy Default File
become: yes
template: src=elasticsearch.j2 dest={{ default_file }} owner=root group={{ es_group }} mode=0660 force=yes
template:
src: "{{ es_config_default }}"
dest: "{{ default_file }}"
owner: root
group: "{{ es_group }}"
mode: "660"
force: yes
notify: restart elasticsearch

#Copy the systemd specific file if systemd is installed
- when: use_system_d and m_lock_enabled
become: yes
block:
- name: Make sure destination dir exists
file: path={{ sysd_config_file | dirname }} state=directory mode=0755
file:
path: "{{ sysd_config_file | dirname }}"
state: directory
mode: "755"

- name: Copy specific ElasticSearch Systemd config file
ini_file: path={{ sysd_config_file }} section=Service option=LimitMEMLOCK value=infinity mode=0644
ini_file:
path: "{{ sysd_config_file }}"
section: Service
option: LimitMEMLOCK
value: infinity
mode: "644"
notify:
- reload systemd configuration
- restart elasticsearch

#Copy the logging.yml
- name: Copy log4j2.properties File
- name: Copy jvm.options File
become: yes
template: src={{ es_config_log4j2 }} dest={{ es_conf_dir }}/log4j2.properties owner=root group={{ es_group }} mode=0660 force=yes
template:
src: "{{ es_config_jvm }}"
dest: "{{ es_conf_dir }}/jvm.options"
owner: root
group: "{{ es_group }}"
mode: "660"
force: yes
notify: restart elasticsearch

- name: Copy jvm.options File
- name: Copy log4j2.properties File
become: yes
template: src=jvm.options.j2 dest={{ es_conf_dir }}/jvm.options owner=root group={{ es_group }} mode=0660 force=yes
template:
src: "{{ es_config_log4j2 }}"
dest: "{{ es_conf_dir }}/log4j2.properties"
owner: root
group: "{{ es_group }}"
mode: "660"
force: yes
notify: restart elasticsearch
when: es_config_log4j2 != ''
10 changes: 5 additions & 5 deletions tasks/elasticsearch-ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
state: directory
owner: root
group: "{{ es_group }}"
mode: 0750
mode: "750"

- name: Upload SSL/TLS keystore
copy:
src: "{{ es_ssl_keystore }}"
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_keystore | basename }}"
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: 0640
mode: "640"
when: es_ssl_keystore and es_ssl_truststore
notify: restart elasticsearch
register: copy_keystore
Expand All @@ -32,7 +32,7 @@
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_truststore | basename }}"
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: 0640
mode: "640"
when: es_ssl_keystore and es_ssl_truststore
notify: restart elasticsearch
register: copy_truststore
Expand All @@ -43,7 +43,7 @@
dest: "{{ es_ssl_certificate_path }}/{{ item | basename }}"
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: 0640
mode: "640"
with_items:
- "{{ es_ssl_key }}"
- "{{ es_ssl_certificate }}"
Expand All @@ -58,7 +58,7 @@
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_certificate_authority | basename }}"
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: 0640
mode: "640"
#Restart if this changes
notify: restart elasticsearch
when: es_ssl_certificate_authority | bool
Expand Down
2 changes: 1 addition & 1 deletion tasks/elasticsearch-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
state: directory
owner: root
group: "{{ es_group }}"
mode: 2750
mode: "2750"

- name: Copy templates to elasticsearch
copy: src={{ item }} dest={{ es_conf_dir }}/templates owner=root group={{ es_group }} mode=0660
Expand Down
33 changes: 10 additions & 23 deletions templates/elasticsearch.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,23 @@ ES_HOME={{es_home}}
#JAVA_HOME=

# Elasticsearch configuration directory
CONF_DIR={{ es_conf_dir }}
ES_PATH_CONF={{ es_conf_dir }}

# Elasticsearch data directory
DATA_DIR={{ es_data_dirs | array_to_str }}

# Elasticsearch logs directory
LOG_DIR={{ es_log_dir }}

# Elasticsearch PID directory
PID_DIR={{ es_pid_dir }}

ES_JVM_OPTIONS={{ es_conf_dir }}/jvm.options
# Additional Java OPTS
ES_JAVA_OPTS=

# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#ES_RESTART_ON_UPGRADE=true

# Path to the GC log file
#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log
#RESTART_ON_UPGRADE=true

################################
# Elasticsearch service
################################

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

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

# The maximum number of bytes of memory that may be locked into RAM
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
# in elasticsearch.yml
# When using Systemd, the LimitMEMLOCK property must be set
# in /usr/lib/systemd/system/elasticsearch.service
#MAX_LOCKED_MEMORY=
# in elasticsearch.yml.
# When using systemd, LimitMEMLOCK must be set in a unit file such as
# /etc/systemd/system/elasticsearch.service.d/override.conf.
#MAX_LOCKED_MEMORY=unlimited
{% if m_lock_enabled %}
MAX_LOCKED_MEMORY=unlimited
{% endif %}
Expand All @@ -65,9 +58,3 @@ MAX_LOCKED_MEMORY=unlimited
{% if es_max_map_count is defined %}
MAX_MAP_COUNT={{es_max_map_count}}
{% endif %}

# Specifies the maximum number of threads that can be started.
# Elasticsearch requires a minimum of 2048.
{% if es_max_threads is defined %}
MAX_THREADS={{ es_max_threads }}
{% endif %}
Loading