From 4e1188b0ccd9fe903b04b227db11f60758c0b98c Mon Sep 17 00:00:00 2001 From: Miguelangel Freitas Date: Mon, 29 Jan 2018 01:04:08 +0000 Subject: [PATCH] Configuring system resources on Elasticsearch role --- ansible-role-elasticsearch/tasks/main.yml | 43 +++++++++++++++ .../templates/elasticsearch_nonsystemd.j2 | 52 +++++++++++++++++++ .../templates/elasticsearch_systemd.conf.j2 | 3 ++ 3 files changed, 98 insertions(+) create mode 100644 ansible-role-elasticsearch/templates/elasticsearch_nonsystemd.j2 create mode 100644 ansible-role-elasticsearch/templates/elasticsearch_systemd.conf.j2 diff --git a/ansible-role-elasticsearch/tasks/main.yml b/ansible-role-elasticsearch/tasks/main.yml index 17e1181f..8c83861d 100644 --- a/ansible-role-elasticsearch/tasks/main.yml +++ b/ansible-role-elasticsearch/tasks/main.yml @@ -5,6 +5,49 @@ - import_tasks: Debian.yml when: ansible_os_family == "Debian" +- name: Create elasticsearch.service.d folder. + file: path=/etc/systemd/system/elasticsearch.service.d/ state=directory + when: + - ansible_service_mgr == "systemd" + +- name: Configure Elasticsearch System Resources. + template: + src: elasticsearch_systemd.conf.j2 + dest: /etc/systemd/system/elasticsearch.service.d/elasticsearch.conf + owner: root + group: elasticsearch + mode: 0660 + notify: restart elasticsearch + tags: configure + when: + - ansible_service_mgr == "systemd" + +- name: Debian/Ubuntu | Configure Elasticsearch System Resources. + template: + src: elasticsearch_nonsystemd.j2 + dest: /etc/default/elasticsearch + owner: root + group: elasticsearch + mode: 0660 + notify: restart elasticsearch + tags: configure + when: + - ansible_service_mgr != "systemd" + - ansible_os_family == "Debian" + +- name: RedHat/CentOS/Fedora | Configure Elasticsearch System Resources. + template: + src: elasticsearch_nonsystemd.j2 + dest: /etc/sysconfig/elasticsearch + owner: root + group: elasticsearch + mode: 0660 + notify: restart elasticsearch + tags: configure + when: + - ansible_service_mgr != "systemd" + - ansible_os_family == "RedHat" + - name: Configure Elasticsearch. template: src: elasticsearch.yml.j2 diff --git a/ansible-role-elasticsearch/templates/elasticsearch_nonsystemd.j2 b/ansible-role-elasticsearch/templates/elasticsearch_nonsystemd.j2 new file mode 100644 index 00000000..fd1ce407 --- /dev/null +++ b/ansible-role-elasticsearch/templates/elasticsearch_nonsystemd.j2 @@ -0,0 +1,52 @@ +# {{ ansible_managed }} +################################ +# Elasticsearch +################################ + +# Elasticsearch home directory +#ES_HOME=/usr/share/elasticsearch + +# Elasticsearch Java path +#JAVA_HOME= + +# Elasticsearch configuration directory +ES_PATH_CONF=/etc/elasticsearch + +# Elasticsearch PID directory +#PID_DIR=/var/run/elasticsearch + +# Additional Java OPTS +#ES_JAVA_OPTS= + +# Configure restart on package upgrade (true, every other setting will lead to not restarting) +#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 + +################################ +# System properties +################################ + +# 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=65536 + +# 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, LimitMEMLOCK must be set in a unit file such as +# /etc/systemd/system/elasticsearch.service.d/override.conf. +MAX_LOCKED_MEMORY=unlimited + +# Maximum number of VMA (Virtual Memory Areas) a process can own +# When using Systemd, this setting is ignored and the 'vm.max_map_count' +# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf +#MAX_MAP_COUNT=262144 diff --git a/ansible-role-elasticsearch/templates/elasticsearch_systemd.conf.j2 b/ansible-role-elasticsearch/templates/elasticsearch_systemd.conf.j2 new file mode 100644 index 00000000..8e52df3f --- /dev/null +++ b/ansible-role-elasticsearch/templates/elasticsearch_systemd.conf.j2 @@ -0,0 +1,3 @@ +# {{ ansible_managed }} +[Service] +LimitMEMLOCK=infinity