Skip to content

Commit 1a16c6b

Browse files
committed
migrate opendistro host data to opensearch automatically
1 parent e4085c6 commit 1a16c6b

File tree

3 files changed

+27
-46
lines changed

3 files changed

+27
-46
lines changed

ansible/adhoc/migrate-opendistro.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

ansible/roles/opensearch/tasks/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
---
22

3+
- name: Check for existing opendistro service
4+
stat:
5+
path: /etc/systemd/system/opendistro.service
6+
register: _opensearch_opendistro_service
7+
8+
- name: Migrate opendistro data
9+
import_tasks:
10+
file: migrate-opendistro.yml
11+
when: _opensearch_opendistro_service.stat.exists
12+
313
- name: Increase maximum number of virtual memory maps
414
# see https://opensearch.org/docs/2.0/opensearch/install/important-settings/
515
ansible.posix.sysctl:
Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
1+
# Migrate data from existing containerised opendistro v1.12.0 to containerised opensearch 2.1.0.
2+
#
13
# This relies on:
2-
# - open{distro,search}_podman_user being the same
3-
# - opendistro and opensearch hosts being the same
4+
# - Both opendistro and opensearch using host directories for data. See `_default_opendistro_data_path` below
5+
# - Pre-upgrade group `opendistro` and current group `opensearch` containing the same host.
6+
#
7+
# NB: If `opendistro_data_path` was set to something non-default it MUST be set again in the `opensearch` group_vars,
8+
# as the `opendistro` group will not exist in the groups.
49

5-
# NB: This deliberately does not remove the opendistro podman volume - do that manually once happy.
10+
# NB: This deliberately does not remove the opendistro data - this could be done manually if required.
611

712
- name: Stop opendistro
813
ansible.builtin.systemd:
914
name: opendistro.service
1015
state: stopped
1116
enabled: false
12-
become: yes
13-
14-
- name: Export opendistro volume
15-
ansible.builtin.shell:
16-
cmd: podman volume export opendistro --output /tmp/opendistro_volume.tar
17-
creates: /tmp/opendistro_volume.tar
18-
become: yes
19-
become_user: "{{ opensearch_podman_user }}"
2017

21-
- name: Make opensearch data directory
22-
file:
23-
path: "{{ opensearch_data_path }}"
24-
state: directory
18+
- name: Copy opendistro data directory
19+
ansible.builtin.copy:
20+
remote_src: true
21+
src: "{{ opendistro_data_path | default(_default_opendistro_data_path) }}"
22+
dest: "{{ opensearch_data_path | dirname }}/" # copying a directory, so need to specify the parent for destination
2523
owner: "{{ opensearch_podman_user }}"
2624
group: "{{ opensearch_podman_user }}"
27-
become: yes
28-
become_user: "{{ opensearch_podman_user }}"
29-
30-
- name: Unpack opendistro volume
31-
ansible.builtin.unarchive:
32-
remote_src: yes
33-
src: /tmp/opendistro_volume.tar
34-
dest: "{{ opensearch_data_path }}"
35-
owner: "{{ opensearch_podman_user }}"
36-
group: "{{ opensearch_podman_user }}"
37-
list_files: yes
38-
become: yes
39-
become_user: "{{ opensearch_podman_user }}"
25+
mode: 0770
26+
vars:
27+
# from environments/common/inventory/group_vars/all/opendistro.yml:
28+
_default_opendistro_data_path: "{{ appliances_state_dir | default('/usr/share') }}/elasticsearch/data"

0 commit comments

Comments
 (0)