Issue 40 + refactoring for better layout and more efficient restart process
This commit is contained in:
parent
731d4b20fe
commit
7b620eadf9
9 changed files with 44 additions and 24 deletions
|
|
@ -10,10 +10,7 @@
|
|||
#Relies on elasticsearch distribution installing a serviced script to determine whether one should be copied.
|
||||
|
||||
|
||||
- stat: path={{sysd_script}}
|
||||
register: systemd_service
|
||||
|
||||
- set_fact: use_system_d={{systemd_service.stat.exists and ((ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution == 'CentOS' and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>='))) }}
|
||||
- set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution == 'CentOS' and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>=')) }}
|
||||
|
||||
- set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}}
|
||||
when: use_system_d
|
||||
|
|
@ -81,3 +78,17 @@
|
|||
notify: restart elasticsearch
|
||||
|
||||
#Clean up un-wanted package scripts to avoid confusion
|
||||
|
||||
- name: Delete Default Init
|
||||
file: dest=/etc/init.d/elasticsearch state=absent
|
||||
|
||||
- name: Delete Default Environment File
|
||||
file: dest=/etc/default/elasticsearch state=absent
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Delete Default Environment File
|
||||
file: dest=/etc/sysconfig/elasticsearch state=absent
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Delete Default Sysconfig File
|
||||
file: dest=/usr/lib/systemd/system/elasticsearch.service state=absent
|
||||
|
|
|
|||
6
tasks/elasticsearch-service.yml
Normal file
6
tasks/elasticsearch-service.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Make sure the service is started, and restart if necessary
|
||||
- name: Start elasticsearch service
|
||||
service: name={{instance_init_script | basename}} state=started enabled=yes
|
||||
when: es_start_service
|
||||
register: elasticsearch_started
|
||||
|
||||
|
|
@ -16,17 +16,3 @@
|
|||
- name: Include specific Elasticsearch
|
||||
include: elasticsearch-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
#Configuration file for elasticsearch
|
||||
- name: Elasticsearch configuration
|
||||
include: elasticsearch-config.yml
|
||||
|
||||
# Make sure the service is started, and restart if necessary
|
||||
- name: Start elasticsearch service
|
||||
service: name={{instance_init_script | basename}} state=started enabled=yes
|
||||
when: es_start_service
|
||||
register: elasticsearch_started
|
||||
|
||||
- name: Restart elasticsearch service if new version installed
|
||||
service: name={{instance_init_script | basename}} state=restarted enabled=yes
|
||||
when: es_start_service and elasticsearch_install.changed and not elasticsearch_started.changed
|
||||
|
|
@ -5,10 +5,12 @@
|
|||
include_vars: "{{ansible_os_family}}.yml"
|
||||
- include: java.yml
|
||||
- include: elasticsearch.yml
|
||||
- include: elasticsearch-plugins.yml
|
||||
when: es_plugins is defined
|
||||
- include: elasticsearch-config.yml
|
||||
- include: elasticsearch-scripts.yml
|
||||
when: es_scripts
|
||||
- include: elasticsearch-plugins.yml
|
||||
when: es_plugins is defined
|
||||
- include: elasticsearch-service.yml
|
||||
- include: elasticsearch-templates.yml
|
||||
when: es_templates
|
||||
- meta: flush_handlers
|
||||
Loading…
Add table
Add a link
Reference in a new issue