summaryrefslogtreecommitdiffstats
path: root/roles/etcd_migrate/tasks/migrate.yml
blob: 7f441568aa8e0f1d199956c5f3027efca3bef260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
# Should this be run in a serial manner?
- set_fact:
    l_etcd_service: "{{ 'etcd_container' if openshift.common.is_containerized else 'etcd' }}"

- name: Disable etcd members
  service:
    name: "{{ l_etcd_service }}"
    state: stopped

# Should we skip all TTL keys? https://bugzilla.redhat.com/show_bug.cgi?id=1389773
- name: Migrate etcd data
  command: >
    etcdctl migrate --data-dir={{ etcd_data_dir }}
  environment:
    ETCDCTL_API: 3
  register: l_etcdctl_migrate

# TODO(jchaloup): If any of the members fails, we need to restore all members to v2 from the pre-migrate backup
- name: Check the etcd v2 data are correctly migrated
  fail:
    msg: "Failed to migrate a member"
  when: "'finished transforming keys' not in l_etcdctl_migrate.stdout and 'no v2 keys to migrate' not in l_etcdctl_migrate.stdout"

- name: Migration message
  debug:
    msg: "Etcd migration finished with: {{ l_etcdctl_migrate.stdout }}"

- name: Enable etcd member
  service:
    name: "{{ l_etcd_service }}"
    state: started

# NOTE: /usr/local/bin may be removed from the PATH by ansible hence why
#       it's added to the environment in this task.
- name: Re-introduce leases (as a replacement for key TTLs)
  command: >
    oadm migrate etcd-ttl \
    --cert {{ etcd_peer_cert_file }} \
    --key {{ etcd_peer_key_file }} \
    --cacert {{ etcd_peer_ca_file }} \
    --etcd-address 'https://{{ etcd_peer }}:{{ etcd_client_port }}' \
    --ttl-keys-prefix {{ item }} \
    --lease-duration 1h
  environment:
    ETCDCTL_API: 3
    PATH: "/usr/local/bin:/var/usrlocal/bin:{{ ansible_env.PATH }}"
  with_items:
  - "/kubernetes.io/events"
  - "/kubernetes.io/masterleases"
  delegate_to: "{{ groups.oo_first_master[0] }}"
  run_once: true

- set_fact:
    r_etcd_migrate_success: true