upgrade_image.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. # INPUT r_etcd_upgrade_version
  3. - name: Verify cluster is healthy pre-upgrade
  4. command: "{{ etcdctlv2 }} cluster-health"
  5. - name: Get current image
  6. shell: "grep 'ExecStart=' {{ etcd_service_file }} | awk '{print $NF}'"
  7. register: current_image
  8. - name: Set new_etcd_image
  9. set_fact:
  10. new_etcd_image: "{{ current_image.stdout | regex_replace('/etcd.*$','/etcd:' ~ r_etcd_upgrade_version ) }}"
  11. - name: Pull new etcd image
  12. command: "docker pull {{ new_etcd_image }}"
  13. - name: Update to latest etcd image
  14. replace:
  15. dest: "{{ etcd_service_file }}"
  16. regexp: "{{ current_image.stdout }}$"
  17. replace: "{{ new_etcd_image }}"
  18. - import_tasks: validate_etcd_conf.yml
  19. - name: Restart etcd_container
  20. systemd:
  21. name: "{{ etcd_service }}"
  22. daemon_reload: yes
  23. state: restarted
  24. ## TODO: probably should just move this into the backup playbooks, also this
  25. ## will fail on atomic host. We need to revisit how to do etcd backups there as
  26. ## the container may be newer than etcdctl on the host. Assumes etcd3 obsoletes etcd (7.3.1)
  27. - name: Detecting Atomic Host Operating System
  28. stat:
  29. path: /run/ostree-booted
  30. register: l_ostree_booted
  31. - name: Upgrade etcd for etcdctl when not atomic
  32. package:
  33. name: etcd
  34. state: latest
  35. when: not l_ostree_booted.stat.exists | bool
  36. register: result
  37. until: result is succeeded
  38. - name: Verify cluster is healthy
  39. command: "{{ etcdctlv2 }} cluster-health"
  40. register: etcdctl
  41. until: etcdctl.rc == 0
  42. retries: 3
  43. delay: 10