You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.1 KiB

  1. - name: "Pre-upgrade | check for etcd-proxy unit file"
  2. stat:
  3. path: /etc/systemd/system/etcd-proxy.service
  4. register: etcd_proxy_service_file
  5. tags: facts
  6. - name: "Pre-upgrade | check for etcd-proxy init script"
  7. stat:
  8. path: /etc/init.d/etcd-proxy
  9. register: etcd_proxy_init_script
  10. tags: facts
  11. - name: "Pre-upgrade | stop etcd-proxy if service defined"
  12. service:
  13. name: etcd-proxy
  14. state: stopped
  15. when: (etcd_proxy_service_file.stat.exists|default(False) or etcd_proxy_init_script.stat.exists|default(False))
  16. - name: "Pre-upgrade | remove etcd-proxy service definition"
  17. file:
  18. path: "{{ item }}"
  19. state: absent
  20. when: (etcd_proxy_service_file.stat.exists|default(False) or etcd_proxy_init_script.stat.exists|default(False))
  21. with_items:
  22. - /etc/systemd/system/etcd-proxy.service
  23. - /etc/init.d/etcd-proxy
  24. - name: "Pre-upgrade | find etcd-proxy container"
  25. command: "{{ docker_bin_dir }}/docker ps -aq --filter 'name=etcd-proxy*'"
  26. register: etcd_proxy_container
  27. changed_when: false
  28. failed_when: false
  29. - name: "Pre-upgrade | remove etcd-proxy if it exists"
  30. command: "{{ docker_bin_dir }}/docker rm -f {{item}}"
  31. with_items: "{{etcd_proxy_container.stdout_lines}}"
  32. - name: "Pre-upgrade | see if etcdctl is installed"
  33. stat:
  34. path: "{{ bin_dir }}/etcdctl"
  35. register: etcdctl_installed
  36. - name: "Pre-upgrade | check if member list is non-SSL"
  37. command: "{{ bin_dir }}/etcdctl --no-sync --peers={{ etcd_access_addresses | regex_replace('https','http') }} member list"
  38. register: etcd_member_list
  39. retries: 10
  40. delay: 3
  41. until: etcd_member_list.rc != 2
  42. run_once: true
  43. when: etcdctl_installed.stat.exists
  44. changed_when: false
  45. failed_when: false
  46. - name: "Pre-upgrade | change peer names to SSL"
  47. shell: >-
  48. {{ bin_dir }}/etcdctl --no-sync --peers={{ etcd_access_addresses | regex_replace('https','http') }} member list |
  49. awk -F"[: =]" '{print "{{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses | regex_replace('https','http') }} member update "$1" https:"$7":"$8}' | bash
  50. run_once: true
  51. when: 'etcdctl_installed.stat.exists and etcd_member_list.rc == 0 and "http://" in etcd_member_list.stdout'