Fixes issue 70, Improves plugin management, Refactoring, Updates tests, Introduces multiple data dir support
This commit is contained in:
parent
40fd3516c4
commit
0fd1f34852
16 changed files with 216 additions and 49 deletions
|
|
@ -17,32 +17,35 @@
|
|||
|
||||
#For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN.
|
||||
|
||||
- set_fact: pid_dir={{ es_pid_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
|
||||
- set_fact: instance_suffix={{inventory_hostname}}-{{ es_instance_name }}
|
||||
|
||||
- set_fact: data_dir={{ es_data_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
|
||||
- set_fact: pid_dir={{ es_pid_dir }}/{{instance_suffix}}
|
||||
|
||||
- set_fact: log_dir={{ es_log_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
|
||||
- set_fact: log_dir={{ es_log_dir }}/{{instance_suffix}}
|
||||
|
||||
- set_fact: work_dir={{ es_work_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
|
||||
- set_fact: work_dir={{ es_work_dir }}/{{instance_suffix}}
|
||||
|
||||
#Create required directories
|
||||
- name: Create PID Directory
|
||||
file: path={{ pid_dir }} state=directory owner={{ es_user }} group={{ es_group }}
|
||||
- name: Create Directories
|
||||
file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }}
|
||||
with_items:
|
||||
- "{{pid_dir}}"
|
||||
- "{{work_dir}}"
|
||||
- "{{log_dir}}"
|
||||
- "{{conf_dir}}"
|
||||
- "{{plugin_dir}}"
|
||||
|
||||
- name: Create data dir
|
||||
file: state=directory path={{ data_dir }} owner={{ es_user }} group={{ es_group }}
|
||||
- debug: msg="Data Dirs {{es_data_dirs}}"
|
||||
|
||||
- name: Create work dir
|
||||
file: state=directory path={{ work_dir }} owner={{ es_user }} group={{ es_group }}
|
||||
- set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }}
|
||||
|
||||
- name: Create log dir
|
||||
file: state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }}
|
||||
- debug: msg="Data Dirs {{data_dirs}}"
|
||||
|
||||
- name: Create Config Directory
|
||||
file: path={{ conf_dir }} state=directory owner={{ es_user }} group={{ es_group }}
|
||||
- name: Create Data Directories
|
||||
file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }}
|
||||
with_items:
|
||||
- "{{data_dirs}}"
|
||||
|
||||
- name: Create Plugin Directory
|
||||
file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }}
|
||||
|
||||
#Copy the config template
|
||||
- name: Copy Configuration File
|
||||
|
|
@ -92,3 +95,11 @@
|
|||
|
||||
- name: Delete Default Sysconfig File
|
||||
file: dest=/usr/lib/systemd/system/elasticsearch.service state=absent
|
||||
|
||||
- name: Delete Default Configuration File
|
||||
file: dest=/etc/elasticsearch/elasticsearch.yml state=absent
|
||||
|
||||
- name: Delete Default Logging File
|
||||
file: dest=/etc/elasticsearch/logging.yml state=absent
|
||||
|
||||
- debug: msg="Data Dirs {{data_dirs}}"
|
||||
|
|
@ -1,22 +1,32 @@
|
|||
---
|
||||
|
||||
#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version
|
||||
#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version, or if no plugins listed. Otherwise it is false and requires explicitly setting.
|
||||
- set_fact: es_plugins_reinstall=true
|
||||
when: elasticsearch_install.changed
|
||||
when: elasticsearch_install.changed or es_plugins is not defined or es_plugins is none
|
||||
|
||||
- set_fact: list_command="list"
|
||||
|
||||
- set_fact: list_command="--list"
|
||||
when: es_version | version_compare('2.0', '<')
|
||||
|
||||
#List currently installed plugins
|
||||
- shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-"
|
||||
register: installed_plugins
|
||||
changed_when: False
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
|
||||
|
||||
#This needs to removed installed plugins not those listed
|
||||
#This needs to removes any currently installed plugins
|
||||
- name: Remove elasticsearch plugins
|
||||
command: "{{es_home}}/bin/plugin remove {{ item.plugin }} --silent"
|
||||
command: "{{es_home}}/bin/plugin remove {{item}} --silent"
|
||||
ignore_errors: yes
|
||||
with_items: es_plugins
|
||||
when: es_plugins_reinstall
|
||||
with_items: installed_plugins.stdout_lines
|
||||
when: es_plugins_reinstall and installed_plugins.stdout_lines | length > 0 and not 'No plugin detected' in installed_plugins.stdout_lines[0]
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
- name: Install elasticsearch plugins
|
||||
#debug: var=item
|
||||
|
|
@ -25,7 +35,7 @@
|
|||
failed_when: "'Failed to install' in plugin_installed.stderr"
|
||||
changed_when: plugin_installed.rc == 0
|
||||
with_items: es_plugins
|
||||
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Debian'
|
||||
when: es_plugins is defined and not es_plugins is none
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
- include: elasticsearch-scripts.yml
|
||||
when: es_scripts
|
||||
- include: elasticsearch-plugins.yml
|
||||
when: es_plugins is defined
|
||||
when: es_plugins is defined or es_plugins_reinstall
|
||||
- include: elasticsearch-service.yml
|
||||
- include: elasticsearch-templates.yml
|
||||
when: es_templates
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue