Skip to content

Instantly share code, notes, and snippets.

@moshiurH
Created February 6, 2026 22:51
Show Gist options
  • Select an option

  • Save moshiurH/0664dde05a05f41d042d06f5893ca7d6 to your computer and use it in GitHub Desktop.

Select an option

Save moshiurH/0664dde05a05f41d042d06f5893ca7d6 to your computer and use it in GitHub Desktop.
Install etcdctl on linux platforms
---
- name: Install etcdctl from official etcd release
hosts: managers
become: true
gather_facts: true
vars:
etcd_ver: "v3.5.12"
install_dir: "/usr/bin"
tmp_dir: "/tmp/etcdctl-install"
# You can set arch per-host if needed; these cover most cases
etcd_arch_map:
x86_64: "amd64"
aarch64: "arm64"
etcd_arch: "{{ etcd_arch_map.get(ansible_architecture, 'amd64') }}"
etcd_platform: "linux-{{ etcd_arch }}"
tarball: "etcd-{{ etcd_ver }}-{{ etcd_platform }}.tar.gz"
base_url: "https://github.com/etcd-io/etcd/releases/download/{{ etcd_ver }}"
tar_url: "{{ base_url }}/{{ tarball }}"
sums_url: "{{ base_url }}/SHA256SUMS"
tasks:
- name: Create temp dir
ansible.builtin.file:
path: "{{ tmp_dir }}"
state: directory
mode: "0755"
- name: Download SHA256SUMS
ansible.builtin.get_url:
url: "{{ sums_url }}"
dest: "{{ tmp_dir }}/SHA256SUMS"
mode: "0644"
- name: Extract checksum for our tarball
ansible.builtin.shell: |
set -euo pipefail
awk '$2 == "{{ tarball }}" {print $1}' "{{ tmp_dir }}/SHA256SUMS"
args:
executable: /bin/bash
register: etcd_tar_sha
changed_when: false
- name: Fail if checksum not found (wrong version/platform?)
ansible.builtin.fail:
msg: "No checksum found for {{ tarball }} in SHA256SUMS"
when: etcd_tar_sha.stdout | trim == ""
- name: Download etcd release tarball (with checksum verification)
ansible.builtin.get_url:
url: "{{ tar_url }}"
dest: "{{ tmp_dir }}/{{ tarball }}"
checksum: "sha256:{{ etcd_tar_sha.stdout | trim }}"
mode: "0644"
- name: Unpack tarball
ansible.builtin.unarchive:
src: "{{ tmp_dir }}/{{ tarball }}"
dest: "{{ tmp_dir }}"
remote_src: true
# idempotence guard (folder name inside tarball)
args:
creates: "{{ tmp_dir }}/etcd-{{ etcd_ver }}-{{ etcd_platform }}/etcdctl"
- name: Install etcdctl binary
ansible.builtin.copy:
src: "{{ tmp_dir }}/etcd-{{ etcd_ver }}-{{ etcd_platform }}/etcdctl"
dest: "{{ install_dir }}/etcdctl"
remote_src: true
mode: "0755"
owner: root
group: root
- name: Verify etcdctl
ansible.builtin.command: "{{ install_dir }}/etcdctl version"
register: etcdctl_ver_out
changed_when: false
- name: Show version
ansible.builtin.debug:
msg: "{{ etcdctl_ver_out.stdout_lines }}"
@moshiurH
Copy link
Author

moshiurH commented Feb 6, 2026

To install:

ansible-playbook -i inventory install-etcdctl.yml --limit managers -b

To confirm:

ansible managers -i inventory -b -m command -a "etcdctl version"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment