forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackup-etcd.yml
42 lines (35 loc) · 1.1 KB
/
backup-etcd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
- hosts: etcd
any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
become: true
tags:
- etcd
roles:
- { role: kubespray-defaults}
vars:
etcd_backup_dir: "./etcd_backup"
vars_files:
- roles/etcd/defaults/main.yml
handlers:
- import_tasks: roles/etcd/handlers/backup.yml
tasks:
- import_tasks: roles/etcd/tasks/set_cluster_health.yml
- name: Backup all etcd data
command: /bin/true
notify:
- Backup etcd data
- meta: flush_handlers
- debug:
var: etcd_backup_directory
- name: Create etcd backup tarball
command: "tar -cvzf /tmp/etcd-backup-{{ inventory_hostname }}.tar.gz -C {{ etcd_backup_directory }} ."
- name: Copy etcd backup tarball to ansible host
fetch:
src: "/tmp/etcd-backup-{{ inventory_hostname }}.tar.gz"
dest: "{{ etcd_backup_dir }}/etcd-backup-{{ inventory_hostname }}.tar.gz"
flat: yes
validate_checksum: no
become: no
- name: Remove etcd backup tarball
file:
path: "/tmp/etcd-backup-{{ inventory_hostname }}.tar.gz"
state: absent