You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

  1. ---
  2. - name: Backup etcd data
  3. command: /bin/true
  4. notify:
  5. - Refresh Time Fact
  6. - Set etcd Backup Directory Prefix
  7. - Set Backup Directory
  8. - Create Backup Directory
  9. - Backup etcd v2 data
  10. - Backup etcd v3 data
  11. when: etcd_cluster_is_healthy.rc == 0
  12. - name: Refresh Time Fact
  13. setup: filter=ansible_date_time
  14. - name: Set etcd Backup Directory Prefix
  15. set_fact:
  16. etcd_backup_prefix: '/var/backups'
  17. - name: Set Backup Directory
  18. set_fact:
  19. etcd_backup_directory: "{{ etcd_backup_prefix }}/etcd-{{ ansible_date_time.date }}_{{ ansible_date_time.time }}"
  20. - name: Create Backup Directory
  21. file:
  22. path: "{{ etcd_backup_directory }}"
  23. state: directory
  24. owner: root
  25. group: root
  26. mode: 0600
  27. - name: Backup etcd v2 data
  28. command: >-
  29. {{ bin_dir }}/etcdctl backup
  30. --data-dir {{ etcd_data_dir }}
  31. --backup-dir {{ etcd_backup_directory }}
  32. environment:
  33. ETCDCTL_API: 2
  34. retries: 3
  35. delay: "{{ retry_stagger | random + 3 }}"
  36. - name: Backup etcd v3 data
  37. command: >-
  38. {{ bin_dir }}/etcdctl
  39. --endpoints={{ etcd_access_addresses }}
  40. snapshot save {{ etcd_backup_directory }}/snapshot.db
  41. environment:
  42. ETCDCTL_API: 3
  43. retries: 3
  44. delay: "{{ retry_stagger | random + 3 }}"