Parameters
The ETCD module has 13 parameters, divided into two sections:
ETCD: 10 parameters for etcd cluster deployment and configurationETCD_REMOVE: 3 parameters for controlling etcd cluster removal
Since Pigsty v3.6, etcd.yml does not handle removal. Removal parameters belong to the separate etcd_remove role. Since v4.0, Pigsty enables RBAC authentication by default and provides the etcd_root_password parameter.
Parameter Overview
Use the ETCD parameter group to deploy and configure etcd clusters. It controls instance identification, cluster name, data directory, ports, and authentication password.
| Parameter | Type | Level | Description |
|---|---|---|---|
etcd_seq | int | I | etcd instance identifier, REQUIRED |
etcd_cluster | string | C | etcd cluster name, fixed to etcd by default |
etcd_learner | bool | I/A | initialize etcd instance as learner? |
etcd_data | path | C | etcd data directory, /data/etcd by default |
etcd_port | port | C | etcd client port, 2379 by default |
etcd_peer_port | port | C | etcd peer port, 2380 by default |
etcd_init | enum | C | etcd initial cluster state, new or existing |
etcd_election_timeout | int | C | etcd election timeout, 1000ms by default |
etcd_heartbeat_interval | int | C | etcd heartbeat interval, 100ms by default |
etcd_root_password | password | G | etcd root user password for RBAC authentication |
The ETCD_REMOVE parameter group controls etcd cluster removal behavior, including safeguard protection, data cleanup, and package uninstallation.
| Parameter | Type | Level | Description |
|---|---|---|---|
etcd_safeguard | bool | G/C/A | unconditionally refuse removal when true |
etcd_rm_data | bool | G/C/A | remove etcd data during removal? default is true |
etcd_rm_pkg | bool | G/C/A | uninstall etcd packages during removal? default is false |
ETCD
This section contains parameters for the etcd role,
which are used by the etcd.yml playbook.
Parameters are defined in roles/etcd/defaults/main.yml
etcd_seq
Parameter: etcd_seq, Type: int, Level: I
etcd instance identifier. This parameter is required. You must assign a unique identifier to each etcd instance.
Here is an example of a 3-node etcd cluster with identifiers 1 through 3:
etcd_cluster
Parameter: etcd_cluster, Type: string, Level: C
etcd cluster & group name, default value is the hard-coded etcd.
You can modify this parameter when you want to deploy an additional etcd cluster for backup purposes.
etcd_learner
Parameter: etcd_learner, Type: bool, Level: I/A
Specifies whether to initialize the etcd instance as a learner. The default is false.
If this parameter is true, Pigsty initializes the instance as a learner. A learner cannot vote in etcd cluster elections.
Use Cases:
- Cluster Expansion: Add members as learners to preserve the current quorum requirements until data synchronization completes.
- Safe Migration: During a rolling upgrade or migration, add the member as a learner. Confirm data synchronization before you promote it.
Workflow:
- Set
etcd_learner: trueto initialize the new member as a learner - Wait for data synchronization to complete (check with
etcdctl endpoint status) - Use
etcdctl member promote <member_id>to promote it to a full member
Learners do not count toward cluster quorum. A 3-node cluster with 1 learner has 2 voting members. It cannot tolerate a voting member failure.
etcd_data
Parameter: etcd_data, Type: path, Level: C
etcd data directory, default is /data/etcd.
etcd_port
Parameter: etcd_port, Type: port, Level: C
etcd client port, default is 2379.
etcd_peer_port
Parameter: etcd_peer_port, Type: port, Level: C
etcd peer port, default is 2380.
etcd_init
Parameter: etcd_init, Type: enum, Level: C
Initial etcd cluster state. Set it to new or existing. The default is new.
Option Values:
| Value | Description | Use Case |
|---|---|---|
new | Create a new etcd cluster | Initial deployment, cluster rebuild |
existing | Join an existing etcd cluster | Cluster expansion, adding new members |
Important Notes:
When adding new members to an existing etcd cluster, you must set etcd_init=existing. Otherwise, the new instance attempts to create a separate cluster. This causes split-brain or initialization failure.
Usage Examples:
etcd_election_timeout
Parameter: etcd_election_timeout, Type: int, Level: C
etcd election timeout, default is 1000 (milliseconds), i.e., 1 second.
etcd_heartbeat_interval
Parameter: etcd_heartbeat_interval, Type: int, Level: C
etcd heartbeat interval, default is 100 (milliseconds).
etcd_root_password
Parameter: etcd_root_password, Type: password, Level: G
etcd root user password for RBAC authentication, default value is Etcd.Root.
Since v4.0, Pigsty has enabled etcd RBAC (Role-Based Access Control) authentication by default. During cluster initialization, the etcd_auth task automatically creates the root user and enables authentication.
Password Storage Location:
- Password is stored in
/etc/etcd/etcd.passfile - File permissions are
0640(owned by root, readable by etcd group) - The etcdctl environment script
/etc/profile.d/etcdctl.shautomatically reads this file
Integration with Other Components:
- Patroni uses the
pg_etcd_passwordparameter to configure the password for connecting to etcd - If
pg_etcd_passwordis empty, Patroni will use the cluster name as password (not recommended) - VIP-Manager also requires the same authentication credentials to connect to etcd
Security Recommendations:
In production environments, it is strongly recommended to change the default password Etcd.Root. Set it in global or cluster configuration:
Run configure -g to generate and replace etcd_root_password automatically.
ETCD_REMOVE
This section contains parameters for the etcd_remove role,
which are action flags used by the etcd-rm.yml playbook.
Parameters are defined in roles/etcd_remove/defaults/main.yml
etcd_safeguard
Parameter: etcd_safeguard, Type: bool, Level: G/C/A
Removal safeguard. The default is false. If set to true, etcd-rm.yml aborts before deregistration, cluster departure, service shutdown, or data deletion. This static boolean switch does not check whether the instance is running.
Override it explicitly with -e etcd_safeguard=false.
Recommended Settings:
| Environment | Recommended | Description |
|---|---|---|
| Dev/Test | false | Convenient for rapid rebuilding and testing |
| Production | true | Prevents service interruption from accidental operations |
In emergencies, you can override the configuration with command-line parameters:
etcd_rm_data
Parameter: etcd_rm_data, Type: bool, Level: G/C/A
Specifies whether to delete etcd data and configuration files during removal. The default is true.
If enabled, etcd-rm.yml deletes these files and directories when it removes a cluster or member:
/etc/etcd/- Configuration directory (including certificates and password files)/var/lib/etcd/- Alternate data directory{{ etcd_data }}- Primary data directory (default/data/etcd)/etc/systemd/system/etcd.service- Systemd service unit file/etc/profile.d/etcdctl.sh- Client environment script/etc/vector/etcd.yaml- Vector log collection config
Use Cases:
| Scenario | Recommended | Description |
|---|---|---|
| Complete removal | true (default) | Full cleanup, free disk space |
| Stop service only | false | Preserve data for troubleshooting or recovery |
etcd_rm_pkg
Parameter: etcd_rm_pkg, Type: bool, Level: G/C/A
Specifies whether to uninstall etcd packages during removal. The default is false.
If enabled, etcd-rm.yml uninstalls etcd packages when it removes a cluster or member.
Use Cases:
| Scenario | Recommended | Description |
|---|---|---|
| Normal removal | false (default) | Keep packages for quick redeployment |
| Complete cleanup | true | Full uninstall, save disk space |
Usually, you do not need to uninstall etcd packages. If you keep them, subsequent redeployments are faster because no download or installation is necessary.