2016-11-15 18:23:53 +01:00
|
|
|
---
|
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: Set real datadir value when customized
|
|
|
|
block:
|
|
|
|
- name: "Is custom datadir present ?"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.stat:
|
2019-12-31 16:56:03 +01:00
|
|
|
path: "{{ elasticsearch_custom_datadir }}"
|
|
|
|
register: elasticsearch_custom_datadir_test
|
|
|
|
check_mode: no
|
2017-03-24 14:15:09 +01:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: "read the real datadir"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.command: readlink -f /var/lib/elasticsearch
|
2023-03-16 14:35:12 +01:00
|
|
|
changed_when: False
|
2019-12-31 16:56:03 +01:00
|
|
|
register: elasticsearch_current_real_datadir_test
|
|
|
|
check_mode: no
|
2016-11-15 18:23:53 +01:00
|
|
|
tags:
|
|
|
|
- elasticsearch
|
2017-11-14 11:05:54 +01:00
|
|
|
when:
|
2021-05-09 23:06:42 +02:00
|
|
|
- elasticsearch_custom_datadir is not none
|
|
|
|
- elasticsearch_custom_datadir | length > 0
|
2016-11-15 18:23:53 +01:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: Datadir is moved to custom path
|
|
|
|
block:
|
|
|
|
- name: elasticsearch is stopped
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.service:
|
2019-12-31 16:56:03 +01:00
|
|
|
name: elasticsearch
|
|
|
|
state: stopped
|
2016-11-15 18:23:53 +01:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: Move elasticsearch datadir to custom datadir
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: mv {{ elasticsearch_current_real_datadir_test.stdout }} {{ elasticsearch_custom_datadir }}
|
2019-12-31 16:56:03 +01:00
|
|
|
args:
|
|
|
|
creates: "{{ elasticsearch_custom_datadir }}"
|
2016-11-15 18:23:53 +01:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: Symlink {{ elasticsearch_custom_datadir }} to /var/lib/elasticsearch
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.file:
|
2019-12-31 16:56:03 +01:00
|
|
|
src: "{{ elasticsearch_custom_datadir }}"
|
|
|
|
dest: '/var/lib/elasticsearch'
|
|
|
|
state: link
|
2016-11-15 18:23:53 +01:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: elasticsearch is started
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.service:
|
2019-12-31 16:56:03 +01:00
|
|
|
name: elasticsearch
|
|
|
|
state: started
|
2016-11-15 18:23:53 +01:00
|
|
|
tags:
|
2017-11-14 11:05:54 +01:00
|
|
|
- elasticsearch
|
|
|
|
when:
|
2021-05-09 23:06:42 +02:00
|
|
|
- elasticsearch_custom_datadir is not none
|
|
|
|
- elasticsearch_custom_datadir | length > 0
|
2017-11-14 11:05:54 +01:00
|
|
|
- elasticsearch_custom_datadir != elasticsearch_current_real_datadir_test.stdout
|
|
|
|
- not elasticsearch_custom_datadir_test.stat.exists
|