Playbook

How to manage etcd cluster with ansible playbooks

There’s a built-in playbook: etcd.yml for installing etcd cluster. But you have to define it first.


Playbook

To create a new etcd cluster, run the following playbook:

./etcd.yml    # install etcd cluster on group 'etcd'

Here are available sub tasks:

  • etcd_assert : generate etcd identity
  • etcd_install : install etcd rpm packages
  • etcd_clean : cleanup existing etcd
    • etcd_check : check etcd instance is running
    • etcd_purge : remove running etcd instance & data
  • etcd_dir : create etcd data & conf dir
  • etcd_config : generate etcd config
    • etcd_conf : generate etcd main config
    • etcd_cert : generate etcd ssl cert
  • etcd_launch : launch etcd service
  • etcd_register : register etcd to prometheus

asciicast

There’s no dedicated uninstall playbook for etcd. If you want to uninstall etcd, you can use etcd_clean subtask:

./etcd.yml -t etcd_clean

Commands

Some shortcuts and common commands:

./etcd.yml                                      # init etcd cluster 
./etcd.yml -t etcd_launch                       # restart etcd cluster
./etcd.yml -t etcd_clean                        # remove etcd cluster
./etcd.yml -t etcd_purge                        # remove etcd cluster with brute force
./etcd.yml -t etcd_conf                         # refreshing /etc/etcd/etcd.conf
./etcd.yml -l 10.10.10.12 -e etcd_init=existing # add new member to existing etcd cluster
./etcd.yml -l 10.10.10.12 -t etcd_purge         # remove member from existing etcd cluster

Safeguard

Pigsty has safeguard mechanism for etcd module to prevent accidental purge.

  • etcd_clean: true by default, which will clean existing etcd instances during init
  • etcd_safeguard: false by default, will not prevent purge etcd cluster.

The default setting is useful for development, testing, and emergency rebuild of etcd cluster in production.

If you wish to prevent accidental purge, you can enable safeguard by setting etcd_clean to false and etcd_safeguard to true. And you can always override this setting by using -e etcd_clean=true and -e etcd_safeguard=false in command line.

If you wish to remove existing cluster:

./etcd.yml -l <cls> -e etcd_clean=true -t etcd_clean

The final brutal way to remove etcd cluster is using the etcd_purge subtask, which will ignore the safeguard:

./etcd.yml -l <cls> -t etcd_purge

Demo

asciicast





Last modified 2024-11-22: update minio/etcd docs (345b8442)