upgrade_image.yml 897 B

123456789101112131415161718192021222324252627282930313233
  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
  20. command: /usr/local/bin/master-restart etcd
  21. - name: Verify cluster is healthy
  22. command: "{{ etcdctlv2 }} cluster-health"
  23. register: etcdctl
  24. until: etcdctl.rc == 0
  25. retries: 3
  26. delay: 10