2018-07-23 16:59:44 +08:00
|
|
|
- name: 停止ectd 服务
|
|
|
|
service: name=etcd state=stopped
|
|
|
|
|
|
|
|
- name: 清除etcd 数据目录
|
2021-06-23 14:26:25 +08:00
|
|
|
file: name={{ ETCD_DATA_DIR }}/member state=absent
|
2018-07-23 16:59:44 +08:00
|
|
|
|
2022-11-24 18:49:31 +08:00
|
|
|
- name: 清除 etcd 备份目录
|
|
|
|
file: name={{ cluster_dir }}/backup/etcd-restore state=absent
|
|
|
|
delegate_to: 127.0.0.1
|
|
|
|
run_once: true
|
2018-07-23 16:59:44 +08:00
|
|
|
|
|
|
|
- name: etcd 数据恢复
|
2022-11-24 18:49:31 +08:00
|
|
|
shell: "cd {{ cluster_dir }}/backup && \
|
|
|
|
ETCDCTL_API=3 {{ base_dir }}/bin/etcdctl snapshot restore snapshot.db \
|
|
|
|
--data-dir={{ cluster_dir }}/backup/etcd-restore"
|
|
|
|
delegate_to: 127.0.0.1
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: 分发恢复文件到 etcd 各个节点
|
|
|
|
copy: src={{ cluster_dir }}/backup/etcd-restore/member dest={{ ETCD_DATA_DIR }}
|
2018-07-23 16:59:44 +08:00
|
|
|
|
|
|
|
- name: 重启etcd 服务
|
|
|
|
service: name=etcd state=restarted
|
2021-01-07 09:30:50 +08:00
|
|
|
|
|
|
|
- name: 以轮询的方式等待服务同步完成
|
2021-05-28 10:11:35 +08:00
|
|
|
shell: "systemctl is-active etcd.service"
|
2021-01-07 09:30:50 +08:00
|
|
|
register: etcd_status
|
2021-05-28 10:11:35 +08:00
|
|
|
until: '"active" in etcd_status.stdout'
|
2021-01-07 09:30:50 +08:00
|
|
|
retries: 8
|
|
|
|
delay: 8
|