代码拉取完成,页面将自动刷新
同步操作将从 烂泥行天下/kubeasz 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# cluster-backup playbook
# read the guide: 'op/cluster_restore.md'
- hosts:
- localhost
tasks:
# step1: find a healthy member in the etcd cluster
- name: set NODE_IPS of the etcd cluster
set_fact: NODE_IPS="{% for host in groups['etcd'] %}{{ host }} {% endfor %}"
- name: get etcd cluster status
shell: 'for ip in {{ NODE_IPS }};do \
ETCDCTL_API=3 {{ base_dir }}/bin/etcdctl \
--endpoints=https://"$ip":2379 \
--cacert={{ base_dir }}/.cluster/ssl/ca.pem \
--cert={{ base_dir }}/.cluster/ssl/admin.pem \
--key={{ base_dir }}/.cluster/ssl/admin-key.pem \
endpoint health; \
done'
register: ETCD_CLUSTER_STATUS
ignore_errors: true
- debug: var="ETCD_CLUSTER_STATUS.stdout"
- name: get a running ectd node
shell: 'echo -e "{{ ETCD_CLUSTER_STATUS.stdout }}"|grep "is healthy"|sed -n "1p"|cut -d: -f2|cut -d/ -f3'
register: RUNNING_NODE
- debug: var="RUNNING_NODE.stdout"
# step2: backup data on the healthy member
- name: make a backup on etcd node
shell: "mkdir -p /etcd_backup && cd /etcd_backup && \
ETCDCTL_API=3 {{ bin_dir }}/etcdctl snapshot save snapshot.db"
args:
warn: false
delegate_to: "{{ RUNNING_NODE.stdout }}"
- name: fetch the backup data
fetch:
src: /etcd_backup/snapshot.db
dest: "{{ base_dir }}/.cluster/backup/"
flat: yes
delegate_to: "{{ RUNNING_NODE.stdout }}"
- hosts:
- localhost
tasks:
- name: Backing up ansible hosts-1
copy:
src: "{{ base_dir }}/hosts"
dest: "{{ base_dir }}/.cluster/backup/hosts"
register: p
- name: Backing up ansible hosts-2
shell: "cd {{ base_dir }}/.cluster/backup && \
cp -fp hosts hosts-$(date +'%Y%m%d%H%M')"
when: 'p is changed'
- name: Backing up etcd snapshot with datetime
shell: "cd {{ base_dir }}/.cluster/backup && \
cp -fp snapshot.db snapshot-$(date +'%Y%m%d%H%M').db"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。