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
1.7 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_kubeadm_enabled
  7. - name: Check if etcdctl exist
  8. stat:
  9. path: "{{ bin_dir }}/etcdctl"
  10. register: stat_etcdctl
  11. - block:
  12. - name: Check version
  13. command: "{{ bin_dir }}/etcdctl version"
  14. register: etcdctl_version
  15. check_mode: no
  16. changed_when: false
  17. - name: Remove old binary if version is not OK
  18. file:
  19. path: "{{ bin_dir }}/etcdctl"
  20. state: absent
  21. when: etcd_version.lstrip('v') not in etcdctl_version.stdout
  22. when: stat_etcdctl.stat.exists
  23. - name: Check if etcdctl still exist after version check
  24. stat:
  25. path: "{{ bin_dir }}/etcdctl"
  26. register: stat_etcdctl
  27. - block:
  28. - name: Copy etcdctl script to host
  29. 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 }}"
  30. when: container_manager == "docker"
  31. - name: Copy etcdctl script to host
  32. 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 }}"
  33. when: container_manager in ['crio', 'containerd']
  34. - name: Copy etcdctl to {{ bin_dir }}
  35. copy:
  36. src: "{{ etcd_data_dir }}/etcdctl"
  37. dest: "{{ bin_dir }}"
  38. remote_src: true
  39. mode: 0755
  40. when: not stat_etcdctl.stat.exists
  41. - name: Remove binary in etcd data dir
  42. file:
  43. path: "{{ etcd_data_dir }}/etcdctl"
  44. state: absent
  45. - name: Create etcdctl wrapper script
  46. template:
  47. src: etcdctl.sh.j2
  48. dest: "{{ bin_dir }}/etcdctl.sh"
  49. mode: 0755