From 914cb7867cbc64c33c9ebb949e5f4619b71b4bb9 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Tue, 17 Jan 2017 14:42:21 +0000 Subject: [PATCH] Move restart to main from handler --- handlers/elasticsearch-restart.yml | 8 -------- handlers/main.yml | 3 ++- tasks/main.yml | 4 ++++ templates/elasticsearch.j2 | 2 +- templates/systemd/elasticsearch.j2 | 1 - 5 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 handlers/elasticsearch-restart.yml diff --git a/handlers/elasticsearch-restart.yml b/handlers/elasticsearch-restart.yml deleted file mode 100644 index 41853bd..0000000 --- a/handlers/elasticsearch-restart.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Restart Elasticsearch - service: name={{instance_init_script | basename}} state=restarted enabled=yes - when: es_restart_on_change and es_start_service and ((plugin_installed is defined and plugin_installed.changed) or (config_updated is defined and config_updated.changed) or (xpack_state.changed) or (debian_elasticsearch_install_from_repo.changed or redhat_elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed)) - -- name: Wait for elasticsearch to startup - wait_for: host={{es_api_host}} port={{es_api_port}} delay=5 connect_timeout=1 \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml index 310e9f7..ff07a08 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,7 +3,8 @@ # Restart service and ensure it is enabled - name: restart elasticsearch - include: ./handlers/elasticsearch-restart.yml + service: name={{instance_init_script | basename}} state=restarted enabled=yes + when: es_restart_on_change and es_start_service and ((plugin_installed is defined and plugin_installed.changed) or (config_updated is defined and config_updated.changed) or (xpack_state.changed) or (debian_elasticsearch_install_from_repo.changed or redhat_elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed)) # All security specific actions should go in here - name: activate-security diff --git a/tasks/main.yml b/tasks/main.yml index bcd2df0..fe12c38 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -41,4 +41,8 @@ when: es_templates tags: - templates + - meta: flush_handlers + +- name: Wait for elasticsearch to startup + wait_for: host={{es_api_host}} port={{es_api_port}} delay=5 connect_timeout=1 \ No newline at end of file diff --git a/templates/elasticsearch.j2 b/templates/elasticsearch.j2 index 0c7f4a6..a86fe16 100644 --- a/templates/elasticsearch.j2 +++ b/templates/elasticsearch.j2 @@ -17,7 +17,7 @@ LOG_DIR={{log_dir}} # Elasticsearch PID directory PID_DIR={{pid_dir}} -ES_JVM_OPTIONS={{conf_dir}}/jvm.options +#ES_JVM_OPTIONS={{conf_dir}}/jvm.options # Configure restart on package upgrade (true, every other setting will lead to not restarting) #ES_RESTART_ON_UPGRADE=true diff --git a/templates/systemd/elasticsearch.j2 b/templates/systemd/elasticsearch.j2 index 334310e..dafae58 100644 --- a/templates/systemd/elasticsearch.j2 +++ b/templates/systemd/elasticsearch.j2 @@ -33,7 +33,6 @@ ExecStart={{es_home}}/bin/elasticsearch \ # stores its logs in /var/log/elasticsearch and does not use # journalctl by default. If you also want to enable journalctl # logging, you can simply remove the "quiet" option from ExecStart. - StandardOutput=journal StandardError=inherit