Playbook
The ETCD module provides two core playbooks. Use etcd.yml to install and configure etcd clusters. Use etcd-rm.yml to remove clusters or members.
Since Pigsty v3.6, the etcd.yml playbook focuses on cluster installation and member addition. The dedicated etcd-rm.yml playbook handles all removals through the etcd_remove role.
etcd.yml
Playbook source: etcd.yml
This playbook installs and configures an etcd cluster on the hardcoded etcd group. Then it starts the etcd service.
The following subtasks are available in etcd.yml:
etcd_assert: Validate etcd identity parameters (etcd_seqmust be defined as a non-negative integer)etcd_install: Install etcd packagesetcd_dir: Create etcd data and configuration directoriesetcd_config: Generate etcd configurationetcd_conf: Generate etcd main config file/etc/etcd/etcd.confetcd_cert: Generate etcd TLS certificates (CA, server cert, private key)
etcd_member: Add new member to existing cluster (only runs whenetcd_init=existing)etcd_launch: Launch etcd serviceetcd_auth: Enable RBAC authentication (create root user and enable auth)etcd_register: Register etcd to VictoriaMetrics monitoring
etcd-rm.yml
Playbook source: etcd-rm.yml
A dedicated playbook for removing etcd clusters or individual members. The following subtasks are available in etcd-rm.yml:
etcd_safeguard: Check safeguard and abort if enabledetcd_pause: Pause for 3 seconds, allowing user to abort with Ctrl-Cetcd_deregister: Remove etcd registration from VictoriaMetrics monitoring targetsetcd_leave: Try graceful leaving etcd cluster before purgeetcd_svc: Stop and disable etcd service with systemdetcd_data: Remove etcd data (disable withetcd_rm_data=false)etcd_pkg: Uninstall etcd packages (enable withetcd_rm_pkg=true)
The removal playbook uses the etcd_remove role with the following configurable parameters:
etcd_safeguard: Prevents accidental removal when set totrueetcd_rm_data: Controls whether ETCD data is deleted (default:true)etcd_rm_pkg: Controls whether ETCD packages are uninstalled (default:false)
etcd_safeguard defaults to false, while etcd_rm_data defaults to true. A full etcd-rm.yml run first attempts to remove the target from the cluster. It deregisters the target and stops its service. It then deletes local etcd data, configuration, unit files, and the client environment file.
The playbook ignores some leave and cleanup errors and does not prove that the remaining members retain quorum. Always use an exact -l target. Verify a recent backup, the member list, and remaining quorum.
Demo
Cheatsheet
Etcd Installation & Configuration:
Etcd Removal & Cleanup:
Convenience Scripts:
Safeguard
The ETCD module provides a safeguard against accidental deletion. Control it with etcd_safeguard. The default is false, which disables the safeguard.
After you initialize a production etcd cluster, we recommend that you enable the safeguard. This helps prevent accidental deletion of existing instances:
If etcd_safeguard is true, etcd-rm.yml aborts before any deregistration, cluster-leave, service-stop, or deletion action. This boolean guard does not check whether the instance is running. Override it with a command-line parameter:
After a real run, inspect etcdctl member list, endpoint health, and remaining quorum, regardless of the safeguard value. A successful task status does not verify the runtime state.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)