---
- name: Determine if generated etcd certificates exist
  stat:
    path: "{{ etcd_conf_dir }}/generated_certs"
  register: etcd_generated_certs_dir_stat

- name: Backup generated etcd certificates
  command: >
    tar -czf {{ etcd_conf_dir }}/etcd-generated-certificate-backup-{{ ansible_date_time.epoch }}.tgz
    {{ etcd_conf_dir }}/generated_certs
  args:
    warn: no
  when: etcd_generated_certs_dir_stat.stat.exists | bool
