ansible-roles/elasticsearch/tasks/datadir.yml

51 lines
1.5 KiB
YAML
Raw Normal View History

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 ?"
stat:
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"
command: readlink -f /var/lib/elasticsearch
changed_when: false
register: elasticsearch_current_real_datadir_test
check_mode: no
2016-11-15 18:23:53 +01:00
tags:
- elasticsearch
when:
- 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
service:
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
command: mv {{ elasticsearch_current_real_datadir_test.stdout }} {{ elasticsearch_custom_datadir }}
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
file:
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
service:
name: elasticsearch
state: started
2016-11-15 18:23:53 +01:00
tags:
- elasticsearch
when:
- elasticsearch_custom_datadir is not none
- elasticsearch_custom_datadir | length > 0
- elasticsearch_custom_datadir != elasticsearch_current_real_datadir_test.stdout
- not elasticsearch_custom_datadir_test.stat.exists