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.

65 lines
1.9 KiB

  1. ---
  2. # To get the binary from container to host, use the etcd data directory mounted
  3. # rw from host into the container.
  4. - name: Check unintentional include of this role
  5. assert:
  6. that: etcd_deployment_type == "kubeadm"
  7. - name: Check if etcdctl exist
  8. stat:
  9. path: "{{ bin_dir }}/etcdctl"
  10. get_attributes: no
  11. get_checksum: no
  12. get_mime: no
  13. register: stat_etcdctl
  14. - block:
  15. - name: Check version
  16. command: "{{ bin_dir }}/etcdctl version"
  17. register: etcdctl_version
  18. check_mode: no
  19. changed_when: false
  20. - name: Remove old binary if version is not OK
  21. file:
  22. path: "{{ bin_dir }}/etcdctl"
  23. state: absent
  24. when: etcd_version.lstrip('v') not in etcdctl_version.stdout
  25. when: stat_etcdctl.stat.exists
  26. - name: Check if etcdctl still exist after version check
  27. stat:
  28. path: "{{ bin_dir }}/etcdctl"
  29. get_attributes: no
  30. get_checksum: no
  31. get_mime: no
  32. register: stat_etcdctl
  33. - block:
  34. - name: Copy etcdctl script to host
  35. shell: "{{ docker_bin_dir }}/docker exec \"$({{ docker_bin_dir }}/docker ps -qf ancestor={{ etcd_image_repo }}:{{ etcd_image_tag }})\" cp /usr/local/bin/etcdctl {{ etcd_data_dir }}/etcdctl"
  36. when: container_manager == "docker"
  37. - name: Copy etcdctl script to host
  38. shell: "{{ bin_dir }}/crictl exec \"$({{ bin_dir }}/crictl ps -q --image {{ etcd_image_repo }}:{{ etcd_image_tag }})\" cp /usr/local/bin/etcdctl {{ etcd_data_dir }}/etcdctl"
  39. when: container_manager in ['crio', 'containerd']
  40. - name: Copy etcdctl to {{ bin_dir }}
  41. copy:
  42. src: "{{ etcd_data_dir }}/etcdctl"
  43. dest: "{{ bin_dir }}"
  44. remote_src: true
  45. mode: 0755
  46. when: not stat_etcdctl.stat.exists
  47. - name: Remove binary in etcd data dir
  48. file:
  49. path: "{{ etcd_data_dir }}/etcdctl"
  50. state: absent
  51. - name: Create etcdctl wrapper script
  52. template:
  53. src: etcdctl.sh.j2
  54. dest: "{{ bin_dir }}/etcdctl.sh"
  55. mode: 0755