Allow switching between oss and standard packages

Before only going from the standard package to oss was supported. Now
this works properly in both directions.
This commit is contained in:
Michael Russell 2018-12-27 16:42:14 +01:00
parent f89f56bc34
commit 3e265a467d
No known key found for this signature in database
GPG key ID: A90C1696496085FE
3 changed files with 9 additions and 9 deletions

View file

@ -14,6 +14,7 @@
es_xpack_conf_subdir: ""
es_repo_name: "{{ es_major_version }}"
es_xpack_users_command: "elasticsearch-users"
es_other_package_name: "elasticsearch-oss"
- name: Detect if es_version is before X-Pack was open and included
set_fact:
@ -33,6 +34,7 @@
set_fact:
es_repo_name: "{{ 'oss-' + es_major_version }}"
es_package_name: "elasticsearch-oss"
es_other_package_name: "elasticsearch"
when:
- es_open_xpack
- not es_enable_xpack

View file

@ -26,12 +26,10 @@
when: es_use_repository
- name: Gracefully stop and remove elasticsearch if we are switching to the oss version
when:
- es_package_name == 'elasticsearch-oss'
- name: Gracefully stop and remove elasticsearch package if switching between OSS and standard
block:
- name: Check if the elasticsearch package is installed
shell: dpkg-query -W -f'${Status}' elasticsearch
shell: "dpkg-query -W -f'${Status}' {{ es_other_package_name }}"
register: elasticsearch_package
failed_when: False
changed_when: False
@ -43,13 +41,14 @@
state: stopped
when: elasticsearch_package.stdout == 'install ok installed'
- name: Debian - Remove elasticsearch package if we are installing the oss package
- name: Debian - Remove elasticsearch package if we are switching to a different package type
become: yes
apt:
name: 'elasticsearch'
name: '{{ es_other_package_name }}'
state: absent
when: elasticsearch_package.stdout == 'install ok installed'
- name: Debian - Ensure elasticsearch is installed
become: yes
apt:

View file

@ -20,12 +20,11 @@
include: elasticsearch-RedHat-version-lock.yml
when: es_version_lock
- name: RedHat - Remove non oss package if the old elasticsearch package is installed
- name: RedHat - Remove the other elasticsearch package if switching between OSS and standard
become: yes
yum:
name: 'elasticsearch'
name: es_other_package_name
state: 'absent'
when: es_package_name == 'elasticsearch-oss'
- name: RedHat - Install Elasticsearch
become: yes