Samuel Liu
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 99 deletions
Split View
Diff Options
-
5roles/etcd/tasks/install_docker.yml
-
11roles/etcd/tasks/install_etcdctl_docker.yml
-
12roles/etcd/tasks/install_host.yml
-
11roles/etcd/tasks/main.yml
-
70roles/etcdctl/tasks/main.yml
-
45roles/etcdctl_etcdutl/tasks/main.yml
-
6roles/etcdctl_etcdutl/templates/etcdctl.sh.j2
-
7roles/kubernetes/control-plane/tasks/kubeadm-etcd.yml
@ -1,11 +0,0 @@ |
|||
--- |
|||
- name: Install | Copy etcdctl binary from docker container |
|||
command: sh -c "{{ docker_bin_dir }}/docker rm -f etcdctl-binarycopy; |
|||
{{ docker_bin_dir }}/docker create --name etcdctl-binarycopy {{ etcd_image_repo }}:{{ etcd_image_tag }} && |
|||
{{ docker_bin_dir }}/docker cp etcdctl-binarycopy:/usr/local/bin/etcdctl {{ bin_dir }}/etcdctl && |
|||
{{ docker_bin_dir }}/docker rm -f etcdctl-binarycopy" |
|||
register: etcdctl_install_result |
|||
until: etcdctl_install_result.rc == 0 |
|||
retries: "{{ etcd_retries }}" |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
changed_when: false |
@ -1,70 +0,0 @@ |
|||
--- |
|||
# To get the binary from container to host, use the etcd data directory mounted |
|||
# rw from host into the container. |
|||
|
|||
- name: Check unintentional include of this role |
|||
assert: |
|||
that: etcd_deployment_type == "kubeadm" |
|||
|
|||
- name: Check if etcdctl exist |
|||
stat: |
|||
path: "{{ bin_dir }}/etcdctl" |
|||
get_attributes: no |
|||
get_checksum: no |
|||
get_mime: no |
|||
register: stat_etcdctl |
|||
|
|||
- name: Remove old etcd binary |
|||
when: stat_etcdctl.stat.exists |
|||
block: |
|||
- name: Check version |
|||
command: "{{ bin_dir }}/etcdctl version" |
|||
register: etcdctl_version |
|||
check_mode: no |
|||
changed_when: false |
|||
|
|||
- name: Remove old binary if version is not OK |
|||
file: |
|||
path: "{{ bin_dir }}/etcdctl" |
|||
state: absent |
|||
when: etcd_version.lstrip('v') not in etcdctl_version.stdout |
|||
|
|||
- name: Check if etcdctl still exist after version check |
|||
stat: |
|||
path: "{{ bin_dir }}/etcdctl" |
|||
get_attributes: no |
|||
get_checksum: no |
|||
get_mime: no |
|||
register: stat_etcdctl |
|||
|
|||
- name: Copy etcdctl script to host |
|||
when: not stat_etcdctl.stat.exists |
|||
block: |
|||
- name: Copy etcdctl script to host |
|||
shell: "{{ docker_bin_dir }}/docker cp \"$({{ docker_bin_dir }}/docker ps -qf ancestor={{ etcd_image_repo }}:{{ etcd_image_tag }})\":/usr/local/bin/etcdctl {{ etcd_data_dir }}/etcdctl" |
|||
when: container_manager == "docker" |
|||
|
|||
- name: Copy etcdctl script to host |
|||
shell: >- |
|||
etcd_ctr_id="$({{ bin_dir }}/crictl ps -q --image {{ etcd_image_repo }}:{{ etcd_image_tag }})" && |
|||
etcd_ctr_pid="$({{ bin_dir }}/crictl inspect --output go-template --template '{{ '{{' }} .info.pid {{ '}}' }}' ${etcd_ctr_id})" && |
|||
cp /proc/${etcd_ctr_pid}/root/usr/local/bin/etcdctl {{ etcd_data_dir }}/etcdctl |
|||
when: container_manager in ['crio', 'containerd'] |
|||
|
|||
- name: Copy etcdctl to {{ bin_dir }} |
|||
copy: |
|||
src: "{{ etcd_data_dir }}/etcdctl" |
|||
dest: "{{ bin_dir }}" |
|||
remote_src: true |
|||
mode: 0755 |
|||
|
|||
- name: Remove binary in etcd data dir |
|||
file: |
|||
path: "{{ etcd_data_dir }}/etcdctl" |
|||
state: absent |
|||
|
|||
- name: Create etcdctl wrapper script |
|||
template: |
|||
src: etcdctl.sh.j2 |
|||
dest: "{{ bin_dir }}/etcdctl.sh" |
|||
mode: 0755 |
@ -0,0 +1,45 @@ |
|||
--- |
|||
- name: Copy etcdctl and etcdutl binary from docker container |
|||
command: sh -c "{{ docker_bin_dir }}/docker rm -f etcdxtl-binarycopy; |
|||
{{ docker_bin_dir }}/docker create --name etcdxtl-binarycopy {{ etcd_image_repo }}:{{ etcd_image_tag }} && |
|||
{{ docker_bin_dir }}/docker cp etcdxtl-binarycopy:/usr/local/bin/{{ item }} {{ bin_dir }}/{{ item }} && |
|||
{{ docker_bin_dir }}/docker rm -f etcdxtl-binarycopy" |
|||
with_items: |
|||
- etcdctl |
|||
- etcdutl |
|||
register: etcdxtl_install_result |
|||
until: etcdxtl_install_result.rc == 0 |
|||
retries: "{{ etcd_retries }}" |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
changed_when: false |
|||
when: container_manager == "docker" |
|||
|
|||
- name: Download etcd binary |
|||
include_tasks: "../../download/tasks/download_file.yml" |
|||
vars: |
|||
download: "{{ download_defaults | combine(downloads.etcd) }}" |
|||
when: container_manager in ['crio', 'containerd'] |
|||
|
|||
- name: Copy etcd binary |
|||
unarchive: |
|||
src: "{{ downloads.etcd.dest }}" |
|||
dest: "{{ local_release_dir }}/" |
|||
remote_src: yes |
|||
when: container_manager in ['crio', 'containerd'] |
|||
|
|||
- name: Copy etcdctl and etcdutl binary from download dir |
|||
copy: |
|||
src: "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-{{ host_architecture }}/{{ item }}" |
|||
dest: "{{ bin_dir }}/{{ item }}" |
|||
mode: 0755 |
|||
remote_src: yes |
|||
with_items: |
|||
- etcdctl |
|||
- etcdutl |
|||
when: container_manager in ['crio', 'containerd'] |
|||
|
|||
- name: Create etcdctl wrapper script |
|||
template: |
|||
src: etcdctl.sh.j2 |
|||
dest: "{{ bin_dir }}/etcdctl.sh" |
|||
mode: 0755 |
Write
Preview
Loading…
Cancel
Save