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
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
- 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_start_service and (not elasticsearch_started.changed or (plugin_installed is defined and plugin_installed.changed))
|
when: es_start_service and (not elasticsearch_started.changed or (plugin_installed is defined and plugin_installed.changed) or elasticsearch_install.changed)
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,7 @@
|
||||||
#Relies on elasticsearch distribution installing a serviced script to determine whether one should be copied.
|
#Relies on elasticsearch distribution installing a serviced script to determine whether one should be copied.
|
||||||
|
|
||||||
|
|
||||||
- stat: path={{sysd_script}}
|
- 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', '>=')) }}
|
||||||
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: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}}
|
- set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}}
|
||||||
when: use_system_d
|
when: use_system_d
|
||||||
|
|
@ -81,3 +78,17 @@
|
||||||
notify: restart elasticsearch
|
notify: restart elasticsearch
|
||||||
|
|
||||||
#Clean up un-wanted package scripts to avoid confusion
|
#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
|
- name: Include specific Elasticsearch
|
||||||
include: elasticsearch-RedHat.yml
|
include: elasticsearch-RedHat.yml
|
||||||
when: ansible_os_family == 'RedHat'
|
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_vars: "{{ansible_os_family}}.yml"
|
||||||
- include: java.yml
|
- include: java.yml
|
||||||
- include: elasticsearch.yml
|
- include: elasticsearch.yml
|
||||||
- include: elasticsearch-plugins.yml
|
- include: elasticsearch-config.yml
|
||||||
when: es_plugins is defined
|
|
||||||
- include: elasticsearch-scripts.yml
|
- include: elasticsearch-scripts.yml
|
||||||
when: es_scripts
|
when: es_scripts
|
||||||
|
- include: elasticsearch-plugins.yml
|
||||||
|
when: es_plugins is defined
|
||||||
|
- include: elasticsearch-service.yml
|
||||||
- include: elasticsearch-templates.yml
|
- include: elasticsearch-templates.yml
|
||||||
when: es_templates
|
when: es_templates
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
@ -47,5 +47,21 @@ shared_examples 'standard::init' do |es_version|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe file('/etc/init.d/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/default/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/sysconfig/elasticsearch') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/usr/lib/systemd/system/elasticsearch.service') do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
java: "openjdk-7-jre-headless"
|
java: "openjdk-7-jre-headless"
|
||||||
default_file: "/etc/default/elasticsearch"
|
default_file: "/etc/default/elasticsearch"
|
||||||
init_script: "/etc/init.d/elasticsearch"
|
|
||||||
es_home: "/usr/share/elasticsearch"
|
es_home: "/usr/share/elasticsearch"
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
java: "java-1.8.0-openjdk.x86_64"
|
java: "java-1.8.0-openjdk.x86_64"
|
||||||
default_file: "/etc/sysconfig/elasticsearch"
|
default_file: "/etc/sysconfig/elasticsearch"
|
||||||
init_script: "/etc/init.d/elasticsearch"
|
|
||||||
es_home: "/usr/share/elasticsearch"
|
es_home: "/usr/share/elasticsearch"
|
||||||
|
|
@ -2,3 +2,4 @@
|
||||||
es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch"
|
es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch"
|
||||||
es_conf_dir: "/etc/elasticsearch"
|
es_conf_dir: "/etc/elasticsearch"
|
||||||
sysd_script: "/usr/lib/systemd/system/elasticsearch.service"
|
sysd_script: "/usr/lib/systemd/system/elasticsearch.service"
|
||||||
|
init_script: "/etc/init.d/elasticsearch"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue