Kevin Carter db9f0fae09
Add options for better memory management
This change allows EL to have customizable heap sizes which will
automatically set themselves to the recommended size as advised by the
elastic documentation.

https://www.elastic.co/guide/en/elasticsearch/reference/6.2/heap-size.html

Change-Id: I55d014dab37bf5e5a4806bd19d4e07e072f9fa7e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-04-27 23:29:20 -05:00

89 lines
2.4 KiB
YAML

---
- name: Install Elastic Search
hosts: "elastic-logstash"
become: true
vars_files:
- vars/variables.yml
tasks:
- name: Set half memory fact
set_fact:
h_mem: "{{ ansible_memtotal_mb // 2 }}"
- name: Set logstash facts
set_fact:
elastic_heap_size: "{{ ((h_mem | int) > 30720) | ternary(30720, h_mem) }}"
when:
- elastic_heap_size is undefined
- name: Configure systcl vm.max_map_count=262144 on container hosts
sysctl:
name: "vm.max_map_count"
value: "262144"
state: "present"
reload: "yes"
delegate_to: "{{ physical_host }}"
tags:
- sysctl
- name: Ensure mount directories exists
file:
path: "/openstack/{{ inventory_hostname }}/elasticsearch"
state: "directory"
delegate_to: "{{ physical_host }}"
- name: elasticsearch datapath bind mount
lxc_container:
name: "{{ inventory_hostname }}"
container_command: |
[[ ! -d "/var/lib/elasticsearch" ]] && mkdir -p "/var/lib/elasticsearch"
container_config:
- "lxc.mount.entry=/openstack/{{ inventory_hostname }}/elasticsearch var/lib/elasticsearch none bind 0 0"
delegate_to: "{{ physical_host }}"
when:
- physical_host != inventory_hostname
- container_tech | default('lxc') == 'lxc'
- name: Ensure Java is installed
apt:
name: openjdk-8-jre
state: present
install_recommends: yes
update_cache: yes
- include_tasks: common_task_install_elk_repo.yml
- name: Ensure Elastic search is installed
apt:
name: elasticsearch
state: present
update_cache: yes
- name: Drop elasticsearch conf file
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- src: templates/elasticsearch.yml.j2
dest: /etc/elasticsearch/elasticsearch.yml
- src: templates/jvm.options.j2
dest: /etc/elasticsearch/jvm.options
tags:
- config
- name: Ensure elasticsearch ownership
file:
path: /var/lib/elasticsearch
owner: elasticsearch
group: elasticsearch
recurse: true
tags:
- config
- name: Enable and restart elastic
systemd:
name: "elasticsearch"
enabled: true
state: restarted
tags:
- config