2015-05-13 09:45:55 +02:00
|
|
|
---
|
2018-08-10 14:14:20 +09:00
|
|
|
- name: set fact allow_downgrade to no
|
|
|
|
|
set_fact: allow_downgrade=no
|
|
|
|
|
|
|
|
|
|
- name: set fact allow_downgrade to yes
|
|
|
|
|
set_fact: allow_downgrade=yes
|
|
|
|
|
when: es_allow_downgrades
|
|
|
|
|
|
2015-05-15 10:53:27 +02:00
|
|
|
- name: Ensure libselinux-python on CentOS 6.x
|
2017-05-12 13:31:50 -07:00
|
|
|
become: yes
|
2015-05-15 10:53:27 +02:00
|
|
|
yum: name=libselinux-python state=present update_cache=yes
|
|
|
|
|
when: ( ansible_distribution == "CentOS" ) and ( ansible_distribution_major_version == "6" )
|
2015-07-16 16:42:39 +02:00
|
|
|
|
2015-05-13 09:45:55 +02:00
|
|
|
- name: RedHat - add Elasticsearch repo
|
2017-05-12 13:31:50 -07:00
|
|
|
become: yes
|
2018-12-31 17:28:37 +01:00
|
|
|
template:
|
|
|
|
|
src: 'elasticsearch.repo'
|
|
|
|
|
dest: '/etc/yum.repos.d/elasticsearch-{{ es_repo_name }}.repo'
|
2019-06-24 11:32:27 +02:00
|
|
|
when: es_use_repository and es_add_repository
|
2018-12-31 17:28:37 +01:00
|
|
|
|
|
|
|
|
- name: RedHat - remove unused Elasticsearch repo
|
|
|
|
|
become: yes
|
2019-01-02 10:06:47 +01:00
|
|
|
file:
|
|
|
|
|
path: '/etc/yum.repos.d/elasticsearch-{{ es_other_repo_name }}.repo'
|
|
|
|
|
state: absent
|
2015-07-16 16:42:39 +02:00
|
|
|
when: es_use_repository
|
|
|
|
|
|
2015-09-07 11:18:42 +02:00
|
|
|
- name: RedHat - include versionlock
|
2025-11-07 14:00:38 +02:00
|
|
|
include_tasks: elasticsearch-RedHat-version-lock.yml
|
2015-09-07 11:05:47 +02:00
|
|
|
|
2018-12-27 16:42:14 +01:00
|
|
|
- name: RedHat - Remove the other elasticsearch package if switching between OSS and standard
|
2018-06-18 12:01:45 +02:00
|
|
|
become: yes
|
|
|
|
|
yum:
|
2018-12-27 17:35:44 +01:00
|
|
|
name: '{{ es_other_package_name }}'
|
2018-06-18 12:01:45 +02:00
|
|
|
state: 'absent'
|
|
|
|
|
|
2019-06-28 14:15:03 +02:00
|
|
|
- name: Include optional user and group creation.
|
|
|
|
|
when: (es_user_id is defined) and (es_group_id is defined)
|
2025-11-07 14:00:38 +02:00
|
|
|
include_tasks: elasticsearch-optional-user.yml
|
2019-06-28 14:15:03 +02:00
|
|
|
|
2015-07-14 11:08:17 +02:00
|
|
|
- name: RedHat - Install Elasticsearch
|
2017-05-12 13:31:50 -07:00
|
|
|
become: yes
|
2018-06-13 08:29:45 +02:00
|
|
|
yum:
|
2018-06-13 09:34:28 +02:00
|
|
|
name: '{{ es_package_name }}{% if es_version is defined and es_version != "" %}-{{ es_version }}{% endif %}'
|
2018-06-13 08:29:45 +02:00
|
|
|
state: present
|
|
|
|
|
update_cache: yes
|
2018-08-10 14:14:20 +09:00
|
|
|
allow_downgrade: '{{ allow_downgrade }}'
|
2020-06-29 13:46:51 +02:00
|
|
|
when: es_use_repository and not ansible_check_mode
|
2016-11-03 16:11:57 +01:00
|
|
|
register: redhat_elasticsearch_install_from_repo
|
2017-08-20 10:30:39 -04:00
|
|
|
notify: restart elasticsearch
|
2018-05-02 11:49:25 +03:00
|
|
|
until: redhat_elasticsearch_install_from_repo.rc == 0
|
2016-08-29 16:34:14 +01:00
|
|
|
retries: 5
|
|
|
|
|
delay: 10
|
2018-06-14 14:44:31 +02:00
|
|
|
environment:
|
2019-09-18 10:04:50 +02:00
|
|
|
ES_PATH_CONF: "{{ es_conf_dir }}"
|
2015-07-16 16:42:39 +02:00
|
|
|
|
2021-03-18 15:22:43 +01:00
|
|
|
# workaround due to https://github.com/ansible/ansible/issues/66977
|
|
|
|
|
- set_fact:
|
|
|
|
|
es_rpm_url: "{% if es_version is version('7.0.0', '>=') %}{{ es_package_url }}-{{ es_version }}-x86_64.rpm{% else %}{{ es_package_url }}-{{ es_version }}.rpm{% endif %}"
|
|
|
|
|
|
2015-07-16 16:42:39 +02:00
|
|
|
- name: RedHat - Install Elasticsearch from url
|
2017-05-12 13:31:50 -07:00
|
|
|
become: yes
|
2021-03-18 15:22:43 +01:00
|
|
|
yum:
|
|
|
|
|
name: '{% if es_custom_package_url is defined %}{{ es_custom_package_url }}{% else %}{{ es_rpm_url }}{% endif %}'
|
|
|
|
|
state: present
|
2015-07-16 16:42:39 +02:00
|
|
|
when: not es_use_repository
|
2016-05-26 07:37:33 +06:00
|
|
|
register: elasticsearch_install_from_package
|
2017-08-20 10:30:39 -04:00
|
|
|
notify: restart elasticsearch
|