Install etcdutl file by default (#10385)
parent
5ed85094c2
commit
e1881fae02
|
@ -1,9 +1,4 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: Install etcdctl from docker
|
|
||||||
import_tasks: install_etcdctl_docker.yml
|
|
||||||
when: etcd_cluster_setup
|
|
||||||
|
|
||||||
- name: Get currently-deployed etcd version
|
- name: Get currently-deployed etcd version
|
||||||
shell: "{{ docker_bin_dir }}/docker ps --filter='name={{ etcd_member_name }}' --format='{{ '{{ .Image }}' }}'"
|
shell: "{{ docker_bin_dir }}/docker ps --filter='name={{ etcd_member_name }}' --format='{{ '{{ .Image }}' }}'"
|
||||||
register: etcd_current_docker_image
|
register: etcd_current_docker_image
|
||||||
|
|
|
@ -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
|
|
|
@ -20,16 +20,7 @@
|
||||||
- etcd_events_cluster_setup
|
- etcd_events_cluster_setup
|
||||||
- etcd_version.lstrip('v') not in etcd_current_host_version.stdout | default('')
|
- etcd_version.lstrip('v') not in etcd_current_host_version.stdout | default('')
|
||||||
|
|
||||||
- name: Install | Download etcd and etcdctl
|
- name: Install | Copy etcd binary from download dir
|
||||||
include_tasks: "../../download/tasks/download_file.yml"
|
|
||||||
vars:
|
|
||||||
download: "{{ download_defaults | combine(downloads.etcd) }}"
|
|
||||||
when: etcd_cluster_setup
|
|
||||||
tags:
|
|
||||||
- never
|
|
||||||
- etcd
|
|
||||||
|
|
||||||
- name: Install | Copy etcd and etcdctl binary from download dir
|
|
||||||
copy:
|
copy:
|
||||||
src: "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-{{ host_architecture }}/{{ item }}"
|
src: "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-{{ host_architecture }}/{{ item }}"
|
||||||
dest: "{{ bin_dir }}/{{ item }}"
|
dest: "{{ bin_dir }}/{{ item }}"
|
||||||
|
@ -37,5 +28,4 @@
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
with_items:
|
with_items:
|
||||||
- etcd
|
- etcd
|
||||||
- etcdctl
|
|
||||||
when: etcd_cluster_setup
|
when: etcd_cluster_setup
|
||||||
|
|
|
@ -53,6 +53,17 @@
|
||||||
- master
|
- master
|
||||||
- network
|
- network
|
||||||
|
|
||||||
|
- name: Install etcdctl and etcdutl binary
|
||||||
|
import_role:
|
||||||
|
name: etcdctl_etcdutl
|
||||||
|
tags:
|
||||||
|
- etcdctl
|
||||||
|
- etcdutl
|
||||||
|
- upgrade
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups['etcd']
|
||||||
|
- etcd_cluster_setup
|
||||||
|
|
||||||
- name: Install etcd
|
- name: Install etcd
|
||||||
include_tasks: "install_{{ etcd_deployment_type }}.yml"
|
include_tasks: "install_{{ etcd_deployment_type }}.yml"
|
||||||
when: is_etcd_master
|
when: is_etcd_master
|
||||||
|
|
|
@ -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
|
|
@ -3,6 +3,12 @@
|
||||||
# example invocation: etcdctl.sh get --keys-only --from-key ""
|
# example invocation: etcdctl.sh get --keys-only --from-key ""
|
||||||
|
|
||||||
etcdctl \
|
etcdctl \
|
||||||
|
{% if etcd_deployment_type == "kubeadm" %}
|
||||||
--cacert {{ kube_cert_dir }}/etcd/ca.crt \
|
--cacert {{ kube_cert_dir }}/etcd/ca.crt \
|
||||||
--cert {{ kube_cert_dir }}/etcd/server.crt \
|
--cert {{ kube_cert_dir }}/etcd/server.crt \
|
||||||
--key {{ kube_cert_dir }}/etcd/server.key "$@"
|
--key {{ kube_cert_dir }}/etcd/server.key "$@"
|
||||||
|
{% else %}
|
||||||
|
--cacert {{ etcd_cert_dir }}/etcd/ca.crt \
|
||||||
|
--cert {{ etcd_cert_dir }}/etcd/server.crt \
|
||||||
|
--key {{ etcd_cert_dir }}/etcd/server.key "$@"
|
||||||
|
{% endif %}
|
|
@ -12,10 +12,13 @@
|
||||||
tags:
|
tags:
|
||||||
- network
|
- network
|
||||||
|
|
||||||
- name: Ensure etcdctl script is installed
|
- name: Ensure etcdctl and etcdutl script is installed
|
||||||
import_role:
|
import_role:
|
||||||
name: etcdctl
|
name: etcdctl_etcdutl
|
||||||
when: etcd_deployment_type == "kubeadm"
|
when: etcd_deployment_type == "kubeadm"
|
||||||
|
tags:
|
||||||
|
- etcdctl
|
||||||
|
- etcdutl
|
||||||
|
|
||||||
- name: Set ownership for etcd data directory
|
- name: Set ownership for etcd data directory
|
||||||
file:
|
file:
|
||||||
|
|
Loading…
Reference in New Issue