
* Implements G1 GC optionally. The variable `elastic_g1gc_enabled` has been added with a default of false. If this option is set true and the system has more than 4GiB of RAM G1GC will be enabled. * Adds new thread options * Better constraints coordination nodes * Interface recover speed has been limited * Buffer size is now set correctly * Serialize elk deployment so that upgrades are non-impacting Change-Id: I89224eeaf4ed29c3bb1d7f8010b69503dbc74e11 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
242 lines
6.6 KiB
YAML
242 lines
6.6 KiB
YAML
---
|
|
|
|
- name: Run serialization detection
|
|
hosts: "elastic-logstash:kibana"
|
|
gather_facts: true
|
|
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
tasks:
|
|
- include_tasks: common_task_data_node_hosts.yml
|
|
|
|
- name: Group by stand alone masters
|
|
group_by:
|
|
key: elastic_masters
|
|
parents: elastic-logstash
|
|
when:
|
|
- inventory_hostname in master_nodes
|
|
|
|
- name: Group by non stand alone masters
|
|
group_by:
|
|
key: elastic_non_masters
|
|
parents: elastic-logstash
|
|
when:
|
|
- inventory_hostname in (data_nodes | difference(master_nodes))
|
|
|
|
- name: Group by coordinators
|
|
group_by:
|
|
key: elastic_coordinators
|
|
parents: elastic-logstash
|
|
when:
|
|
- inventory_hostname in groups['kibana']
|
|
tags:
|
|
- always
|
|
|
|
- name: Install Elastic Search
|
|
hosts: "elastic_coordinators:elastic_masters:elastic_non_masters"
|
|
serial: "33%"
|
|
become: true
|
|
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
vars:
|
|
temp_dir: /var/lib/elasticsearch/tmp
|
|
nfs_query: "[?fstype=='nfs' || fstype=='nfs4']"
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
tasks:
|
|
- name: Set memory fact to half
|
|
set_fact:
|
|
h_mem: "{{ (ansible_memtotal_mb | int) // 2 }}"
|
|
when:
|
|
- h_mem is not defined
|
|
tags:
|
|
- always
|
|
|
|
- name: Set elasticsearch facts
|
|
set_fact:
|
|
elastic_heap_size: "{{ ((h_mem | int) > 30720) | ternary(30720, h_mem) }}"
|
|
elastic_log_rotate_path: "/var/log/elasticsearch"
|
|
tags:
|
|
- always
|
|
|
|
- name: Set kibana elasticsearch facts
|
|
block:
|
|
- name: Set kibana as elasticsearch coordinators
|
|
set_fact:
|
|
elasticsearch_node_master: false
|
|
elasticsearch_node_data: false
|
|
elasticsearch_node_ingest: false
|
|
elastic_coordination_node: true
|
|
elastic_heap_size: "{{ (elastic_heap_size | int) // 3 }}"
|
|
elastic_thread_pool_size: "{{ ((ansible_processor_cores | int) > 4) | ternary(4, (ansible_processor_cores // 2)) }}"
|
|
when:
|
|
- inventory_hostname in (groups['kibana'] | default([])) and
|
|
not inventory_hostname in (groups['elastic-logstash'] | default([]))
|
|
tags:
|
|
- always
|
|
|
|
- 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: "{{ elk_package_state | default('present') }}"
|
|
install_recommends: yes
|
|
update_cache: yes
|
|
register: _apt_task
|
|
until: _apt_task is success
|
|
retries: 3
|
|
delay: 2
|
|
tags:
|
|
- package_install
|
|
|
|
- include_tasks: common_task_install_elk_repo.yml
|
|
|
|
- name: Ensure elasticsearch is installed
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
update_cache: yes
|
|
with_items:
|
|
- logrotate
|
|
- elasticsearch
|
|
register: _apt_task
|
|
until: _apt_task is success
|
|
retries: 3
|
|
delay: 2
|
|
notify:
|
|
- Enable and restart elastic
|
|
tags:
|
|
- package_install
|
|
|
|
- name: exit playbook after uninstall
|
|
meta: end_play
|
|
when:
|
|
- (elk_package_state | default('present')) == 'absent'
|
|
|
|
post_tasks:
|
|
- name: Create elasticsearch systemd service config dir
|
|
file:
|
|
path: "/etc/systemd/system/elasticsearch.service.d"
|
|
state: "directory"
|
|
group: "root"
|
|
owner: "root"
|
|
mode: "0755"
|
|
|
|
- name: Apply systemd options
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "/etc/systemd/system/elasticsearch.service.d/{{ item.dest }}"
|
|
mode: "0644"
|
|
with_items:
|
|
- { src: "systemd.elasticsearch-overrides.conf.j2", dest: "elasticsearch-overrides.conf" }
|
|
notify:
|
|
- Enable and restart elastic
|
|
|
|
- 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
|
|
- src: templates/es-log4j2.properties.j2
|
|
dest: /etc/elasticsearch/log4j2.properties
|
|
notify:
|
|
- Enable and restart elastic
|
|
tags:
|
|
- config
|
|
|
|
- name: Ensure elasticsearch ownership
|
|
file:
|
|
path: /var/lib/elasticsearch
|
|
owner: elasticsearch
|
|
group: elasticsearch
|
|
recurse: true
|
|
register: e_perms
|
|
until: e_perms is success
|
|
retries: 3
|
|
delay: 1
|
|
tags:
|
|
- config
|
|
|
|
- name: Ensure logstash tmp dir
|
|
file:
|
|
path: "/var/lib/elasticsearch/tmp"
|
|
state: directory
|
|
owner: "elasticsearch"
|
|
group: "elasticsearch"
|
|
mode: "0750"
|
|
|
|
- name: Create logrotate config
|
|
template:
|
|
src: "templates/logrotate.j2"
|
|
dest: "/etc/logrotate.d/elasticsearch"
|
|
|
|
- name: Ensure nfs client is available if necessary
|
|
package:
|
|
name: nfs-common
|
|
state: present
|
|
when:
|
|
- elastic_shared_fs_repos is defined
|
|
- (elastic_shared_fs_repos|json_query(nfs_query)) | length > 0
|
|
|
|
- name: Ensure backup filesystems are mounted
|
|
mount:
|
|
fstype: "{{ item.fstype }}"
|
|
src: "{{ item.src }}"
|
|
opts: "{{ item.opts }}"
|
|
path: "{{ item.path }}"
|
|
state: "{{ item.state }}"
|
|
with_items:
|
|
- "{{ elastic_shared_fs_repos }}"
|
|
when:
|
|
- elastic_shared_fs_repos is defined and elastic_shared_fs_repos | length > 0
|
|
|
|
handlers:
|
|
- name: Enable and restart elastic
|
|
systemd:
|
|
name: "elasticsearch"
|
|
enabled: true
|
|
state: restarted
|
|
daemon_reload: true
|
|
when:
|
|
- (elk_package_state | default('present')) != 'absent'
|
|
tags:
|
|
- config
|
|
|
|
tags:
|
|
- server-install
|