kubeasz/roles/cluster-restore/tasks/main.yml

31 lines
906 B
YAML
Raw Normal View History

2018-07-23 16:59:44 +08:00
- name: 停止ectd 服务
service: name=etcd state=stopped
- name: 清除etcd 数据目录
file: name={{ ETCD_DATA_DIR }}/member state=absent
2018-07-23 16:59:44 +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 数据恢复
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: 以轮询的方式等待服务同步完成
shell: "systemctl is-active etcd.service"
2021-01-07 09:30:50 +08:00
register: etcd_status
until: '"active" in etcd_status.stdout'
2021-01-07 09:30:50 +08:00
retries: 8
delay: 8