|
| 1 | +# Migrate data from existing containerised opendistro v1.12.0 to containerised opensearch 2.1.0. |
| 2 | +# |
1 | 3 | # 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. |
4 | 9 |
|
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. |
6 | 11 |
|
7 | 12 | - name: Stop opendistro |
8 | 13 | ansible.builtin.systemd: |
9 | 14 | name: opendistro.service |
10 | 15 | state: stopped |
11 | 16 | 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 }}" |
20 | 17 |
|
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 |
25 | 23 | owner: "{{ opensearch_podman_user }}" |
26 | 24 | 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