From 65238c74bd115b61efa54d4bfcfeb121eeb14a2e Mon Sep 17 00:00:00 2001 From: Maarten Bezemer Date: Fri, 4 Nov 2016 16:04:31 +0100 Subject: [PATCH] Fix version_compare usage --- tasks/elasticsearch-config.yml | 6 +++--- templates/elasticsearch.j2 | 6 +++--- templates/elasticsearch.yml.j2 | 4 ++-- templates/init/debian/elasticsearch.j2 | 2 +- templates/init/redhat/elasticsearch.j2 | 4 ++-- templates/systemd/elasticsearch.j2 | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 2b05d39..83586ae 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -48,18 +48,18 @@ - name: Copy Logging.yml File for Instance template: src=logging.yml.j2 dest={{conf_dir}}/logging.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes notify: restart elasticsearch - when: es_version | version_compare('2.0', '<=') + when: es_version | version_compare('5.0', '<') - name: Copy log4j2.properties File for Instance template: src=log4j2.properties.j2 dest={{conf_dir}}/log4j2.properties owner={{ es_user }} group={{ es_group }} mode=0644 force=yes notify: restart elasticsearch - when: es_version | version_compare('2.0', '>') + when: es_version | version_compare('5.0', '>=') # Copy the JVM Options (5.x only) - name: Copy jvm.options File for Instance template: src=jvm.options.j2 dest={{conf_dir}}/jvm.options owner={{ es_user }} group={{ es_group }} mode=0644 force=yes notify: restart elasticsearch - when: es_version | version_compare('2.0', '>') + when: es_version | version_compare('5.0', '>=') #Clean up un-wanted package scripts to avoid confusion diff --git a/templates/elasticsearch.j2 b/templates/elasticsearch.j2 index 674b170..58eb282 100644 --- a/templates/elasticsearch.j2 +++ b/templates/elasticsearch.j2 @@ -14,7 +14,7 @@ DATA_DIR={{ data_dirs | array_to_str }} # Elasticsearch logs directory LOG_DIR={{log_dir}} -{% if es_version | version_compare('2.0', '<=') %} +{% if es_version | version_compare('5.0', '<') %} # Elasticsearch work directory WORK_DIR={{work_dir}} {% endif %} @@ -22,7 +22,7 @@ WORK_DIR={{work_dir}} # Elasticsearch PID directory PID_DIR={{pid_dir}} -{% if es_version | version_compare('2.0', '<=') %} +{% if es_version | version_compare('5.0', '<') %} # Heap size defaults to 256m min, 1g max # Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g {% if es_heap_size is defined %} @@ -78,7 +78,7 @@ MAX_OPEN_FILES={{es_max_open_files}} {% endif %} # The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.{% if es_version | version_compare('2.0', '>') %}memory_lock{% else %}mlockall{% endif %}: true' option +# Set to "unlimited" if you use the 'bootstrap.{% if es_version | version_compare('5.0', '<=') %}memory_lock{% else %}mlockall{% endif %}: true' option # in elasticsearch.yml (ES_HEAP_SIZE must also be set). # When using Systemd, the LimitMEMLOCK property must be set # in /usr/lib/systemd/system/elasticsearch.service diff --git a/templates/elasticsearch.yml.j2 b/templates/elasticsearch.yml.j2 index da1e7ae..d6755ae 100644 --- a/templates/elasticsearch.yml.j2 +++ b/templates/elasticsearch.yml.j2 @@ -18,8 +18,8 @@ path.conf: {{ conf_dir }} path.data: {{ data_dirs | array_to_str }} -{% if es_version | version_compare('2.0', '<=') %} +{% if es_version | version_compare('5.0', '<') %} path.work: {{ work_dir }} {% endif %} -path.logs: {{ log_dir }} \ No newline at end of file +path.logs: {{ log_dir }} diff --git a/templates/init/debian/elasticsearch.j2 b/templates/init/debian/elasticsearch.j2 index b29b7da..bc6ed87 100755 --- a/templates/init/debian/elasticsearch.j2 +++ b/templates/init/debian/elasticsearch.j2 @@ -104,7 +104,7 @@ fi # Define other required variables PID_FILE="$PID_DIR/$NAME.pid" DAEMON={{es_home}}/bin/elasticsearch -{% if es_version | version_compare('2.0', '<=') %} +{% if es_version | version_compare('5.0', '<') %} 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" {% else %} DAEMON_OPTS="-d -p $PID_FILE -Edefault.path.home=$ES_HOME -Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR -Edefault.path.conf=$CONF_DIR" diff --git a/templates/init/redhat/elasticsearch.j2 b/templates/init/redhat/elasticsearch.j2 index 4166354..91d23a6 100755 --- a/templates/init/redhat/elasticsearch.j2 +++ b/templates/init/redhat/elasticsearch.j2 @@ -3,7 +3,7 @@ # elasticsearch # # chkconfig: 2345 80 20 -# description: Starts and stops a single elasticsearch instance on this system +# description: Starts and stops a single elasticsearch instance on this system # ### BEGIN INIT INFO @@ -116,7 +116,7 @@ start() { cd $ES_HOME echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" -{% if es_version | version_compare('2.0', '<=') %} +{% if es_version | version_compare('5.0', '<') %} 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 {% else %} daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Edefault.path.home=$ES_HOME -Edefault.path.logs=$LOG_DIR -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=$CONF_DIR diff --git a/templates/systemd/elasticsearch.j2 b/templates/systemd/elasticsearch.j2 index f14b82e..8043360 100644 --- a/templates/systemd/elasticsearch.j2 +++ b/templates/systemd/elasticsearch.j2 @@ -22,7 +22,7 @@ ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec {% endif %} ExecStart={{es_home}}/bin/elasticsearch \ -{% if es_version | version_compare('2.0', '<=') %} +{% if es_version | version_compare('5.0', '<') %} -Des.pidfile=${PID_DIR}/elasticsearch.pid \ -Des.default.path.home=${ES_HOME} \ -Des.default.path.logs=${LOG_DIR} \ @@ -45,7 +45,7 @@ StandardError=inherit LimitNOFILE={{es_max_open_files}} # Specifies the maximum number of bytes of memory that may be locked into RAM -# Set to "infinity" if you use the 'bootstrap.{% if es_version | version_compare('2.0', '>') %}memory_lock{% else %}mlockall{% endif %}: true' option +# Set to "infinity" if you use the 'bootstrap.{% if es_version | version_compare('5.0', '<=') %}memory_lock{% else %}mlockall{% endif %}: true' option # in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in {{instance_default_file}} {% if m_lock_enabled %} LimitMEMLOCK=infinity