Przeglądaj źródła

etcd: copy previous database when migrating to system container

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Giuseppe Scrivano 7 lat temu
rodzic
commit
098e93cc02
1 zmienionych plików z 24 dodań i 0 usunięć
  1. 24 0
      roles/etcd/tasks/system_container.yml

+ 24 - 0
roles/etcd/tasks/system_container.yml

@@ -15,6 +15,30 @@
       {%- endif -%}
       {% endfor -%}
 
+- name: Check for previous etcd data store
+  stat:
+    path: "{{ etcd_data_dir }}/member/"
+  register: src_datastore
+
+- name: Check for etcd system container data store
+  stat:
+    path: "{{ r_etcd_common_system_container_host_dir }}/etcd.etcd/member"
+  register: dest_datastore
+
+- name: Ensure that etcd system container data dirs exist
+  file: path="{{ item }}" state=directory
+  with_items:
+    - "{{ r_etcd_common_system_container_host_dir }}/etc"
+    - "{{ r_etcd_common_system_container_host_dir }}/etcd.etcd"
+
+- name: Copy etcd data store
+  command: >
+    cp -a {{ etcd_data_dir }}/member
+    {{ r_etcd_common_system_container_host_dir }}/etcd.etcd/member
+  when:
+    - src_datastore.stat.exists
+    - not dest_datastore.stat.exists
+
 - name: Install or Update Etcd system container package
   oc_atomic_container:
     name: etcd