mirror of
https://github.com/aljazceru/ansible-elasticsearch.git
synced 2025-12-17 17:14:20 +01:00
2.0 Support + Plugin Directory Support + Supporting Tests + Defaults Change
This commit is contained in:
52
.kitchen.yml
52
.kitchen.yml
@@ -56,24 +56,66 @@ platforms:
|
|||||||
use_sudo: false
|
use_sudo: false
|
||||||
|
|
||||||
suites:
|
suites:
|
||||||
- name: standard
|
- name: standard-2x
|
||||||
provisioner:
|
provisioner:
|
||||||
playbook: test/integration/standard.yml
|
playbook: test/integration/standard.yml
|
||||||
run_list:
|
run_list:
|
||||||
attributes:
|
attributes:
|
||||||
- name: package
|
- name: package-2x
|
||||||
run_list:
|
run_list:
|
||||||
attributes:
|
attributes:
|
||||||
|
extra_vars:
|
||||||
|
es_plugins:
|
||||||
|
- plugin: lmenezes/elasticsearch-kopf
|
||||||
|
version: master
|
||||||
|
- plugin: license
|
||||||
|
- plugin: marvel-agent
|
||||||
provisioner:
|
provisioner:
|
||||||
playbook: test/integration/package.yml
|
playbook: test/integration/package.yml
|
||||||
- name: config
|
- name: config-2x
|
||||||
run_list:
|
run_list:
|
||||||
attributes:
|
attributes:
|
||||||
provisioner:
|
provisioner:
|
||||||
playbook: test/integration/config.yml
|
playbook: test/integration/config.yml
|
||||||
- name: multi
|
- name: multi-2x
|
||||||
run_list:
|
run_list:
|
||||||
attributes:
|
attributes:
|
||||||
provisioner:
|
provisioner:
|
||||||
playbook: test/integration/multi.yml
|
playbook: test/integration/multi.yml
|
||||||
|
- name: standard-1x
|
||||||
|
provisioner:
|
||||||
|
playbook: test/integration/standard.yml
|
||||||
|
run_list:
|
||||||
|
attributes:
|
||||||
|
extra_vars:
|
||||||
|
es_major_version: 1.7
|
||||||
|
es_version: 1.7.3
|
||||||
|
- name: package-1x
|
||||||
|
run_list:
|
||||||
|
attributes:
|
||||||
|
extra_vars:
|
||||||
|
es_major_version: 1.7
|
||||||
|
es_version: 1.7.3
|
||||||
|
es_plugins:
|
||||||
|
- plugin: lmenezes/elasticsearch-kopf
|
||||||
|
version: master
|
||||||
|
- plugin: elasticsearch/marvel
|
||||||
|
version: latest
|
||||||
|
provisioner:
|
||||||
|
playbook: test/integration/package.yml
|
||||||
|
- name: config-1x
|
||||||
|
run_list:
|
||||||
|
attributes:
|
||||||
|
extra_vars:
|
||||||
|
es_major_version: 1.7
|
||||||
|
es_version: 1.7.3
|
||||||
|
provisioner:
|
||||||
|
playbook: test/integration/config.yml
|
||||||
|
- name: multi-1x
|
||||||
|
run_list:
|
||||||
|
attributes:
|
||||||
|
extra_vars:
|
||||||
|
es_major_version: 1.7
|
||||||
|
es_version: 1.7.3
|
||||||
|
provisioner:
|
||||||
|
playbook: test/integration/multi.yml
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
es_major_version: "1.7"
|
es_major_version: "2.x"
|
||||||
es_version: "1.7.3"
|
es_version: "2.1.0"
|
||||||
es_version_lock: false
|
es_version_lock: false
|
||||||
es_use_repository: true
|
es_use_repository: true
|
||||||
es_start_service: true
|
es_start_service: true
|
||||||
@@ -15,3 +15,4 @@ es_pid_dir: "/var/run/elasticsearch"
|
|||||||
es_data_dir: "/var/lib/elasticsearch"
|
es_data_dir: "/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"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
- name: restart elasticsearch
|
- name: restart elasticsearch
|
||||||
service: name={{instance_init_script | basename}} state=restarted enabled=yes
|
service: name={{instance_init_script | basename}} state=restarted enabled=yes
|
||||||
when: es_start_service and not elasticsearch_started.changed
|
when: es_start_service and (not elasticsearch_started.changed or plugin_installed.changed)
|
||||||
@@ -3,15 +3,15 @@
|
|||||||
- fail: msg="es_instance_name must be specified"
|
- fail: msg="es_instance_name must be specified"
|
||||||
when: es_instance_name is not defined
|
when: es_instance_name is not defined
|
||||||
|
|
||||||
- set_fact: multi_cast={{ (es_version | version_compare('2.0', '<') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) or es_config['discovery.zen.ping.multicast.enabled']}}
|
- set_fact: multi_cast={{ (es_version | version_compare('2.0', '<') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) or (es_config['discovery.zen.ping.multicast.enabled'] is defined and es_config['discovery.zen.ping.multicast.enabled'])}}
|
||||||
|
|
||||||
- fail: msg="Parameter 'http.port' must be defined when multicast is disabled"
|
- debug: msg="WARNING - It is recommended you specify the parameter 'http.port' when multicast is disabled"
|
||||||
when: not multi_cast and es_config['http.port'] is not defined
|
when: not multi_cast and es_config['http.port'] is not defined
|
||||||
|
|
||||||
- fail: msg="Parameter 'transport.tcp.port' must be defined when multicast is disabled"
|
- debug: msg="WARNING - It is recommended you specify the parameter 'transport.tcp.port' when multicast is disabled"
|
||||||
when: not multi_cast and es_config['transport.tcp.port'] is not defined
|
when: not multi_cast and es_config['transport.tcp.port'] is not defined
|
||||||
|
|
||||||
- fail: msg="Parameter 'discovery.zen.ping.unicast.hosts' must be defined when multicast is disabled"
|
- debug: msg="WARNING - It is recommended you specify the parameter 'discovery.zen.ping.unicast.hosts' when multicast is disabled"
|
||||||
when: not multi_cast and es_config['discovery.zen.ping.unicast.hosts'] is not defined
|
when: not multi_cast and es_config['discovery.zen.ping.unicast.hosts'] is not defined
|
||||||
|
|
||||||
#If the user attempts to lock memory they must specify a heap size
|
#If the user attempts to lock memory they must specify a heap size
|
||||||
|
|||||||
@@ -34,11 +34,14 @@
|
|||||||
file: state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }}
|
file: state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }}
|
||||||
|
|
||||||
- name: Create Config Directory
|
- name: Create Config Directory
|
||||||
file: path={{ instance_config_directory }} state=directory owner={{ es_user }} group={{ es_group }}
|
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 }}
|
||||||
|
|
||||||
#Copy the config template
|
#Copy the config template
|
||||||
- name: Copy Configuration File
|
- name: Copy Configuration File
|
||||||
template: src=elasticsearch.yml.j2 dest={{instance_config_directory}}/elasticsearch.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
|
template: src=elasticsearch.yml.j2 dest={{conf_dir}}/elasticsearch.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
|
||||||
notify: restart elasticsearch
|
notify: restart elasticsearch
|
||||||
|
|
||||||
#Copy the instance specific default file
|
#Copy the instance specific default file
|
||||||
@@ -64,5 +67,5 @@
|
|||||||
|
|
||||||
#Copy the logging.yml
|
#Copy the logging.yml
|
||||||
- name: Copy Logging.yml File for Instance
|
- name: Copy Logging.yml File for Instance
|
||||||
template: src=logging.yml.j2 dest={{instance_config_directory}}/logging.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
|
template: src=logging.yml.j2 dest={{conf_dir}}/logging.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
|
||||||
notify: restart elasticsearch
|
notify: restart elasticsearch
|
||||||
@@ -1,15 +1,26 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Remove elasticsearch plugins
|
- name: Remove elasticsearch plugins
|
||||||
command: /usr/share/elasticsearch/bin/plugin --remove {{ item.plugin }} --silent
|
command: "{{es_home}}/bin/plugin remove {{ item.plugin }} --silent"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
with_items: es_plugins
|
with_items: es_plugins
|
||||||
when: ( ansible_os_family == 'RedHat' or ansible_os_family == 'Debian' ) and es_plugins_reinstall
|
when: ( ansible_os_family == 'RedHat' or ansible_os_family == 'Debian' ) and es_plugins_reinstall
|
||||||
|
notify: restart elasticsearch
|
||||||
|
environment:
|
||||||
|
CONF_DIR: "{{ conf_dir }}"
|
||||||
|
|
||||||
- name: Install elasticsearch plugins
|
- name: Install elasticsearch plugins
|
||||||
#debug: var=item
|
#debug: var=item
|
||||||
command: /usr/share/elasticsearch/bin/plugin --install {{ item.plugin }}/{{ item.version }} --silent
|
command: "{{es_home}}/bin/plugin install {{ item.plugin }}{% if item.version is defined and item.version != '' %}/{{ item.version }}{% endif %} --silent"
|
||||||
register: command_result
|
register: plugin_installed
|
||||||
failed_when: "'Failed to install' in command_result.stderr"
|
failed_when: "'Failed to install' in plugin_installed.stderr"
|
||||||
changed_when: command_result.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: ansible_os_family == 'RedHat' or ansible_os_family == 'Debian'
|
||||||
|
notify: restart elasticsearch
|
||||||
|
environment:
|
||||||
|
CONF_DIR: "{{ conf_dir }}"
|
||||||
|
|
||||||
|
#Set permissions on plugins directory
|
||||||
|
- name: Set Plugin Directory Permissions
|
||||||
|
file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
- set_fact: instance_default_file={{default_file | dirname}}/{{es_instance_name}}_{{default_file | basename}}
|
- set_fact: instance_default_file={{default_file | dirname}}/{{es_instance_name}}_{{default_file | basename}}
|
||||||
- set_fact: instance_init_script={{init_script | dirname }}/{{es_instance_name}}_{{init_script | basename}}
|
- set_fact: instance_init_script={{init_script | dirname }}/{{es_instance_name}}_{{init_script | basename}}
|
||||||
- set_fact: instance_config_directory={{ es_conf_dir }}/{{es_instance_name}}
|
- set_fact: conf_dir={{ es_conf_dir }}/{{es_instance_name}}
|
||||||
|
- set_fact: plugin_dir={{ es_plugin_dir }}/{{es_instance_name}}
|
||||||
- set_fact: m_lock_enabled={{ es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True }}
|
- set_fact: m_lock_enabled={{ es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True }}
|
||||||
|
|
||||||
- debug: msg="Node configuration {{ es_config }} "
|
- debug: msg="Node configuration {{ es_config }} "
|
||||||
@@ -20,7 +21,6 @@
|
|||||||
- name: Elasticsearch configuration
|
- name: Elasticsearch configuration
|
||||||
include: elasticsearch-config.yml
|
include: elasticsearch-config.yml
|
||||||
|
|
||||||
|
|
||||||
# Make sure the service is started, and restart if necessary
|
# Make sure the service is started, and restart if necessary
|
||||||
- name: Start elasticsearch service
|
- name: Start elasticsearch service
|
||||||
service: name={{instance_init_script | basename}} state=started enabled=yes
|
service: name={{instance_init_script | basename}} state=started enabled=yes
|
||||||
|
|||||||
@@ -6,10 +6,7 @@
|
|||||||
ES_HOME={{es_home}}
|
ES_HOME={{es_home}}
|
||||||
|
|
||||||
# Elasticsearch configuration directory
|
# Elasticsearch configuration directory
|
||||||
CONF_DIR={{instance_config_directory}}
|
CONF_DIR={{conf_dir}}
|
||||||
|
|
||||||
# Elasticsearch configuration file
|
|
||||||
CONF_FILE={{instance_config_directory}}/elasticsearch.yml
|
|
||||||
|
|
||||||
# Elasticsearch data directory
|
# Elasticsearch data directory
|
||||||
DATA_DIR={{data_dir}}
|
DATA_DIR={{data_dir}}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[elasticsearch-{{ es_major_version }}]
|
[elasticsearch-{{ es_major_version }}]
|
||||||
name=Elasticsearch repository for {{ es_major_version }}.x packages
|
name=Elasticsearch repository for {{ es_major_version }} packages
|
||||||
baseurl=http://packages.elastic.co/elasticsearch/{{ es_major_version }}/centos
|
baseurl=http://packages.elastic.co/elasticsearch/{{ es_major_version }}/centos
|
||||||
gpgcheck=1
|
gpgcheck=1
|
||||||
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
|
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ node.name: {{inventory_hostname}}-{{es_instance_name}}
|
|||||||
#################################### Paths ####################################
|
#################################### Paths ####################################
|
||||||
|
|
||||||
# Path to directory containing configuration (this file and logging.yml):
|
# Path to directory containing configuration (this file and logging.yml):
|
||||||
path.conf: {{ instance_config_directory }}
|
path.conf: {{ conf_dir }}
|
||||||
|
|
||||||
path.data: {{ data_dir }}
|
path.data: {{ data_dir }}
|
||||||
|
|
||||||
path.work: {{ work_dir }}
|
path.work: {{ work_dir }}
|
||||||
|
|
||||||
path.logs: {{ log_dir }}
|
path.logs: {{ log_dir }}
|
||||||
|
|
||||||
|
path.plugins: {{ plugin_dir }}
|
||||||
@@ -26,6 +26,7 @@ DESC="Elasticsearch Server - {{es_config['node.name']}}"
|
|||||||
{% else %}
|
{% else %}
|
||||||
DESC="Elasticsearch Server - {{es_instance_name}}"
|
DESC="Elasticsearch Server - {{es_instance_name}}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
DEFAULT=/etc/default/$NAME
|
DEFAULT=/etc/default/$NAME
|
||||||
|
|
||||||
if [ `id -u` -ne 0 ]; then
|
if [ `id -u` -ne 0 ]; then
|
||||||
@@ -40,23 +41,13 @@ if [ -r /etc/default/rcS ]; then
|
|||||||
. /etc/default/rcS
|
. /etc/default/rcS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# The following variables can be overwritten in $DEFAULT
|
# The following variables can be overwritten in $DEFAULT
|
||||||
|
|
||||||
# Run Elasticsearch as this user ID and group ID
|
# Run Elasticsearch as this user ID and group ID
|
||||||
ES_USER=elasticsearch
|
ES_USER=elasticsearch
|
||||||
ES_GROUP=elasticsearch
|
ES_GROUP=elasticsearch
|
||||||
|
|
||||||
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
|
|
||||||
JDK_DIRS="/usr/lib/jvm/java-8-oracle/ /usr/lib/jvm/j2sdk1.8-oracle/ /usr/lib/jvm/jdk-7-oracle-x64 /usr/lib/jvm/java-7-oracle /usr/lib/jvm/j2sdk1.7-oracle/ /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-armhf /usr/lib/jvm/java-7-openjdk-i386/ /usr/lib/jvm/default-java"
|
|
||||||
|
|
||||||
# Look for the right JVM to use
|
|
||||||
for jdir in $JDK_DIRS; do
|
|
||||||
if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
|
|
||||||
JAVA_HOME="$jdir"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
export JAVA_HOME
|
|
||||||
|
|
||||||
# Directory where the Elasticsearch binary distribution resides
|
# Directory where the Elasticsearch binary distribution resides
|
||||||
ES_HOME=/usr/share/$NAME
|
ES_HOME=/usr/share/$NAME
|
||||||
|
|
||||||
@@ -85,15 +76,9 @@ LOG_DIR=/var/log/$NAME
|
|||||||
# Elasticsearch data directory
|
# Elasticsearch data directory
|
||||||
DATA_DIR=/var/lib/$NAME
|
DATA_DIR=/var/lib/$NAME
|
||||||
|
|
||||||
# Elasticsearch work directory
|
|
||||||
WORK_DIR=/tmp/$NAME
|
|
||||||
|
|
||||||
# Elasticsearch configuration directory
|
# Elasticsearch configuration directory
|
||||||
CONF_DIR=/etc/$NAME
|
CONF_DIR=/etc/$NAME
|
||||||
|
|
||||||
# Elasticsearch configuration file (elasticsearch.yml)
|
|
||||||
CONF_FILE=$CONF_DIR/elasticsearch.yml
|
|
||||||
|
|
||||||
# Maximum number of VMA (Virtual Memory Areas) a process can own
|
# Maximum number of VMA (Virtual Memory Areas) a process can own
|
||||||
MAX_MAP_COUNT=262144
|
MAX_MAP_COUNT=262144
|
||||||
|
|
||||||
@@ -110,15 +95,23 @@ if [ -f "$DEFAULT" ]; then
|
|||||||
. "$DEFAULT"
|
. "$DEFAULT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# CONF_FILE setting was removed
|
||||||
|
if [ ! -z "$CONF_FILE" ]; then
|
||||||
|
echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Define other required variables
|
# Define other required variables
|
||||||
PID_FILE="$PID_DIR/$NAME.pid"
|
PID_FILE="$PID_DIR/$NAME.pid"
|
||||||
DAEMON=$ES_HOME/bin/elasticsearch
|
DAEMON=$ES_HOME/bin/elasticsearch
|
||||||
DAEMON_OPTS="-d -p $PID_FILE --default.config=$CONF_FILE --default.path.home=$ES_HOME --default.path.logs=$LOG_DIR --default.path.data=$DATA_DIR --default.path.work=$WORK_DIR --default.path.conf=$CONF_DIR"
|
DAEMON_OPTS="-d -p $PID_FILE --default.path.home=$ES_HOME --default.path.logs=$LOG_DIR --default.path.data=$DATA_DIR --default.path.conf=$CONF_DIR"
|
||||||
|
|
||||||
export ES_HEAP_SIZE
|
export ES_HEAP_SIZE
|
||||||
export ES_HEAP_NEWSIZE
|
export ES_HEAP_NEWSIZE
|
||||||
export ES_DIRECT_SIZE
|
export ES_DIRECT_SIZE
|
||||||
export ES_JAVA_OPTS
|
export ES_JAVA_OPTS
|
||||||
|
export ES_GC_LOG_FILE
|
||||||
|
export JAVA_HOME
|
||||||
|
|
||||||
# Check DAEMON exists
|
# Check DAEMON exists
|
||||||
test -x $DAEMON || exit 0
|
test -x $DAEMON || exit 0
|
||||||
@@ -155,7 +148,7 @@ case "$1" in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare environment
|
# Prepare environment
|
||||||
mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR"
|
mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR"
|
||||||
|
|
||||||
# Ensure that the PID_DIR exists (it is cleaned at OS startup time)
|
# Ensure that the PID_DIR exists (it is cleaned at OS startup time)
|
||||||
if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then
|
if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then
|
||||||
@@ -178,10 +171,9 @@ case "$1" in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Start Daemon
|
# Start Daemon
|
||||||
start-stop-daemon --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS
|
start-stop-daemon -d $ES_HOME --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS
|
||||||
return=$?
|
return=$?
|
||||||
if [ $return -eq 0 ]
|
if [ $return -eq 0 ]; then
|
||||||
then
|
|
||||||
i=0
|
i=0
|
||||||
timeout=10
|
timeout=10
|
||||||
# Wait for the process to be properly started before exiting
|
# Wait for the process to be properly started before exiting
|
||||||
@@ -194,9 +186,9 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
|
||||||
log_end_msg $return
|
|
||||||
fi
|
fi
|
||||||
|
log_end_msg $return
|
||||||
|
exit $return
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
log_daemon_msg "Stopping $DESC"
|
log_daemon_msg "Stopping $DESC"
|
||||||
@@ -204,7 +196,8 @@ case "$1" in
|
|||||||
if [ -f "$PID_FILE" ]; then
|
if [ -f "$PID_FILE" ]; then
|
||||||
start-stop-daemon --stop --pidfile "$PID_FILE" \
|
start-stop-daemon --stop --pidfile "$PID_FILE" \
|
||||||
--user "$ES_USER" \
|
--user "$ES_USER" \
|
||||||
--retry=TERM/20/KILL/5 >/dev/null
|
--quiet \
|
||||||
|
--retry forever/TERM/20 > /dev/null
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
log_progress_msg "$DESC is not running but pid file exists, cleaning up"
|
log_progress_msg "$DESC is not running but pid file exists, cleaning up"
|
||||||
elif [ $? -eq 3 ]; then
|
elif [ $? -eq 3 ]; then
|
||||||
|
|||||||
@@ -39,9 +39,8 @@ MAX_OPEN_FILES=65535
|
|||||||
MAX_MAP_COUNT=262144
|
MAX_MAP_COUNT=262144
|
||||||
LOG_DIR="/var/log/elasticsearch"
|
LOG_DIR="/var/log/elasticsearch"
|
||||||
DATA_DIR="/var/lib/elasticsearch"
|
DATA_DIR="/var/lib/elasticsearch"
|
||||||
WORK_DIR="/tmp/elasticsearch"
|
|
||||||
CONF_DIR="/etc/elasticsearch"
|
CONF_DIR="/etc/elasticsearch"
|
||||||
CONF_FILE="/etc/elasticsearch/elasticsearch.yml"
|
|
||||||
PID_DIR="/var/run/elasticsearch"
|
PID_DIR="/var/run/elasticsearch"
|
||||||
|
|
||||||
# Source the default env file
|
# Source the default env file
|
||||||
@@ -50,6 +49,12 @@ if [ -f "$ES_ENV_FILE" ]; then
|
|||||||
. "$ES_ENV_FILE"
|
. "$ES_ENV_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# CONF_FILE setting was removed
|
||||||
|
if [ ! -z "$CONF_FILE" ]; then
|
||||||
|
echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
exec="$ES_HOME/bin/elasticsearch"
|
exec="$ES_HOME/bin/elasticsearch"
|
||||||
prog="elasticsearch"
|
prog="elasticsearch"
|
||||||
pidfile="$PID_DIR/${prog}.pid"
|
pidfile="$PID_DIR/${prog}.pid"
|
||||||
@@ -58,6 +63,8 @@ export ES_HEAP_SIZE
|
|||||||
export ES_HEAP_NEWSIZE
|
export ES_HEAP_NEWSIZE
|
||||||
export ES_DIRECT_SIZE
|
export ES_DIRECT_SIZE
|
||||||
export ES_JAVA_OPTS
|
export ES_JAVA_OPTS
|
||||||
|
export ES_GC_LOG_FILE
|
||||||
|
export ES_STARTUP_SLEEP_TIME
|
||||||
export JAVA_HOME
|
export JAVA_HOME
|
||||||
|
|
||||||
lockfile=/var/lock/subsys/$prog
|
lockfile=/var/lock/subsys/$prog
|
||||||
@@ -83,7 +90,6 @@ checkJava() {
|
|||||||
start() {
|
start() {
|
||||||
checkJava
|
checkJava
|
||||||
[ -x $exec ] || exit 5
|
[ -x $exec ] || exit 5
|
||||||
[ -f $CONF_FILE ] || exit 6
|
|
||||||
if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then
|
if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then
|
||||||
echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"
|
echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"
|
||||||
return 7
|
return 7
|
||||||
@@ -97,10 +103,7 @@ start() {
|
|||||||
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
|
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
|
||||||
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
|
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
|
||||||
fi
|
fi
|
||||||
if [ -n "$WORK_DIR" ]; then
|
export ES_GC_LOG_FILE
|
||||||
mkdir -p "$WORK_DIR"
|
|
||||||
chown "$ES_USER":"$ES_GROUP" "$WORK_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure that the PID_DIR exists (it is cleaned at OS startup time)
|
# Ensure that the PID_DIR exists (it is cleaned at OS startup time)
|
||||||
if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then
|
if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then
|
||||||
@@ -110,9 +113,10 @@ start() {
|
|||||||
touch "$pidfile" && chown "$ES_USER":"$ES_GROUP" "$pidfile"
|
touch "$pidfile" && chown "$ES_USER":"$ES_GROUP" "$pidfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd $ES_HOME
|
||||||
echo -n $"Starting $prog: "
|
echo -n $"Starting $prog: "
|
||||||
# if not running, start it up here, usually something like "daemon $exec"
|
# if not running, start it up here, usually something like "daemon $exec"
|
||||||
daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR
|
daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.conf=$CONF_DIR
|
||||||
retval=$?
|
retval=$?
|
||||||
echo
|
echo
|
||||||
[ $retval -eq 0 ] && touch $lockfile
|
[ $retval -eq 0 ] && touch $lockfile
|
||||||
@@ -122,7 +126,7 @@ start() {
|
|||||||
stop() {
|
stop() {
|
||||||
echo -n $"Stopping $prog: "
|
echo -n $"Stopping $prog: "
|
||||||
# stop it here, often "killproc $prog"
|
# stop it here, often "killproc $prog"
|
||||||
killproc -p $pidfile -d 20 $prog
|
killproc -p $pidfile -d 86400 $prog
|
||||||
retval=$?
|
retval=$?
|
||||||
echo
|
echo
|
||||||
[ $retval -eq 0 ] && rm -f $lockfile
|
[ $retval -eq 0 ] && rm -f $lockfile
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ After=network-online.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=ES_HOME={{es_home}}
|
Environment=ES_HOME={{es_home}}
|
||||||
Environment=CONF_DIR={{instance_config_directory}}
|
Environment=CONF_DIR={{conf_dir}}
|
||||||
Environment=CONF_FILE={{instance_config_directory}}/elasticsearch.yml
|
|
||||||
Environment=DATA_DIR={{data_dir}}
|
Environment=DATA_DIR={{data_dir}}
|
||||||
Environment=LOG_DIR={{log_dir}}
|
Environment=LOG_DIR={{log_dir}}
|
||||||
Environment=PID_DIR={{pid_dir}}
|
Environment=PID_DIR={{pid_dir}}
|
||||||
@@ -17,12 +16,13 @@ User={{es_user}}
|
|||||||
Group={{es_group}}
|
Group={{es_group}}
|
||||||
|
|
||||||
ExecStart={{es_home}}/bin/elasticsearch \
|
ExecStart={{es_home}}/bin/elasticsearch \
|
||||||
-Des.pidfile=$PID_DIR/elasticsearch.pid \
|
-Des.pidfile=${PID_DIR}/elasticsearch.pid \
|
||||||
-Des.default.path.home=$ES_HOME \
|
-Des.default.path.home=${ES_HOME} \
|
||||||
-Des.default.path.logs=$LOG_DIR \
|
-Des.default.path.logs=${LOG_DIR} \
|
||||||
-Des.default.path.data=$DATA_DIR \
|
-Des.default.path.data=${DATA_DIR} \
|
||||||
-Des.default.config=$CONF_FILE \
|
-Des.default.path.conf=${CONF_DIR}
|
||||||
-Des.default.path.conf=$CONF_DIR
|
|
||||||
|
|
||||||
|
|
||||||
# Connects standard output to /dev/null
|
# Connects standard output to /dev/null
|
||||||
StandardOutput=null
|
StandardOutput=null
|
||||||
@@ -30,9 +30,6 @@ StandardOutput=null
|
|||||||
# Connects standard error to journal
|
# Connects standard error to journal
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
|
|
||||||
# When a JVM receives a SIGTERM signal it exits with code 143
|
|
||||||
SuccessExitStatus=143
|
|
||||||
|
|
||||||
# Specifies the maximum file descriptor number that can be opened by this process
|
# Specifies the maximum file descriptor number that can be opened by this process
|
||||||
LimitNOFILE=65535
|
LimitNOFILE=65535
|
||||||
|
|
||||||
@@ -43,8 +40,17 @@ LimitNOFILE=65535
|
|||||||
LimitMEMLOCK=infinity
|
LimitMEMLOCK=infinity
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured)
|
# Disable timeout logic and wait until process is stopped
|
||||||
TimeoutStopSec=20
|
TimeoutStopSec=0
|
||||||
|
|
||||||
|
# SIGTERM signal is used to stop the Java process
|
||||||
|
KillSignal=SIGTERM
|
||||||
|
|
||||||
|
# Java process is never killed
|
||||||
|
SendSIGKILL=no
|
||||||
|
|
||||||
|
# When a JVM receives a SIGTERM signal it exits with code 143
|
||||||
|
SuccessExitStatus=143
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
6
test/integration/config-1x/serverspec/default_spec.rb
Normal file
6
test/integration/config-1x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require 'config_spec'
|
||||||
|
|
||||||
|
describe 'Config Tests v 1.x' do
|
||||||
|
include_examples 'config::init', "1.7.3"
|
||||||
|
end
|
||||||
|
|
||||||
6
test/integration/config-2x/serverspec/default_spec.rb
Normal file
6
test/integration/config-2x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require 'config_spec'
|
||||||
|
|
||||||
|
describe 'Config Tests v 2.x' do
|
||||||
|
include_examples 'config::init', "2.1.0"
|
||||||
|
end
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
require 'serverspec'
|
|
||||||
set :backend, :exec
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
context "basic tests" do
|
shared_examples 'config::init' do |es_version|
|
||||||
|
|
||||||
describe user('elasticsearch') do
|
describe user('elasticsearch') do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
@@ -61,7 +61,7 @@ context "basic tests" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
#test we started on the correct port was used
|
#test we started on the correct port was used
|
||||||
describe command('curl -s "localhost:9201" | grep status') do
|
describe command('curl -s "localhost:9201"') do
|
||||||
#TODO: This is returning an empty string
|
#TODO: This is returning an empty string
|
||||||
#its(:stdout) { should match /\"status\" : 200/ }
|
#its(:stdout) { should match /\"status\" : 200/ }
|
||||||
its(:exit_status) { should eq 0 }
|
its(:exit_status) { should eq 0 }
|
||||||
@@ -73,5 +73,20 @@ context "basic tests" do
|
|||||||
its(:exit_status) { should eq 0 }
|
its(:exit_status) { should eq 0 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe 'version check' do
|
||||||
|
it 'should be reported as version '+es_version do
|
||||||
|
command = command('curl -s localhost:9201 | grep number')
|
||||||
|
expect(command.stdout).to match(es_version)
|
||||||
|
expect(command.exit_status).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#Not copied on Debian 8
|
||||||
|
#describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do
|
||||||
|
# it { should be_file }
|
||||||
|
# it { should contain 'LimitMEMLOCK=infinity' }
|
||||||
|
#end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
context "basic tests" do
|
shared_examples 'multi::init' do |es_version|
|
||||||
|
|
||||||
describe user('elasticsearch') do
|
describe user('elasticsearch') do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
@@ -155,6 +155,33 @@ context "basic tests" do
|
|||||||
its(:exit_status) { should eq 0 }
|
its(:exit_status) { should eq 0 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'version check on master' do
|
||||||
|
it 'should be reported as version '+es_version do
|
||||||
|
command = command('curl -s localhost:9200 | grep number')
|
||||||
|
expect(command.stdout).to match(es_version)
|
||||||
|
expect(command.exit_status).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'version check on data' do
|
||||||
|
it 'should be reported as version '+es_version do
|
||||||
|
command = command('curl -s localhost:9201 | grep number')
|
||||||
|
expect(command.stdout).to match(es_version)
|
||||||
|
expect(command.exit_status).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#Test server spec file has been created and modified
|
||||||
|
#describe file('/usr/lib/systemd/system/master_elasticsearch.service') do
|
||||||
|
# it { should be_file }
|
||||||
|
# it { should contain 'LimitMEMLOCK=infinity' }
|
||||||
|
#end
|
||||||
|
|
||||||
|
#describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do
|
||||||
|
# it { should be_file }
|
||||||
|
# it { should_not contain 'LimitMEMLOCK=infinity' }
|
||||||
|
#end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
context "basic tests" do
|
shared_examples 'package::init' do |es_version,plugins|
|
||||||
|
|
||||||
describe user('elasticsearch') do
|
describe user('elasticsearch') do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
@@ -23,6 +23,8 @@ context "basic tests" do
|
|||||||
it { should be_owned_by 'elasticsearch' }
|
it { should be_owned_by 'elasticsearch' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe file('/etc/elasticsearch/node1/scripts/calculate-score.groovy') do
|
describe file('/etc/elasticsearch/node1/scripts/calculate-score.groovy') do
|
||||||
it { should be_file }
|
it { should be_file }
|
||||||
it { should be_owned_by 'elasticsearch' }
|
it { should be_owned_by 'elasticsearch' }
|
||||||
@@ -52,5 +54,33 @@ context "basic tests" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'version check' do
|
||||||
|
it 'should be reported as version '+es_version do
|
||||||
|
command = command('curl -s localhost:9200 | grep number')
|
||||||
|
expect(command.stdout).to match(es_version)
|
||||||
|
expect(command.exit_status).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/usr/share/elasticsearch/plugins/node1') do
|
||||||
|
it { should be_directory }
|
||||||
|
it { should be_owned_by 'elasticsearch' }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for plugin in plugins
|
||||||
|
describe file('/usr/share/elasticsearch/plugins/node1/'+plugin) do
|
||||||
|
it { should be_directory }
|
||||||
|
it { should be_owned_by 'elasticsearch' }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
#path.plugins: /usr/share/elasticsearch/plugins/node1
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
context "basic tests" do
|
shared_examples 'standard::init' do |es_version|
|
||||||
|
|
||||||
describe user('elasticsearch') do
|
describe user('elasticsearch') do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
@@ -39,10 +39,10 @@ context "basic tests" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'plugin' do
|
describe 'version check' do
|
||||||
it 'should be reported as existing', :retry => 3, :retry_wait => 10 do
|
it 'should be reported as version '+es_version do
|
||||||
command = command('curl -s localhost:9200/_nodes/?plugin | grep kopf')
|
command = command('curl -s localhost:9200 | grep number')
|
||||||
expect(command.stdout).to match(/kopf/)
|
expect(command.stdout).to match(es_version)
|
||||||
expect(command.exit_status).to eq(0)
|
expect(command.exit_status).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
6
test/integration/multi-1x/serverspec/default_spec.rb
Normal file
6
test/integration/multi-1x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require 'multi_spec'
|
||||||
|
|
||||||
|
|
||||||
|
describe 'Multi Tests v 1.x' do
|
||||||
|
include_examples 'multi::init', "1.7.3"
|
||||||
|
end
|
||||||
8
test/integration/multi-2x/serverspec/default_spec.rb
Normal file
8
test/integration/multi-2x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
require 'multi_spec'
|
||||||
|
|
||||||
|
|
||||||
|
describe 'Multi Tests v 2.x' do
|
||||||
|
include_examples 'multi::init', "2.1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
require 'serverspec'
|
|
||||||
set :backend, :exec
|
|
||||||
2
test/integration/package-1x/package.yaml
Normal file
2
test/integration/package-1x/package.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- host: test-kitchen
|
||||||
5
test/integration/package-1x/serverspec/default_spec.rb
Normal file
5
test/integration/package-1x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'package_spec'
|
||||||
|
|
||||||
|
describe 'Package Tests v 1.x' do
|
||||||
|
include_examples 'package::init', "1.7.3", ["kopf","marvel"]
|
||||||
|
end
|
||||||
2
test/integration/package-2x/package.yaml
Normal file
2
test/integration/package-2x/package.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- host: test-kitchen
|
||||||
6
test/integration/package-2x/serverspec/default_spec.rb
Normal file
6
test/integration/package-2x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require 'package_spec'
|
||||||
|
|
||||||
|
|
||||||
|
describe 'Package Tests v 2.x' do
|
||||||
|
include_examples 'package::init', "2.1.0", ["kopf","license","marvel-agent"]
|
||||||
|
end
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
- name: Elasticsearch Package tests
|
- name: Elasticsearch Package tests
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
roles:
|
roles:
|
||||||
- { role: elasticsearch, es_config: { "discovery.zen.ping.multicast.enabled": true }, es_instance_name: "node1" }
|
- { role: elasticsearch, es_config: { "http.port": 9200, "transport.tcp.port":9300, discovery.zen.ping.unicast.hosts: "localhost:9300" }, es_instance_name: "node1" }
|
||||||
vars:
|
vars:
|
||||||
es_scripts: true
|
es_scripts: true
|
||||||
es_templates: true
|
es_templates: true
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
require 'serverspec'
|
|
||||||
set :backend, :exec
|
|
||||||
8
test/integration/standard-1x/serverspec/default_spec.rb
Normal file
8
test/integration/standard-1x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
require 'standard_spec'
|
||||||
|
|
||||||
|
|
||||||
|
describe 'Standard Tests v 1.x' do
|
||||||
|
include_examples 'standard::init', "1.7.3"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
2
test/integration/standard-1x/standard.yml
Normal file
2
test/integration/standard-1x/standard.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- host: test-kitchen
|
||||||
9
test/integration/standard-2x/serverspec/default_spec.rb
Normal file
9
test/integration/standard-2x/serverspec/default_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
require 'standard_spec'
|
||||||
|
|
||||||
|
|
||||||
|
describe 'Standard Tests v 2.x' do
|
||||||
|
include_examples 'standard::init', "2.1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2
test/integration/standard-2x/standard.yml
Normal file
2
test/integration/standard-2x/standard.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- host: test-kitchen
|
||||||
@@ -5,6 +5,3 @@
|
|||||||
- { role: elasticsearch, es_instance_name: "node1" }
|
- { role: elasticsearch, es_instance_name: "node1" }
|
||||||
vars:
|
vars:
|
||||||
es_use_repository: "true"
|
es_use_repository: "true"
|
||||||
es_plugins:
|
|
||||||
- plugin: lmenezes/elasticsearch-kopf
|
|
||||||
version: master
|
|
||||||
Reference in New Issue
Block a user