Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Gracefully remove default elasticsearch package when upgrading to the
Browse files Browse the repository at this point in the history
oss version
  • Loading branch information
Crazybus committed Jun 18, 2018
1 parent d451d27 commit d795e01
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tasks/elasticsearch-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@
- { repo: "{{ es_apt_url }}", state: "present" }
when: es_use_repository

- name: Stop elasticsearch and remove the package if we are upgrading to the oss version
when: es_package_name == 'elasticsearch-oss'
block:
- name: Check if the elasticsearch package is still installed
command: dpkg -l elasticsearch
register: elasticsearch_package
failed_when: False
changed_when: False

- name: Gracefully stop and remove elasticsearch if we are switching to the oss version
when: elasticsearch_package.rc == 0
block:
- name: stop elasticsearch
become: yes
service:
name: '{{ instance_init_script | basename }}'
state: stopped

- name: Debian - Remove elasticsearch package if we are installing the oss package
become: yes
apt:
name: 'elasticsearch'
state: absent

- name: Debian - Ensure elasticsearch is installed
become: yes
apt:
Expand Down
7 changes: 7 additions & 0 deletions tasks/elasticsearch-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
include: elasticsearch-RedHat-version-lock.yml
when: es_version_lock

- name: RedHat - Remove non oss package if the old elasticsearch package is installed
become: yes
yum:
name: 'elasticsearch'
state: 'absent'
when: es_package_name == 'elasticsearch-oss'

- name: RedHat - Install Elasticsearch
become: yes
yum:
Expand Down

0 comments on commit d795e01

Please # to comment.