Check for restarts only when restart handler executes

This commit is contained in:
John Reed 2017-03-21 10:13:10 -04:00
parent 64f9cdbc5c
commit 692637f073
2 changed files with 6 additions and 2 deletions

View file

@ -4,7 +4,11 @@
# Restart service and ensure it is enabled # Restart service and ensure it is enabled
- 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_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)) when:
- es_restart_on_change
- es_start_service
- ((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))
register: es_restarted
#Templates are a handler as they need to come after a restart e.g. suppose user removes security on a running node and doesn't #Templates are a handler as they need to come after a restart e.g. suppose user removes security on a running node and doesn't
#specify es_api_basic_auth_username and es_api_basic_auth_password. The templates will subsequently not be removed if we don't wait for the node to restart. #specify es_api_basic_auth_username and es_api_basic_auth_password. The templates will subsequently not be removed if we don't wait for the node to restart.

View file

@ -46,7 +46,7 @@
- name: Wait for elasticsearch to startup - name: Wait for elasticsearch to startup
wait_for: host={{es_api_host}} port={{es_api_port}} delay=5 connect_timeout=1 wait_for: host={{es_api_host}} port={{es_api_port}} delay=5 connect_timeout=1
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)) when: es_restarted is defined and es_restarted.changed
- name: activate-license - name: activate-license
include: ./xpack/security/elasticsearch-xpack-activation.yml include: ./xpack/security/elasticsearch-xpack-activation.yml