From a10676384f54bfbee1d36192ab6fdbab52a50523 Mon Sep 17 00:00:00 2001 From: Michel Weitbrecht Date: Thu, 27 Dec 2018 22:47:24 +0100 Subject: [PATCH 1/3] Refactor deprecated filter calls Previously, each of the calls generated a warning : "Using tests as filters is deprecated. Instead of using `result|version_compare` use `result is version_compare`. This feature will be removed in version 2.9.". --- defaults/main.yml | 2 +- tasks/compatibility-variables.yml | 2 +- tasks/xpack/elasticsearch-xpack.yml | 2 +- .../xpack/security/elasticsearch-security.yml | 2 +- templates/elasticsearch.yml.j2 | 2 +- templates/init/debian/elasticsearch.j2 | 2 +- templates/init/redhat/elasticsearch.j2 | 2 +- templates/log4j2.properties.j2 | 18 +++++++++--------- templates/systemd/elasticsearch.j2 | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index f9f140b..91177cb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,7 +27,7 @@ es_data_dirs: "/var/lib/elasticsearch" es_log_dir: "/var/log/elasticsearch" es_action_auto_create_index: true es_max_open_files: 65536 -es_max_threads: "{{ 2048 if ( es_version | version_compare('6.0.0', '<')) else 8192 }}" +es_max_threads: "{{ 2048 if ( es_version is version_compare('6.0.0', '<')) else 8192 }}" es_max_map_count: 262144 es_allow_downgrades: false es_xpack_features: ["alerting","monitoring","graph","ml","security"] diff --git a/tasks/compatibility-variables.yml b/tasks/compatibility-variables.yml index e56e3c1..b5cf31c 100644 --- a/tasks/compatibility-variables.yml +++ b/tasks/compatibility-variables.yml @@ -18,7 +18,7 @@ - name: Detect if es_version is before X-Pack was open and included set_fact: es_open_xpack: false - when: "es_version | version_compare('6.3.0', '<')" + when: "es_version is version_compare('6.3.0', '<')" - name: If this is an older version we need to install X-Pack as a plugin and use a differet users command set_fact: diff --git a/tasks/xpack/elasticsearch-xpack.yml b/tasks/xpack/elasticsearch-xpack.yml index 2074dcb..c3c3906 100644 --- a/tasks/xpack/elasticsearch-xpack.yml +++ b/tasks/xpack/elasticsearch-xpack.yml @@ -20,4 +20,4 @@ - name: Set elasticsearch.keystore Permissions become: yes file: state=file path={{ conf_dir }}/elasticsearch.keystore owner={{ es_user }} group={{ es_group }} - when: es_enable_xpack and "security" in es_xpack_features and (es_version | version_compare('6.0.0', '>')) + when: es_enable_xpack and "security" in es_xpack_features and (es_version is version_compare('6.0.0', '>')) diff --git a/tasks/xpack/security/elasticsearch-security.yml b/tasks/xpack/security/elasticsearch-security.yml index 8f749f8..048351b 100644 --- a/tasks/xpack/security/elasticsearch-security.yml +++ b/tasks/xpack/security/elasticsearch-security.yml @@ -14,7 +14,7 @@ #-----------------------------Create Bootstrap User----------------------------------- ### START BLOCK elasticsearch keystore ### - name: create the elasticsearch keystore - when: (es_enable_xpack and "security" in es_xpack_features) and (es_version | version_compare('6.0.0', '>')) + when: (es_enable_xpack and "security" in es_xpack_features) and (es_version is version_compare('6.0.0', '>')) block: - name: create the keystore if it doesn't exist yet become: yes diff --git a/templates/elasticsearch.yml.j2 b/templates/elasticsearch.yml.j2 index ef8dd9b..09f8af0 100644 --- a/templates/elasticsearch.yml.j2 +++ b/templates/elasticsearch.yml.j2 @@ -15,7 +15,7 @@ node.name: {{inventory_hostname}}-{{es_instance_name}} # Path to directory containing configuration (this file and logging.yml): -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} path.conf: {{ conf_dir }} {% endif %} diff --git a/templates/init/debian/elasticsearch.j2 b/templates/init/debian/elasticsearch.j2 index efe2c37..7d7e346 100755 --- a/templates/init/debian/elasticsearch.j2 +++ b/templates/init/debian/elasticsearch.j2 @@ -92,7 +92,7 @@ fi # Define other required variables PID_FILE="$PID_DIR/$NAME.pid" DAEMON=$ES_HOME/bin/elasticsearch -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} DAEMON_OPTS="-d -p $PID_FILE -Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR -Edefault.path.conf=$CONF_DIR" {% else %} DAEMON_OPTS="-d -p $PID_FILE" diff --git a/templates/init/redhat/elasticsearch.j2 b/templates/init/redhat/elasticsearch.j2 index c993e14..8ba1164 100755 --- a/templates/init/redhat/elasticsearch.j2 +++ b/templates/init/redhat/elasticsearch.j2 @@ -140,7 +140,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('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR -Edefault.path.conf=$CONF_DIR {% else %} daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d diff --git a/templates/log4j2.properties.j2 b/templates/log4j2.properties.j2 index 269be52..dbfb23e 100644 --- a/templates/log4j2.properties.j2 +++ b/templates/log4j2.properties.j2 @@ -11,14 +11,14 @@ appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n appender.rolling.type = RollingFile appender.rolling.name = rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.rolling.fileName = ${sys:es.logs}.log {% else %} appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log {% endif %} appender.rolling.layout.type = PatternLayout appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log {% else %} appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz @@ -27,7 +27,7 @@ appender.rolling.policies.type = Policies appender.rolling.policies.time.type = TimeBasedTriggeringPolicy appender.rolling.policies.time.interval = 1 appender.rolling.policies.time.modulate = true -{% if (es_version | version_compare('6.0.0', '>')) %} +{% if (es_version is version_compare('6.0.0', '>')) %} appender.rolling.policies.size.type = SizeBasedTriggeringPolicy appender.rolling.policies.size.size = 128MB appender.rolling.strategy.type = DefaultRolloverStrategy @@ -45,14 +45,14 @@ rootLogger.appenderRef.rolling.ref = rolling appender.deprecation_rolling.type = RollingFile appender.deprecation_rolling.name = deprecation_rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.deprecation_rolling.fileName = ${sys:es.logs}_deprecation.log {% else %} appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.log {% endif %} appender.deprecation_rolling.layout.type = PatternLayout appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.deprecation_rolling.filePattern = ${sys:es.logs}_deprecation-%i.log.gz {% else %} appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.log.gz @@ -70,14 +70,14 @@ logger.deprecation.additivity = false appender.index_search_slowlog_rolling.type = RollingFile appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.index_search_slowlog_rolling.fileName = ${sys:es.logs}_index_search_slowlog.log {% else %} appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log {% endif %} appender.index_search_slowlog_rolling.layout.type = PatternLayout appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs}_index_search_slowlog-%d{yyyy-MM-dd}.log {% else %} appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%d{yyyy-MM-dd}.log @@ -94,14 +94,14 @@ logger.index_search_slowlog_rolling.additivity = false appender.index_indexing_slowlog_rolling.type = RollingFile appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs}_index_indexing_slowlog.log {% else %} appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log {% endif %} appender.index_indexing_slowlog_rolling.layout.type = PatternLayout appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs}_index_indexing_slowlog-%d{yyyy-MM-dd}.log {% else %} appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%d{yyyy-MM-dd}.log diff --git a/templates/systemd/elasticsearch.j2 b/templates/systemd/elasticsearch.j2 index 8bd5545..a1747d0 100644 --- a/templates/systemd/elasticsearch.j2 +++ b/templates/systemd/elasticsearch.j2 @@ -18,13 +18,13 @@ WorkingDirectory={{es_home}} User={{es_user}} Group={{es_group}} -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec {% endif %} ExecStart={{es_home}}/bin/elasticsearch \ -p ${PID_DIR}/elasticsearch.pid \ -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version_compare('6.0.0', '<')) %} -Edefault.path.logs=${LOG_DIR} \ -Edefault.path.data=${DATA_DIR} \ -Edefault.path.conf=${CONF_DIR} \ From eed3efbb85353f3829c46f14c21c65bc4a8185ee Mon Sep 17 00:00:00 2001 From: Lilian Deloche Date: Thu, 7 Feb 2019 12:24:16 +0100 Subject: [PATCH 2/3] Use sleep command in remplacement of pause --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index e98b98d..cb4735e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -73,7 +73,7 @@ # If playbook runs too fast, Native commands could fail as the Native Realm is not yet up - name: Wait 15 seconds for the Native Relm to come up - pause: seconds=15 + command: sleep 15 when: manage_native_realm - name: activate-license From c4b51482c10c4daa5ad55bd6fd79f39abceaf578 Mon Sep 17 00:00:00 2001 From: Grzegorz Nowak Date: Thu, 28 Feb 2019 14:33:53 +0100 Subject: [PATCH 3/3] make playbook (tested for debians) compatible with the mode --- tasks/elasticsearch-Debian.yml | 1 + tasks/java.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index 7b9a735..037ea23 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -15,6 +15,7 @@ register: elasticsearch_package failed_when: False changed_when: False + check_mode: no - name: stop elasticsearch service: diff --git a/tasks/java.yml b/tasks/java.yml index 68abc53..26d6b15 100644 --- a/tasks/java.yml +++ b/tasks/java.yml @@ -44,6 +44,7 @@ register: open_jdk ignore_errors: yes changed_when: false + check_mode: no #https://github.com/docker-library/openjdk/issues/19 - ensures tests pass due to java 8 broken certs - name: refresh the java ca-certificates