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
63
README.md
63
README.md
|
|
@ -8,7 +8,7 @@ Ansible role for Elasticsearch. Currently this works on Debian and RedHat based
|
||||||
* Centos 6
|
* Centos 6
|
||||||
* Centos 7
|
* Centos 7
|
||||||
|
|
||||||
The latest Elasticsearch versions of 1.7.x and 2.1.x are actively tested.
|
The latest Elasticsearch versions of 1.7.x and 2.x are actively tested.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
@ -54,7 +54,18 @@ The following illustrates applying configuration parameters to an Elasticsearch
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
roles:
|
roles:
|
||||||
#expand to all available parameters
|
#expand to all available parameters
|
||||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp",
|
||||||
|
es_config: {
|
||||||
|
node.name: "node1",
|
||||||
|
cluster.name: "custom-cluster",
|
||||||
|
discovery.zen.ping.unicast.hosts: "localhost:9301",
|
||||||
|
http.port: 9201,
|
||||||
|
transport.tcp.port: 9301,
|
||||||
|
node.data: false,
|
||||||
|
node.master: true,
|
||||||
|
bootstrap.mlockall: true,
|
||||||
|
discovery.zen.ping.multicast.enabled: false }
|
||||||
|
}
|
||||||
vars:
|
vars:
|
||||||
es_scripts: false
|
es_scripts: false
|
||||||
es_templates: false
|
es_templates: false
|
||||||
|
|
@ -84,7 +95,18 @@ A more complex example:
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
roles:
|
roles:
|
||||||
#expand to all available parameters
|
#expand to all available parameters
|
||||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp",
|
||||||
|
es_config: {
|
||||||
|
node.name: "node1",
|
||||||
|
cluster.name: "custom-cluster",
|
||||||
|
discovery.zen.ping.unicast.hosts: "localhost:9301",
|
||||||
|
http.port: 9201,
|
||||||
|
transport.tcp.port: 9301,
|
||||||
|
node.data: false,
|
||||||
|
node.master: true,
|
||||||
|
bootstrap.mlockall: true,
|
||||||
|
discovery.zen.ping.multicast.enabled: false }
|
||||||
|
}
|
||||||
vars:
|
vars:
|
||||||
es_scripts: false
|
es_scripts: false
|
||||||
es_templates: false
|
es_templates: false
|
||||||
|
|
@ -126,8 +148,28 @@ recommended in any multi node cluster configuration.
|
||||||
|
|
||||||
- hosts: data_nodes
|
- hosts: data_nodes
|
||||||
roles:
|
roles:
|
||||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: true, node.master: false, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } }
|
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: "/opt/elasticsearch",
|
||||||
- { role: elasticsearch, es_instance_name: "node2", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } }
|
es_config: {
|
||||||
|
"discovery.zen.ping.multicast.enabled": false,
|
||||||
|
discovery.zen.ping.unicast.hosts: "elastic02:9300",
|
||||||
|
http.port: 9200,
|
||||||
|
transport.tcp.port: 9300,
|
||||||
|
node.data: true,
|
||||||
|
node.master: false,
|
||||||
|
bootstrap.mlockall: false,
|
||||||
|
discovery.zen.ping.multicast.enabled: false }
|
||||||
|
}
|
||||||
|
- { role: elasticsearch, es_instance_name: "node2",
|
||||||
|
es_config: {
|
||||||
|
"discovery.zen.ping.multicast.enabled": false,
|
||||||
|
discovery.zen.ping.unicast.hosts: "elastic02:9300",
|
||||||
|
http.port: 9201,
|
||||||
|
transport.tcp.port: 9301,
|
||||||
|
node.data: true,
|
||||||
|
node.master: false,
|
||||||
|
bootstrap.mlockall: false,
|
||||||
|
discovery.zen.ping.multicast.enabled: false }
|
||||||
|
}
|
||||||
vars:
|
vars:
|
||||||
es_scripts: false
|
es_scripts: false
|
||||||
es_templates: false
|
es_templates: false
|
||||||
|
|
@ -159,7 +201,7 @@ Following variables affect the versions installed:
|
||||||
* ```es_version``` (e.g. "1.5.2").
|
* ```es_version``` (e.g. "1.5.2").
|
||||||
* ```es_start_service``` (true (default) or false)
|
* ```es_start_service``` (true (default) or false)
|
||||||
* ```es_plugins_reinstall``` (true or false (default) )
|
* ```es_plugins_reinstall``` (true or false (default) )
|
||||||
* ```es_plugins``` (an array of plugin definitons e.g.:
|
* ```es_plugins``` (an array of plugin definitions e.g.:
|
||||||
|
|
||||||
```
|
```
|
||||||
es_plugins:
|
es_plugins:
|
||||||
|
|
@ -183,10 +225,12 @@ By default, each node on a host will be installed to use unique pid, plugin, wor
|
||||||
controlled by the following parameters:
|
controlled by the following parameters:
|
||||||
|
|
||||||
* ```es_pid_dir``` - defaults to "/var/run/elasticsearch".
|
* ```es_pid_dir``` - defaults to "/var/run/elasticsearch".
|
||||||
* ```es_data_dir``` - defaults to "/var/lib/elasticsearch".
|
* ```es_data_dirs``` - defaults to "/var/lib/elasticsearch". This can be a list or comma separated string e.g. ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"] or "/opt/elasticsearch/data-1,/opt/elasticsearch/data-2"
|
||||||
* ```es_log_dir``` - defaults to "/var/log/elasticsearch".
|
* ```es_log_dir``` - defaults to "/var/log/elasticsearch".
|
||||||
* ```es_work_dir``` - defaults to "/tmp/elasticsearch".
|
* ```es_work_dir``` - defaults to "/tmp/elasticsearch".
|
||||||
* ```es_plugin_dir``` - defaults to "/usr/share/elasticsearch/plugins".
|
* ```es_plugin_dir``` - defaults to "/usr/share/elasticsearch/plugins".
|
||||||
|
* ```es_restart_on_change``` - defaults to true. If false, changes will not result in Elasticsearch being restarted.
|
||||||
|
* ```es_plugins_reinstall``` - defaults to false. If true, all currently installed plugins will be removed from a node. Listed plugins will then be re-installed.
|
||||||
|
|
||||||
This role ships with sample scripts and templates located in the [files/scripts/](files/scripts) and [files/templates/](files/templates) directories, respectively. These variables are used with the Ansible [with_fileglob](http://docs.ansible.com/ansible/playbooks_loops.html#id4) loop. When setting the globs, be sure to use an absolute path.
|
This role ships with sample scripts and templates located in the [files/scripts/](files/scripts) and [files/templates/](files/templates) directories, respectively. These variables are used with the Ansible [with_fileglob](http://docs.ansible.com/ansible/playbooks_loops.html#id4) loop. When setting the globs, be sure to use an absolute path.
|
||||||
* ```es_scripts_fileglob``` - defaults to `<role>/files/scripts/`.
|
* ```es_scripts_fileglob``` - defaults to `<role>/files/scripts/`.
|
||||||
|
|
@ -203,3 +247,8 @@ all supported platforms.
|
||||||
Elasticsearch restarted where required.
|
Elasticsearch restarted where required.
|
||||||
* Systemd is used for Ubuntu versions >= 15, Debian >=8, Centos >=7. All other versions use init for service scripts.
|
* Systemd is used for Ubuntu versions >= 15, Debian >=8, Centos >=7. All other versions use init for service scripts.
|
||||||
|
|
||||||
|
## IMPORTANT NOTES RE PLUGIN MANAGEMENT
|
||||||
|
|
||||||
|
* If the ES version is changed, all plugins will be removed. Those listed in the playbook will be re-installed. This is behaviour is required in ES 2.x.
|
||||||
|
* If no plugins are listed in the playbook for a node, all currently installed plugins will be removed.
|
||||||
|
* The role does not currently support automatic detection of differences between installed and listed plugins (other than if none are listed). Should users wish to change installed plugins should set es_plugins_reinstall to true. This will cause all currently installed plugins to be removed and those listed to be installed. Change detection will be implemented in future releases.
|
||||||
|
|
@ -13,7 +13,7 @@ es_group: elasticsearch
|
||||||
es_config: {}
|
es_config: {}
|
||||||
#Need to provide default directories
|
#Need to provide default directories
|
||||||
es_pid_dir: "/var/run/elasticsearch"
|
es_pid_dir: "/var/run/elasticsearch"
|
||||||
es_data_dir: "/var/lib/elasticsearch"
|
es_data_dirs: "/var/lib/elasticsearch"
|
||||||
es_log_dir: "/var/log/elasticsearch"
|
es_log_dir: "/var/log/elasticsearch"
|
||||||
es_work_dir: "/tmp/elasticsearch"
|
es_work_dir: "/tmp/elasticsearch"
|
||||||
es_plugin_dir: "/usr/share/elasticsearch/plugins"
|
es_plugin_dir: "/usr/share/elasticsearch/plugins"
|
||||||
26
filter_plugins/custom.py
Normal file
26
filter_plugins/custom.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
__author__ = 'dale mcdiarmid'
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
def modify_list(values=[], pattern='', replacement='', ignorecase=False):
|
||||||
|
''' Perform a `re.sub` on every item in the list'''
|
||||||
|
if ignorecase:
|
||||||
|
flags = re.I
|
||||||
|
else:
|
||||||
|
flags = 0
|
||||||
|
_re = re.compile(pattern, flags=flags)
|
||||||
|
return [_re.sub(replacement, value) for value in values]
|
||||||
|
|
||||||
|
def append_to_list(values=[], suffix=''):
|
||||||
|
if isinstance(values, basestring):
|
||||||
|
values = values.split(',')
|
||||||
|
return [str(value+suffix) for value in values]
|
||||||
|
|
||||||
|
def array_to_str(values=[],separator=','):
|
||||||
|
return separator.join(values)
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
def filters(self):
|
||||||
|
return {'modify_list': modify_list,
|
||||||
|
'append_to_list':append_to_list,
|
||||||
|
'array_to_str':array_to_str}
|
||||||
|
|
@ -17,32 +17,35 @@
|
||||||
|
|
||||||
#For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN.
|
#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
|
#Create required directories
|
||||||
- name: Create PID Directory
|
- name: Create Directories
|
||||||
file: path={{ pid_dir }} state=directory owner={{ es_user }} group={{ es_group }}
|
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
|
- debug: msg="Data Dirs {{es_data_dirs}}"
|
||||||
file: state=directory path={{ data_dir }} owner={{ es_user }} group={{ es_group }}
|
|
||||||
|
|
||||||
- name: Create work dir
|
- set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }}
|
||||||
file: state=directory path={{ work_dir }} owner={{ es_user }} group={{ es_group }}
|
|
||||||
|
|
||||||
- name: Create log dir
|
- debug: msg="Data Dirs {{data_dirs}}"
|
||||||
file: state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }}
|
|
||||||
|
|
||||||
- name: Create Config Directory
|
- name: Create Data Directories
|
||||||
file: path={{ conf_dir }} state=directory owner={{ es_user }} group={{ es_group }}
|
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
|
#Copy the config template
|
||||||
- name: Copy Configuration File
|
- name: Copy Configuration File
|
||||||
|
|
@ -92,3 +95,11 @@
|
||||||
|
|
||||||
- name: Delete Default Sysconfig File
|
- name: Delete Default Sysconfig File
|
||||||
file: dest=/usr/lib/systemd/system/elasticsearch.service state=absent
|
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
|
- 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
|
#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 removes any currently installed plugins
|
||||||
|
|
||||||
#This needs to removed installed plugins not those listed
|
|
||||||
- name: Remove elasticsearch 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
|
ignore_errors: yes
|
||||||
with_items: es_plugins
|
with_items: installed_plugins.stdout_lines
|
||||||
when: es_plugins_reinstall
|
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
|
notify: restart elasticsearch
|
||||||
environment:
|
environment:
|
||||||
CONF_DIR: "{{ conf_dir }}"
|
CONF_DIR: "{{ conf_dir }}"
|
||||||
|
ES_INCLUDE: "{{ instance_default_file }}"
|
||||||
|
|
||||||
- name: Install elasticsearch plugins
|
- name: Install elasticsearch plugins
|
||||||
#debug: var=item
|
#debug: var=item
|
||||||
|
|
@ -25,7 +35,7 @@
|
||||||
failed_when: "'Failed to install' in plugin_installed.stderr"
|
failed_when: "'Failed to install' in plugin_installed.stderr"
|
||||||
changed_when: plugin_installed.rc == 0
|
changed_when: plugin_installed.rc == 0
|
||||||
with_items: es_plugins
|
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
|
notify: restart elasticsearch
|
||||||
environment:
|
environment:
|
||||||
CONF_DIR: "{{ conf_dir }}"
|
CONF_DIR: "{{ conf_dir }}"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
- include: elasticsearch-scripts.yml
|
- include: elasticsearch-scripts.yml
|
||||||
when: es_scripts
|
when: es_scripts
|
||||||
- include: elasticsearch-plugins.yml
|
- include: elasticsearch-plugins.yml
|
||||||
when: es_plugins is defined
|
when: es_plugins is defined or es_plugins_reinstall
|
||||||
- include: elasticsearch-service.yml
|
- include: elasticsearch-service.yml
|
||||||
- include: elasticsearch-templates.yml
|
- include: elasticsearch-templates.yml
|
||||||
when: es_templates
|
when: es_templates
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ ES_HOME={{es_home}}
|
||||||
CONF_DIR={{conf_dir}}
|
CONF_DIR={{conf_dir}}
|
||||||
|
|
||||||
# Elasticsearch data directory
|
# Elasticsearch data directory
|
||||||
DATA_DIR={{data_dir}}
|
DATA_DIR={{ data_dirs | array_to_str }}
|
||||||
|
|
||||||
# Elasticsearch logs directory
|
# Elasticsearch logs directory
|
||||||
LOG_DIR={{log_dir}}
|
LOG_DIR={{log_dir}}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ node.name: {{inventory_hostname}}-{{es_instance_name}}
|
||||||
# Path to directory containing configuration (this file and logging.yml):
|
# Path to directory containing configuration (this file and logging.yml):
|
||||||
path.conf: {{ conf_dir }}
|
path.conf: {{ conf_dir }}
|
||||||
|
|
||||||
path.data: {{ data_dir }}
|
path.data: {{ data_dirs | array_to_str }}
|
||||||
|
|
||||||
path.work: {{ work_dir }}
|
path.work: {{ work_dir }}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
# Modified by Nicolas Huray for Elasticsearch <nicolas.huray@gmail.com>.
|
# Modified by Nicolas Huray for Elasticsearch <nicolas.huray@gmail.com>.
|
||||||
#
|
#
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: elasticsearch
|
# Provides: {{es_instance_name}}_{{default_file | basename}}
|
||||||
# Required-Start: $network $remote_fs $named
|
# Required-Start: $network $remote_fs $named
|
||||||
# Required-Stop: $network $remote_fs $named
|
# Required-Stop: $network $remote_fs $named
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ After=network-online.target
|
||||||
[Service]
|
[Service]
|
||||||
Environment=ES_HOME={{es_home}}
|
Environment=ES_HOME={{es_home}}
|
||||||
Environment=CONF_DIR={{conf_dir}}
|
Environment=CONF_DIR={{conf_dir}}
|
||||||
Environment=DATA_DIR={{data_dir}}
|
Environment=DATA_DIR={{ data_dirs | array_to_str }}
|
||||||
Environment=LOG_DIR={{log_dir}}
|
Environment=LOG_DIR={{log_dir}}
|
||||||
Environment=PID_DIR={{pid_dir}}
|
Environment=PID_DIR={{pid_dir}}
|
||||||
EnvironmentFile=-{{instance_default_file}}
|
EnvironmentFile=-{{instance_default_file}}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
roles:
|
roles:
|
||||||
#expand to all available parameters
|
#expand to all available parameters
|
||||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
||||||
vars:
|
vars:
|
||||||
es_scripts: false
|
es_scripts: false
|
||||||
es_templates: false
|
es_templates: false
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ shared_examples 'config::init' do |es_version|
|
||||||
it { should contain 'bootstrap.mlockall: true' }
|
it { should contain 'bootstrap.mlockall: true' }
|
||||||
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' }
|
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' }
|
||||||
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
||||||
it { should contain 'path.data: /opt/elasticsearch/data/localhost-node1' }
|
it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' }
|
||||||
it { should contain 'path.work: /opt/elasticsearch/temp/localhost-node1' }
|
it { should contain 'path.work: /opt/elasticsearch/temp/localhost-node1' }
|
||||||
it { should contain 'path.logs: /opt/elasticsearch/logs/localhost-node1' }
|
it { should contain 'path.logs: /opt/elasticsearch/logs/localhost-node1' }
|
||||||
end
|
end
|
||||||
|
|
@ -41,7 +41,12 @@ shared_examples 'config::init' do |es_version|
|
||||||
it { should be_owned_by 'elasticsearch' }
|
it { should be_owned_by 'elasticsearch' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/opt/elasticsearch/data/localhost-node1') do
|
describe file('/opt/elasticsearch/data-1/localhost-node1') do
|
||||||
|
it { should be_directory }
|
||||||
|
it { should be_owned_by 'elasticsearch' }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/opt/elasticsearch/data-2/localhost-node1') do
|
||||||
it { should be_directory }
|
it { should be_directory }
|
||||||
it { should be_owned_by 'elasticsearch' }
|
it { should be_owned_by 'elasticsearch' }
|
||||||
end
|
end
|
||||||
|
|
@ -82,6 +87,27 @@ shared_examples 'config::init' do |es_version|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe file('/etc/init.d/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/default/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/sysconfig/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/usr/lib/systemd/system/elasticsearch.service') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/elasticsearch/elasticsearch.yml') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
#Not copied on Debian 8
|
#Not copied on Debian 8
|
||||||
#describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do
|
#describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do
|
||||||
# it { should be_file }
|
# it { should be_file }
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ shared_examples 'multi::init' do |es_version,plugins|
|
||||||
it { should contain 'node.name: localhost-node1' }
|
it { should contain 'node.name: localhost-node1' }
|
||||||
it { should_not contain 'bootstrap.mlockall: true' }
|
it { should_not contain 'bootstrap.mlockall: true' }
|
||||||
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
||||||
it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' }
|
it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' }
|
||||||
it { should contain 'path.work: /tmp/elasticsearch/localhost-node1' }
|
it { should contain 'path.work: /tmp/elasticsearch/localhost-node1' }
|
||||||
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
|
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
|
||||||
end
|
end
|
||||||
|
|
@ -46,7 +46,7 @@ shared_examples 'multi::init' do |es_version,plugins|
|
||||||
it { should contain 'node.name: localhost-master' }
|
it { should contain 'node.name: localhost-master' }
|
||||||
it { should contain 'bootstrap.mlockall: true' }
|
it { should contain 'bootstrap.mlockall: true' }
|
||||||
it { should contain 'path.conf: /etc/elasticsearch/master' }
|
it { should contain 'path.conf: /etc/elasticsearch/master' }
|
||||||
it { should contain 'path.data: /opt/elasticsearch/localhost-master' }
|
it { should contain 'path.data: /opt/elasticsearch/master/localhost-master' }
|
||||||
it { should contain 'path.work: /tmp/elasticsearch/localhost-master' }
|
it { should contain 'path.work: /tmp/elasticsearch/localhost-master' }
|
||||||
it { should contain 'path.logs: /var/log/elasticsearch/localhost-master' }
|
it { should contain 'path.logs: /var/log/elasticsearch/localhost-master' }
|
||||||
end
|
end
|
||||||
|
|
@ -129,16 +129,18 @@ shared_examples 'multi::init' do |es_version,plugins|
|
||||||
end
|
end
|
||||||
|
|
||||||
#Confirm that the data directory has only been set for the first node
|
#Confirm that the data directory has only been set for the first node
|
||||||
describe file('/opt/elasticsearch/localhost-master') do
|
describe file('/opt/elasticsearch/master/localhost-master') do
|
||||||
it { should be_directory }
|
it { should be_directory }
|
||||||
it { should be_owned_by 'elasticsearch' }
|
it { should be_owned_by 'elasticsearch' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/opt/elasticsearch/localhost-node1') do
|
describe file('/opt/elasticsearch/data-1/localhost-node1') do
|
||||||
it { should_not exist }
|
it { should be_directory }
|
||||||
|
it { should be_owned_by 'elasticsearch' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/var/lib/elasticsearch/localhost-node1') do
|
|
||||||
|
describe file('/opt/elasticsearch/data-2/localhost-node1') do
|
||||||
it { should be_directory }
|
it { should be_directory }
|
||||||
it { should be_owned_by 'elasticsearch' }
|
it { should be_owned_by 'elasticsearch' }
|
||||||
end
|
end
|
||||||
|
|
@ -203,6 +205,25 @@ shared_examples 'multi::init' do |es_version,plugins|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe file('/etc/init.d/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/default/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/sysconfig/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/usr/lib/systemd/system/elasticsearch.service') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/elasticsearch/elasticsearch.yml') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,5 +83,25 @@ shared_examples 'package::init' do |es_version,plugins|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe file('/etc/init.d/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/default/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/sysconfig/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/usr/lib/systemd/system/elasticsearch.service') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/elasticsearch/elasticsearch.yml') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,5 +63,9 @@ shared_examples 'standard::init' do |es_version|
|
||||||
it { should_not exist }
|
it { should_not exist }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe file('/etc/elasticsearch/elasticsearch.yml') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
- name: Elasticsearch Multi tests
|
- name: Elasticsearch Multi tests
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
roles:
|
roles:
|
||||||
- { role: elasticsearch, es_instance_name: "master", es_data_dir: "/opt/elasticsearch", es_heap_size: "1g", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
- { role: elasticsearch, es_instance_name: "master", es_data_dirs: ["/opt/elasticsearch/master"], es_heap_size: "1g", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
||||||
- { role: elasticsearch, es_instance_name: "node1", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, discovery.zen.ping.multicast.enabled: false } }
|
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: "/opt/elasticsearch/data-1,/opt/elasticsearch/data-2", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, discovery.zen.ping.multicast.enabled: false } }
|
||||||
vars:
|
vars:
|
||||||
es_scripts: true
|
es_scripts: true
|
||||||
es_templates: true
|
es_templates: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue