Merge pull request #521 from elastic/swapsies
Allow switching between oss and standard packages
This commit is contained in:
commit
a7b07e458b
4 changed files with 73 additions and 30 deletions
|
|
@ -14,6 +14,9 @@
|
||||||
es_xpack_conf_subdir: ""
|
es_xpack_conf_subdir: ""
|
||||||
es_repo_name: "{{ es_major_version }}"
|
es_repo_name: "{{ es_major_version }}"
|
||||||
es_xpack_users_command: "elasticsearch-users"
|
es_xpack_users_command: "elasticsearch-users"
|
||||||
|
es_other_package_name: "elasticsearch-oss"
|
||||||
|
es_other_repo_name: "{{ 'oss-' + es_major_version }}"
|
||||||
|
es_other_apt_url: "deb https://artifacts.elastic.co/packages/{{ 'oss-' + es_major_version }}/apt stable main"
|
||||||
|
|
||||||
- name: Detect if es_version is before X-Pack was open and included
|
- name: Detect if es_version is before X-Pack was open and included
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|
@ -32,7 +35,10 @@
|
||||||
- name: Use the oss repo and package if xpack is not being used
|
- name: Use the oss repo and package if xpack is not being used
|
||||||
set_fact:
|
set_fact:
|
||||||
es_repo_name: "{{ 'oss-' + es_major_version }}"
|
es_repo_name: "{{ 'oss-' + es_major_version }}"
|
||||||
|
es_other_repo_name: "{{ es_major_version }}"
|
||||||
|
es_other_apt_url: "deb https://artifacts.elastic.co/packages/{{ es_major_version }}/apt stable main"
|
||||||
es_package_name: "elasticsearch-oss"
|
es_package_name: "elasticsearch-oss"
|
||||||
|
es_other_package_name: "elasticsearch"
|
||||||
when:
|
when:
|
||||||
- es_open_xpack
|
- es_open_xpack
|
||||||
- not es_enable_xpack
|
- not es_enable_xpack
|
||||||
|
|
|
||||||
|
|
@ -7,49 +7,53 @@
|
||||||
set_fact: force_install=yes
|
set_fact: force_install=yes
|
||||||
when: es_allow_downgrades
|
when: es_allow_downgrades
|
||||||
|
|
||||||
- name: Debian - Install apt-transport-https to support https APT downloads
|
- name: Gracefully stop and remove elasticsearch package if switching between OSS and standard
|
||||||
become: yes
|
become: yes
|
||||||
apt: name=apt-transport-https state=present
|
|
||||||
when: es_use_repository
|
|
||||||
|
|
||||||
- name: Debian - Add Elasticsearch repository key
|
|
||||||
become: yes
|
|
||||||
apt_key: url="{{ es_apt_key }}" state=present
|
|
||||||
when: es_use_repository and es_apt_key
|
|
||||||
|
|
||||||
- name: Debian - Add elasticsearch repository
|
|
||||||
become: yes
|
|
||||||
apt_repository: repo={{ item.repo }} state={{ item.state}}
|
|
||||||
with_items:
|
|
||||||
- { repo: "{{ es_apt_url_old }}", state: "absent" }
|
|
||||||
- { repo: "{{ es_apt_url }}", state: "present" }
|
|
||||||
when: es_use_repository
|
|
||||||
|
|
||||||
|
|
||||||
- name: Gracefully stop and remove elasticsearch if we are switching to the oss version
|
|
||||||
when:
|
|
||||||
- es_package_name == 'elasticsearch-oss'
|
|
||||||
block:
|
block:
|
||||||
- name: Check if the elasticsearch package is installed
|
- 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
|
register: elasticsearch_package
|
||||||
failed_when: False
|
failed_when: False
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: stop elasticsearch
|
- name: stop elasticsearch
|
||||||
become: yes
|
|
||||||
service:
|
service:
|
||||||
name: '{{ instance_init_script | basename }}'
|
name: '{{ instance_init_script | basename }}'
|
||||||
state: stopped
|
state: stopped
|
||||||
when: elasticsearch_package.stdout == 'install ok installed'
|
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:
|
apt:
|
||||||
name: 'elasticsearch'
|
name: '{{ es_other_package_name }}'
|
||||||
state: absent
|
state: absent
|
||||||
when: elasticsearch_package.stdout == 'install ok installed'
|
when: elasticsearch_package.stdout == 'install ok installed'
|
||||||
|
|
||||||
|
|
||||||
|
- name: Install Elasticsearch repository
|
||||||
|
when: es_use_repository
|
||||||
|
become: yes
|
||||||
|
block:
|
||||||
|
- name: Debian - Install apt-transport-https to support https APT downloads
|
||||||
|
apt:
|
||||||
|
name: apt-transport-https
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Debian - Add Elasticsearch repository key
|
||||||
|
apt_key:
|
||||||
|
url: '{{ es_apt_key }}'
|
||||||
|
state: present
|
||||||
|
when: es_apt_key is defined
|
||||||
|
|
||||||
|
- name: Debian - Add elasticsearch repository
|
||||||
|
apt_repository:
|
||||||
|
repo: '{{ item.repo }}'
|
||||||
|
state: '{{ item.state }}'
|
||||||
|
with_items:
|
||||||
|
- { repo: "{{ es_apt_url_old }}", state: "absent" }
|
||||||
|
- { repo: "{{ es_apt_url }}", state: "present" }
|
||||||
|
- { repo: "{{ es_other_apt_url }}", state: "absent" }
|
||||||
|
|
||||||
|
|
||||||
- name: Debian - Ensure elasticsearch is installed
|
- name: Debian - Ensure elasticsearch is installed
|
||||||
become: yes
|
become: yes
|
||||||
apt:
|
apt:
|
||||||
|
|
|
||||||
|
|
@ -13,19 +13,27 @@
|
||||||
|
|
||||||
- name: RedHat - add Elasticsearch repo
|
- name: RedHat - add Elasticsearch repo
|
||||||
become: yes
|
become: yes
|
||||||
template: src=elasticsearch.repo dest=/etc/yum.repos.d/elasticsearch-{{ es_repo_name }}.repo
|
template:
|
||||||
|
src: 'elasticsearch.repo'
|
||||||
|
dest: '/etc/yum.repos.d/elasticsearch-{{ es_repo_name }}.repo'
|
||||||
|
when: es_use_repository
|
||||||
|
|
||||||
|
- name: RedHat - remove unused Elasticsearch repo
|
||||||
|
become: yes
|
||||||
|
file:
|
||||||
|
path: '/etc/yum.repos.d/elasticsearch-{{ es_other_repo_name }}.repo'
|
||||||
|
state: absent
|
||||||
when: es_use_repository
|
when: es_use_repository
|
||||||
|
|
||||||
- name: RedHat - include versionlock
|
- name: RedHat - include versionlock
|
||||||
include: elasticsearch-RedHat-version-lock.yml
|
include: elasticsearch-RedHat-version-lock.yml
|
||||||
when: es_version_lock
|
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
|
become: yes
|
||||||
yum:
|
yum:
|
||||||
name: 'elasticsearch'
|
name: '{{ es_other_package_name }}'
|
||||||
state: 'absent'
|
state: 'absent'
|
||||||
when: es_package_name == 'elasticsearch-oss'
|
|
||||||
|
|
||||||
- name: RedHat - Install Elasticsearch
|
- name: RedHat - Install Elasticsearch
|
||||||
become: yes
|
become: yes
|
||||||
|
|
|
||||||
|
|
@ -167,4 +167,29 @@ shared_examples 'shared::init' do |vars|
|
||||||
its(:content) { should match "path.data: #{vars['data_dirs'].join(',')}" }
|
its(:content) { should match "path.data: #{vars['data_dirs'].join(',')}" }
|
||||||
its(:content) { should match "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
|
its(:content) { should match "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if vars['es_use_repository']
|
||||||
|
if vars['ansible_os_family'] == 'RedHat'
|
||||||
|
describe file("/etc/yum.repos.d/elasticsearch-#{vars['es_repo_name']}.repo") do
|
||||||
|
it { should exist }
|
||||||
|
end
|
||||||
|
describe yumrepo("elasticsearch-#{vars['es_repo_name']}") do
|
||||||
|
it { should exist }
|
||||||
|
it { should be_enabled }
|
||||||
|
end
|
||||||
|
describe file("/etc/yum.repos.d/elasticsearch-#{vars['es_other_repo_name']}.repo") do
|
||||||
|
it { should_not exist }
|
||||||
|
end
|
||||||
|
describe yumrepo("elasticsearch-#{vars['es_other_repo_name']}") do
|
||||||
|
it { should_not exist }
|
||||||
|
it { should_not be_enabled }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if vars['ansible_os_family'] == 'Debian'
|
||||||
|
describe command('apt-cache policy') do
|
||||||
|
its(:stdout) { should match /elastic.co.*\/#{Regexp.quote(vars['es_repo_name'])}\//}
|
||||||
|
its(:stdout) { should_not match /elastic.co.*\/#{Regexp.quote(vars['es_other_repo_name'])}\//}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue