2015-10-22 19:09:53 +01:00
---
# Configure Elasticsearch Node
2015-11-27 19:39:47 +00:00
2015-12-21 13:27:45 +00:00
#Use systemd for the following distributions:
#
#Ubuntu 15 and up
#Debian 8 and up
#Centos 7 and up
#Relies on elasticsearch distribution installing a serviced script to determine whether one should be copied.
2015-11-27 19:39:47 +00:00
- stat : path={{sysd_script}}
register : systemd_service
2015-12-21 13:27:45 +00:00
- set_fact : use_system_d={{systemd_service.stat.exists and ((ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution == 'CentOS' and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>='))) }}
2015-11-27 21:43:49 +00:00
2015-11-27 19:39:47 +00:00
- set_fact : instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}}
2015-11-27 21:43:49 +00:00
when : use_system_d
2015-11-27 19:39:47 +00:00
2015-11-27 18:12:59 +00:00
#For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN.
2015-10-22 19:09:53 +01:00
2015-12-13 22:46:50 +00:00
- set_fact : pid_dir={{ es_pid_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
2015-11-25 15:28:09 +00:00
- set_fact : data_dir={{ es_data_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
- set_fact : log_dir={{ es_log_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
- set_fact : work_dir={{ es_work_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
2015-11-27 18:12:59 +00:00
#Create required directories
2015-10-22 19:09:53 +01:00
- name : Create PID Directory
2015-11-25 15:28:09 +00:00
file : path={{ pid_dir }} state=directory owner={{ es_user }} group={{ es_group }}
2015-10-22 19:09:53 +01:00
- name : Create data dir
2015-11-25 15:28:09 +00:00
file : state=directory path={{ data_dir }} owner={{ es_user }} group={{ es_group }}
2015-10-22 19:09:53 +01:00
- name : Create work dir
2015-11-25 15:28:09 +00:00
file : state=directory path={{ work_dir }} owner={{ es_user }} group={{ es_group }}
2015-10-22 19:09:53 +01:00
- name : Create log dir
2015-11-25 15:28:09 +00:00
file : state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }}
2015-10-22 19:09:53 +01:00
2015-11-27 18:12:59 +00:00
- name : Create Config Directory
2015-12-13 22:46:50 +00:00
file : path={{ conf_dir }} state=directory owner={{ es_user }} group={{ es_group }}
- name : Create Plugin Directory
file : state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }}
2015-10-22 19:09:53 +01:00
2015-11-27 18:12:59 +00:00
#Copy the config template
- name : Copy Configuration File
2015-12-13 22:46:50 +00:00
template : src=elasticsearch.yml.j2 dest={{conf_dir}}/elasticsearch.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
2015-11-27 18:12:59 +00:00
notify : restart elasticsearch
2015-10-22 19:09:53 +01:00
2015-11-27 18:12:59 +00:00
#Copy the instance specific default file
- name : Copy Default File for Instance
template : src=elasticsearch.j2 dest={{instance_default_file}} mode=0644 force=yes
notify : restart elasticsearch
2015-10-22 19:09:53 +01:00
2015-11-27 18:12:59 +00:00
#Copy the instance specific init file
- name : Copy Debian Init File for Instance
template : src=init/debian/elasticsearch.j2 dest={{instance_init_script}} mode=0755 force=yes
2015-10-22 19:09:53 +01:00
when : ansible_os_family == 'Debian'
2015-12-21 13:27:45 +00:00
notify : restart elasticsearch
2015-10-22 19:09:53 +01:00
2015-11-27 18:12:59 +00:00
#Copy the instance specific init file
- name : Copy Redhat Init File for Instance
template : src=init/redhat/elasticsearch.j2 dest={{instance_init_script}} mode=0755 force=yes
2015-11-27 19:39:47 +00:00
when : ansible_os_family == 'RedHat'
2015-12-21 13:27:45 +00:00
notify : restart elasticsearch
2015-10-22 19:09:53 +01:00
2015-11-27 18:12:59 +00:00
#Copy the systemd specific file if systemd is installed
- name : Copy Systemd File for Instance
template : src=systemd/elasticsearch.j2 dest={{instance_sysd_script}} mode=0644 force=yes
2015-11-27 21:43:49 +00:00
when : use_system_d
2015-11-27 18:12:59 +00:00
notify : restart elasticsearch
2015-10-22 19:09:53 +01:00
2015-11-26 14:19:25 +00:00
#Copy the logging.yml
2015-11-27 21:09:58 +00:00
- name : Copy Logging.yml File for Instance
2015-12-13 22:46:50 +00:00
template : src=logging.yml.j2 dest={{conf_dir}}/logging.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
2015-12-14 19:34:09 +00:00
notify : restart elasticsearch
#Clean up un-wanted package scripts to avoid confusion