---

- name: Create the archive dir
  file: path={{ vault_root_dir }}/archives/{{ vault_current_version }} state=directory
  tags: vault

#- name: Take a snapshot of the data
#  command: vault operator raft snapshot save {{ vault_root_dir }}/archives/{{ vault_current_version }}/vault.snap
#  when:
#    - vault_bkp_token is defined
#    - vault_sys_services.ansible_facts.services['nomad.service'] is defined
#    - vault_sys_services.ansible_facts.services['nomad.service'].state == 'started'
#    - vault_status.initialized is defined and vault_status.initialized
#    - vault_status.sealed is defined and not vault_status.sealed
#    - vault_status.leader_address == vault_conf.api_addr
#  tags: vault

- name: Backup previous version
  copy: src={{ vault_root_dir }}/bin/vault dest={{ vault_root_dir }}/archives/{{ vault_current_version }}/ remote_src=True
  tags: vault

