migrate.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. # Should this be run in a serial manner?
  3. - set_fact:
  4. l_etcd_service: "{{ 'etcd_container' if openshift.common.is_containerized else 'etcd' }}"
  5. - name: Disable etcd members
  6. service:
  7. name: "{{ l_etcd_service }}"
  8. state: stopped
  9. # Should we skip all TTL keys? https://bugzilla.redhat.com/show_bug.cgi?id=1389773
  10. - name: Migrate etcd data
  11. command: >
  12. etcdctl migrate --data-dir={{ etcd_data_dir }}
  13. environment:
  14. ETCDCTL_API: 3
  15. register: l_etcdctl_migrate
  16. # TODO(jchaloup): If any of the members fails, we need to restore all members to v2 from the pre-migrate backup
  17. - name: Check the etcd v2 data are correctly migrated
  18. fail:
  19. msg: "Failed to migrate a member"
  20. when: "'finished transforming keys' not in l_etcdctl_migrate.stdout and 'no v2 keys to migrate' not in l_etcdctl_migrate.stdout"
  21. - name: Migration message
  22. debug:
  23. msg: "Etcd migration finished with: {{ l_etcdctl_migrate.stdout }}"
  24. - name: Enable etcd member
  25. service:
  26. name: "{{ l_etcd_service }}"
  27. state: started
  28. # NOTE: /usr/local/bin may be removed from the PATH by ansible hence why
  29. # it's added to the environment in this task.
  30. - name: Re-introduce leases (as a replacement for key TTLs)
  31. command: >
  32. oadm migrate etcd-ttl \
  33. --cert {{ r_etcd_common_master_peer_cert_file }} \
  34. --key {{ r_etcd_common_master_peer_key_file }} \
  35. --cacert {{ r_etcd_common_master_peer_ca_file }} \
  36. --etcd-address 'https://{{ etcd_peer }}:{{ etcd_client_port }}' \
  37. --ttl-keys-prefix {{ item }} \
  38. --lease-duration 1h
  39. environment:
  40. ETCDCTL_API: 3
  41. PATH: "/usr/local/bin:/var/usrlocal/bin:{{ ansible_env.PATH }}"
  42. with_items:
  43. - "/kubernetes.io/events"
  44. - "/kubernetes.io/masterleases"
  45. delegate_to: "{{ groups.oo_first_master[0] }}"
  46. run_once: true
  47. - set_fact:
  48. r_etcd_migrate_success: true