---
# Verify that a file still exists and no data loss has occurred.
# To use:
# - set testfile to a path under the mountpoint being tested
# - include create-test-file.yml before executing the operation to be
#   tested
# - execute the operation that could potentially result in a loss of
#   data in the filesystem where testfile is located
# - include this file (verify-data-preservation.yml)

- name: Stat the file
  stat:
    path: "{{ testfile }}"
  register: stat_r

- name: Assert file presence
  assert:
    that: stat_r.stat.isreg is defined and stat_r.stat.isreg
    msg: "data lost!"
