e0f77d531a
Systemd overrides have been added to the service unit files for all beats and services. All of the playbooks have been updated to make them look and feel uniform. This also sets handlers within the playbooks so that we're improving the idempotence. Change-Id: I2dd3183dae4bfddc607cc74f9dfb7af115b80abc Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
177 lines
4.7 KiB
YAML
177 lines
4.7 KiB
YAML
---
|
|
- name: Install Elastic Search
|
|
hosts: "elastic-logstash:kibana"
|
|
become: true
|
|
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
vars:
|
|
temp_dir: /var/lib/elasticsearch/tmp
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
pre_tasks:
|
|
- include_tasks: common_task_data_node_hosts.yml
|
|
tags:
|
|
- always
|
|
|
|
tasks:
|
|
- name: Set memory fact to half
|
|
set_fact:
|
|
h_mem: "{{ (ansible_memtotal_mb | int) // 2 }}"
|
|
tags:
|
|
- always
|
|
|
|
- name: Set logstash facts
|
|
set_fact:
|
|
elastic_heap_size: "{{ ((h_mem | int) > 30720) | ternary(30720, h_mem) }}"
|
|
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_heap_size: "{{ (elastic_heap_size | int) // 3 }}"
|
|
when:
|
|
- inventory_hostname in (groups['kibana'] | difference(groups['elastic-logstash']))
|
|
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: elasticsearch
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
update_cache: yes
|
|
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"
|
|
|
|
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
|