I am running an ansible-playbook
which is doing running tar
command to zip a directory. Following is the ansible
task.
- name: tar the old code
command: tar -czf {{ansible_date_time.date}}.tar.gz /home/ubuntu/my-folder
The above gives the following error.
"warnings": use unarchive module rather than running tar stderr: tar: Removing leading '/' from member names tar: /home/ubuntu/my-folder/xyz.log: file change as we read it
I also tried with option --ignore-failed-read
but it didn't zipped the directory but ran the rest of the tasks successfully.
- name: tar the old code
command: tar -czf {{ansible_date_time.date}}.tar.gz /home/ubuntu/my-folder --ignore-failed-read
Since this task is in between other tasks, the tasks which has to be run after this one fails.
ansible doesn't give module to tar the code. only unarchive
module is there to unzip the directory.
The tar command will exit with a return code of 1 when it experiences the "file change as we read it" problem, and while I can't speak with too much authority as to how Ansible interprets that, I'm assuming it will treat any non-zero return code as "failed." I worked around the issue by telling Ansible to redefine what it considers to be failure: