---
- name: Determine if generated etcd certificates exist
  stat:
    path: "{{ etcd_conf_dir }}/generated_certs"
    get_checksum: false
    get_attributes: false
    get_mime: false
  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
